From bc5213d4d3335f46c0a83aba05f1ecb4be6bf4e0 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Fri, 7 Jul 2023 09:05:47 -0600 Subject: [PATCH] suppress JUST_PRESSED event on first frame with gamepad input --- src/kiss_flixel/FlxKeyShortcutHandler.kiss | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/kiss_flixel/FlxKeyShortcutHandler.kiss b/src/kiss_flixel/FlxKeyShortcutHandler.kiss index 6939f50..31f9091 100644 --- a/src/kiss_flixel/FlxKeyShortcutHandler.kiss +++ b/src/kiss_flixel/FlxKeyShortcutHandler.kiss @@ -33,13 +33,17 @@ (unless gamepadId (set gamepadId FlxInputDeviceID.ALL)) (set buttonActions (for =>buttonId keyString buttonToKeyMappings - (.addGamepad - (new FlxActionDigital - "${buttonId}->${keyString}" - ->:Void _ (handleKey keyString)) - buttonId - JUST_PRESSED - gamepadId)))) + (let [action + (.addGamepad + (new FlxActionDigital + "${buttonId}->${keyString}") + buttonId + JUST_PRESSED + gamepadId)] + // capture the fake JUST_PRESSED event harmlessly + (action.update) + (set action.callback ->:Void _ (handleKey keyString)) + action)))) (method :Void update [] (doFor action buttonActions