mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-12 00:10:56 +02:00
2699c9a2f9
SDL labels south as a and east as b; on Switch remap so physical A confirms and physical B cancels in launcher and NamingScreen. Co-authored-by: Cursor <cursoragent@cursor.com>
61 lines
2.3 KiB
Lua
61 lines
2.3 KiB
Lua
-- When isGamepad(), raw face presses must not stack on gamepad* (NamingScreen a+b).
|
|
-- On NX, SDL face labels are swapped so physical A confirms / B cancels.
|
|
package.path = "./?.lua;./?/init.lua;" .. package.path
|
|
if not _G.love then _G.love = require("tests.love_stub") end
|
|
|
|
local T = require("tests.harness")
|
|
local check = T.check
|
|
local eq = T.eq
|
|
|
|
local GamepadMap = require("src.core.GamepadMap")
|
|
local Input = require("src.core.Input")
|
|
|
|
local gamepadJoy = {
|
|
isGamepad = function() return true end,
|
|
}
|
|
local rawJoy = {
|
|
isGamepad = function() return false end,
|
|
}
|
|
|
|
check(GamepadMap.ignoreRawForJoystick(gamepadJoy), "ignore raw when isGamepad")
|
|
check(not GamepadMap.ignoreRawForJoystick(rawJoy), "allow raw when not gamepad")
|
|
check(not GamepadMap.ignoreRawForJoystick(nil), "nil joystick does not ignore raw")
|
|
|
|
-- Desktop: SDL a → GB A (unchanged).
|
|
eq(GamepadMap.mapGamepadButton("a"), "a", "desktop SDL a -> GB A")
|
|
eq(GamepadMap.mapGamepadButton("b"), "b", "desktop SDL b -> GB B")
|
|
|
|
GamepadMap._setForceNXForTests(true)
|
|
eq(GamepadMap.mapGamepadButton("a"), "b", "NX SDL south (a) -> GB B (Nintendo B)")
|
|
eq(GamepadMap.mapGamepadButton("b"), "a", "NX SDL east (b) -> GB A (Nintendo A)")
|
|
eq(GamepadMap.mapRawButton(1), "b", "NX raw #1 Nintendo B -> GB B")
|
|
eq(GamepadMap.mapRawButton(2), "a", "NX raw #2 Nintendo A -> GB A")
|
|
eq(GamepadMap.mapRawButton(3), nil, "NX raw Y (#3) not mapped as confirm")
|
|
eq(GamepadMap.mapRawButton(4), nil, "NX raw X (#4) not mapped as confirm")
|
|
GamepadMap._setForceNXForTests(false)
|
|
|
|
Input:init()
|
|
Input:gamepadpressed(gamepadJoy, "a")
|
|
Input:joystickpressed(gamepadJoy, 1) -- must no-op
|
|
Input:joystickpressed(gamepadJoy, 2) -- must no-op
|
|
Input:step()
|
|
check(Input:wasPressed("a"), "desktop gamepad A edge present")
|
|
check(not Input:wasPressed("b"), "raw must not add B alongside gamepad A")
|
|
check(Input:isDown("a"), "A held from pad source only")
|
|
|
|
-- NX: physical A arrives as SDL "b" → GB A.
|
|
GamepadMap._setForceNXForTests(true)
|
|
Input:init()
|
|
Input:gamepadpressed(gamepadJoy, "b")
|
|
Input:step()
|
|
check(Input:wasPressed("a"), "NX physical A (SDL b) confirms as GB A")
|
|
check(not Input:wasPressed("b"), "NX physical A must not also erase")
|
|
GamepadMap._setForceNXForTests(false)
|
|
|
|
Input:init()
|
|
Input:joystickpressed(rawJoy, 1)
|
|
Input:step()
|
|
check(Input:wasPressed("a"), "non-gamepad raw #1 still maps to A on desktop")
|
|
|
|
T.finish()
|