class FlxActionManager
package flixel.input.actions
implements IFlxDestroyable, IFlxInputManager
High level input manager for FlxAction
s. This lets you manage multiple input
devices and action sets, and is the only supported method for natively using
the Steam Controller API.
Once you've set up FlxActionManager
, you can let flixel handle it globally
with: FlxG.inputs.add(myFlxActionManager)
;
If you don't add it globally, you will have to call update()
on it yourself.
If you are using the steamwrap library, FlxActionManager
can automatically
create action sets from a steamwrap object derived from the master vdf game
actions file that Steam makes you set up for native controller support.
You must then ACTIVATE one of those action sets for any connected steam
controllers, which will automatically attach the proper steam action inputs
to the actions in the set. You can also add as many regular FlxActionInput
s
as you like to any actions in the sets.
4.6.0
.Constructor
Variables
read onlydeviceConnected:FlxTypedSignal<(FlxInputDevice, Int, String) ‑> Void>
A signal fired when a device is connected. Returns the device type, handle/id, and a string identifier for the device model (if applicable)
read onlydeviceDisconnected:FlxTypedSignal<(FlxInputDevice, Int, String) ‑> Void>
A signal fired when a device currently in use is suddenly disconnected. Returns the device type, handle/id, and a string identifier for the device model (if applicable)
read onlyinputsChanged:FlxTypedSignal<Array<FlxAction> ‑> Void>
A signal fired when an action's inputs have been externally changed. Returns a list of all actions whose inputs have changed. For now only used for Steam Controllers.
resetOnStateSwitch:ResetPolicy = ResetPolicy.DEFAULT_SET_ONLY
Which action sets to remove on state switches.
Methods
activateSet(ActionSet:Int, Device:FlxInputDevice, DeviceID:Int):Void
Activate an action set for a particular device
Parameters:
ActionSet | The integer ID for the Action Set you want to activate |
---|---|
Device | The device type (Mouse, Keyboard, Gamepad, SteamController, etc) |
DeviceID | FlxGamepad ID or a Steam Controller Handle (ignored for Mouse/Keyboard) |
addAction(Action:FlxAction, ActionSet:Int = 0):Bool
Add an action to a particular action set
Parameters:
Action | The FlxAction you want to add |
---|---|
ActionSet | The index of the FlxActionSet you want to add |
Returns:
whether it was successfully added
addActions(Actions:Array<FlxAction>, ActionSet:Int = 0):Bool
Add actions to a particular action set
Parameters:
Actions | The FlxActions you want to add |
---|---|
ActionSet | The index of the FlxActionSet you want to add |
Returns:
whether they were all successfully added
addSet(set:FlxActionSet):Int
Add a FlxActionSet to the manager
Parameters:
set | The FlxActionSet you want to add |
---|
Returns:
the index of the FlxActionSet
deactivateSet(ActionSet:Int, DeviceID:Int = FlxInputDeviceID.ALL):Void
Deactivate an action set for any devices it is currently active for
Parameters:
ActionSet | The integer ID for the Action Set you want to deactivate |
---|---|
DeviceID | FlxGamepad ID or a Steam Controller Handle (ignored for Mouse/Keyboard) |
getSet(Index:Int):FlxActionSet
Get an action set
Parameters:
Index | Action set index |
---|
Returns:
The FlxActionSet at that location, or null if not found
getSetActivatedForDevice(device:FlxInputDevice, deviceID:Int = FlxInputDeviceID.ALL):FlxActionSet
Returns the action set that has been activated for this specific device
getSetIndex(Name:String):Int
Get the index of a particular action set
Parameters:
name | Action set name |
---|
Returns:
Index number of that set, -1 if not found
getSetName(Index:Int):String
Get the name of an action set
Parameters:
Index | Action set index |
---|
Returns:
Name of that set, "" if not found
initFromJson(data:ActionSetJsonArray, CallbackDigital:FlxActionDigital ‑> Void, CallbackAnalog:FlxActionAnalog ‑> Void):Int
Load action sets from a parsed Json object
Parameters:
data | Json object parsed from the same format that "exportToJson()" outputs |
---|---|
CallbackDigital | Callback function for digital actions |
CallbackAnalog | Callback function for analog actions |
Returns:
The number of new FlxActionSets created and added. 0 means nothing happened.
removeAction(Action:FlxAction, ActionSet:Int):Bool
Remove an action to a particular action set
Parameters:
Action | The FlxAction you want to remove |
---|---|
ActionSet | The index of the FlxActionSet you want to remove |
Returns:
whether it was successfully removed
removeSet(Set:FlxActionSet, Destroy:Bool = true):Bool
Remove a set from the manager
Parameters:
Set | The set you want to remove |
---|---|
Destroy | Whether to also destroy the set or just remove it from the list |
Returns:
whether the action was found & successfully removed