SimpleWindow first pass at gamepad support
This commit is contained in:
@@ -14,10 +14,21 @@
|
|||||||
("Vertical"
|
("Vertical"
|
||||||
null)
|
null)
|
||||||
("Menu"
|
("Menu"
|
||||||
null)
|
(subMenu))
|
||||||
("Quit"
|
("Quit"
|
||||||
(Sys.exit 0))
|
(Sys.exit 0))
|
||||||
(never otherwise))))
|
(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]
|
(method &override :Void update [:Float elapsed]
|
||||||
(super.update elapsed))
|
(super.update elapsed))
|
||||||
@@ -11,6 +11,10 @@ import flixel.FlxSprite;
|
|||||||
import flixel.util.FlxColor;
|
import flixel.util.FlxColor;
|
||||||
import flixel.group.FlxGroup;
|
import flixel.group.FlxGroup;
|
||||||
import kiss_flixel.FlxKeyShortcutHandler;
|
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 ShortcutAction = Void->Void;
|
||||||
typedef Action = FlxSprite->Void;
|
typedef Action = FlxSprite->Void;
|
||||||
|
|||||||
@@ -496,3 +496,23 @@
|
|||||||
// Irreversibly disable the window's buttons (for when you're going to hide it in the next frame)
|
// Irreversibly disable the window's buttons (for when you're going to hide it in the next frame)
|
||||||
(method clearActions []
|
(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