SimpleWindow first pass at gamepad support
This commit is contained in:
@@ -14,10 +14,21 @@
|
||||
("Vertical"
|
||||
null)
|
||||
("Menu"
|
||||
null)
|
||||
(subMenu))
|
||||
("Quit"
|
||||
(Sys.exit 0))
|
||||
(never otherwise))))
|
||||
|
||||
(method subMenu []
|
||||
(.enableGamepadInput
|
||||
(SimpleWindow.promptForChoice "SubMenu" ["A" "B" "C" "{tab} Back"]
|
||||
->:Void choice
|
||||
(case choice
|
||||
("{tab} Back" (showMenu))
|
||||
(never otherwise)))
|
||||
true
|
||||
null
|
||||
[=>B "tab"]))
|
||||
|
||||
(method &override :Void update [:Float elapsed]
|
||||
(super.update elapsed))
|
@@ -11,6 +11,10 @@ import flixel.FlxSprite;
|
||||
import flixel.util.FlxColor;
|
||||
import flixel.group.FlxGroup;
|
||||
import kiss_flixel.FlxKeyShortcutHandler;
|
||||
import flixel.input.actions.FlxAction;
|
||||
import flixel.input.actions.FlxActionInput;
|
||||
import flixel.input.FlxInput;
|
||||
import flixel.input.gamepad.FlxGamepadInputID;
|
||||
|
||||
typedef ShortcutAction = Void->Void;
|
||||
typedef Action = FlxSprite->Void;
|
||||
|
@@ -495,4 +495,24 @@
|
||||
|
||||
// Irreversibly disable the window's buttons (for when you're going to hide it in the next frame)
|
||||
(method clearActions []
|
||||
(_actions.clear))
|
||||
(_actions.clear))
|
||||
|
||||
(method enableGamepadInput [:Bool addDefaultUIInputs &opt :Map<FlxGamepadInputID,String> uiKeyMappings :Map<FlxGamepadInputID,String> otherKeyMappings :Int gamepadId]
|
||||
(unless uiKeyMappings (set uiKeyMappings (new Map)))
|
||||
(localVar DEFAULT_UI_INPUTS [
|
||||
=>xKey [B]
|
||||
=>leftKey [DPAD_LEFT LEFT_STICK_DIGITAL_LEFT]
|
||||
=>rightKey [DPAD_RIGHT LEFT_STICK_DIGITAL_RIGHT]
|
||||
=>upKey [DPAD_UP LEFT_STICK_DIGITAL_UP]
|
||||
=>downKey [DPAD_DOWN LEFT_STICK_DIGITAL_DOWN]
|
||||
=>enterKey [A START]
|
||||
])
|
||||
(when addDefaultUIInputs
|
||||
(doFor key [xKey leftKey rightKey upKey downKey enterKey]
|
||||
(whenLet [key key buttons (dictGet DEFAULT_UI_INPUTS key)]
|
||||
(doFor button buttons
|
||||
(dictSet uiKeyMappings button key)))))
|
||||
(xHandler.enableGamepadInput uiKeyMappings gamepadId)
|
||||
(when otherKeyMappings
|
||||
(keyHandler.enableGamepadInput otherKeyMappings gamepadId))
|
||||
this)
|
Reference in New Issue
Block a user