fix(input): ignore raw face presses when Joy-Con is gamepad

love-nx emits gamepad+raw on one press; NamingScreen saw a+b and always
erased. Skip raw when isGamepad(); align NX Y→a/X→b; prefer A if both.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Andrew Quenehen
2026-08-01 04:15:47 -03:00
parent 925b224eda
commit efd81d8e34
6 changed files with 89 additions and 24 deletions
+42
View File
@@ -0,0 +1,42 @@
-- When isGamepad(), raw face presses must not stack on gamepad* (NamingScreen a+b).
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")
GamepadMap._setForceNXForTests(true)
eq(GamepadMap.mapRawButton(3), "a", "NX raw Y (#3) -> GB A")
eq(GamepadMap.mapRawButton(4), "b", "NX raw X (#4) -> GB B")
GamepadMap._setForceNXForTests(false)
Input:init()
Input:gamepadpressed(gamepadJoy, "a")
Input:joystickpressed(gamepadJoy, 1) -- must no-op
Input:joystickpressed(gamepadJoy, 2) -- must no-op (would have set b)
Input:step()
check(Input:wasPressed("a"), "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")
Input:init()
Input:joystickpressed(rawJoy, 1)
Input:step()
check(Input:wasPressed("a"), "non-gamepad raw #1 still maps to A")
T.finish()
+5 -5
View File
@@ -9,11 +9,11 @@ local GamepadMap = require("src.core.GamepadMap")
GamepadMap._setForceNXForTests(true)
-- Phase 0 probe: Y→#3, X→#4; Nintendo B/A at #1/#2.
eq(GamepadMap.mapRawButton(3), "b", "NX raw Y (#3) maps to GB B")
eq(GamepadMap.mapRawButton(4), "a", "NX raw X (#4) maps to GB A")
eq(GamepadMap.mapRawToGamepadButton(3), "y", "NX raw #3 routes to gamepad y")
eq(GamepadMap.mapRawToGamepadButton(4), "x", "NX raw #4 routes to gamepad x")
-- Phase 0 / naming diagnosis: Y→#3→a, X→#4→b; Nintendo B/A at #1/#2.
eq(GamepadMap.mapRawButton(3), "a", "NX raw Y (#3) maps to GB A")
eq(GamepadMap.mapRawButton(4), "b", "NX raw X (#4) maps to GB B")
eq(GamepadMap.mapRawToGamepadButton(3), "a", "NX raw #3 routes to gamepad a")
eq(GamepadMap.mapRawToGamepadButton(4), "b", "NX raw #4 routes to gamepad b")
eq(GamepadMap.mapRawButton(9), "select", "NX minus (#9) -> select")
eq(GamepadMap.mapRawButton(10), "start", "NX plus (#10) -> start")