InputMapRebinder
Entity →
ceramic.InputMapRebinder (Class)
A utility class for rebinding input mappings at runtime.
InputMapRebinder provides a user-friendly way to change input bindings
by listening for input and automatically binding it to the specified action.
This is commonly used in game settings menus to let players customize controls.
Features:
- Listen for any input type (keyboard, gamepad button, gamepad axis)
- Support for cancellation (ESC key or SELECT button by default)
- Configurable conditions for filtering valid inputs
- Events for tracking rebind operations
- Option to preserve or replace existing bindings
Example usage:
var rebinder = new InputMapRebinder<Action>();
rebinder.rebind(inputMap, Action.JUMP);
rebinder.onAfterRebindAny(this, (map, action) -> {
trace('Rebound action: ' + action);
});
rebinder.keyCondition = (action, key) -> {
return key.keyCode < KeyCode.F1 || key.keyCode > KeyCode.F12;
};
Instance Members
The dead zone threshold for converting analog axis movement to button presses.
When binding an axis as a button, the axis must exceed this value to register.
Default: 0.25 (25% of axis range)
The gamepad button that cancels the rebind operation.
Default: GamepadButton.SELECT
The keyboard key that cancels the rebind operation.
Default: KeyCode.ESCAPE
keyCondition(action: ceramic.InputMapRebinder.T, key: Key): Bool
Optional condition function to filter keyboard inputs during rebinding.
Return false to reject the input, true to accept it.
If null, all keyboard inputs are accepted (except cancel key).
| Name |
Type |
action |
ceramic.InputMapRebinder.T |
key |
Key |
Optional condition function to filter gamepad button inputs during rebinding.
Return false to reject the input, true to accept it.
If null, all gamepad buttons are accepted (except cancel button).
Optional condition function to filter gamepad axis inputs during rebinding.
Return false to reject the input, true to accept it.
If null, all gamepad axes are accepted.
Optional condition function to filter gamepad axis-to-button conversions during rebinding.
Return false to reject the input, true to accept it.
If null, all gamepad axis movements exceeding the dead zone are accepted.
rebind(inputMap: InputMap<ceramic.InputMapRebinder.T>, action: ceramic.InputMapRebinder.T, ?removeExisting: Bool = true): Void
Starts listening for input to rebind the specified action.
The rebinder will listen for keyboard, gamepad buttons, and gamepad axes
simultaneously and bind the first valid input received.
| Name |
Type |
Default |
Description |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
|
The input map to modify |
action |
ceramic.InputMapRebinder.T |
|
The action to rebind |
removeExisting |
Bool |
true |
If true, removes existing bindings before adding the new one |
Private Members
emitBeforeRebindAny(inputMap: InputMap<ceramic.InputMapRebinder.T>, action: ceramic.InputMapRebinder.T): Void
Triggered before any input is rebound, regardless of input type.
@event beforeRebindAny
| Name |
Type |
Description |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
The input map being modified |
action |
ceramic.InputMapRebinder.T |
The action being rebound |
emitAfterRebindAny(inputMap: InputMap<ceramic.InputMapRebinder.T>, action: ceramic.InputMapRebinder.T): Void
Triggered after any input is successfully rebound, regardless of input type.
@event afterRebindAny
| Name |
Type |
Description |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
The input map that was modified |
action |
ceramic.InputMapRebinder.T |
The action that was rebound |
isMatchingGamepad(inputMap: InputMap<ceramic.InputMapRebinder.T>, gamepadId: Int): Bool
| Name |
Type |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
gamepadId |
Int |
emitBeforeRebindKey(inputMap: InputMap<ceramic.InputMapRebinder.T>, action: ceramic.InputMapRebinder.T, key: Key): Void
Triggered before a keyboard key is bound to an action.
@event beforeRebindKey
| Name |
Type |
Description |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
The input map being modified |
action |
ceramic.InputMapRebinder.T |
The action being rebound |
key |
Key |
The keyboard key being bound |
emitAfterRebindKey(inputMap: InputMap<ceramic.InputMapRebinder.T>, action: ceramic.InputMapRebinder.T, key: Key): Void
Triggered after a keyboard key is successfully bound to an action.
@event afterRebindKey
| Name |
Type |
Description |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
The input map that was modified |
action |
ceramic.InputMapRebinder.T |
The action that was rebound |
key |
Key |
The keyboard key that was bound |
registerKeyListener(inputMap: InputMap<ceramic.InputMapRebinder.T>, action: ceramic.InputMapRebinder.T, ?removeExisting: Bool = true): Void
| Name |
Type |
Default |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
|
action |
ceramic.InputMapRebinder.T |
|
removeExisting |
Bool |
true |
removeKey(inputMap: InputMap<ceramic.InputMapRebinder.T>, action: ceramic.InputMapRebinder.T): Void
| Name |
Type |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
action |
ceramic.InputMapRebinder.T |
rebindKey(inputMap: InputMap<ceramic.InputMapRebinder.T>, action: ceramic.InputMapRebinder.T, key: Key, ?removeExisting: Bool = true): Void
| Name |
Type |
Default |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
|
action |
ceramic.InputMapRebinder.T |
|
key |
Key |
|
removeExisting |
Bool |
true |
Triggered before a gamepad button is bound to an action.
@event beforeRebindGamepadButton
| Name |
Type |
Description |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
The input map being modified |
action |
ceramic.InputMapRebinder.T |
The action being rebound |
button |
GamepadButton |
The gamepad button being bound |
Triggered after a gamepad button is successfully bound to an action.
@event afterRebindGamepadButton
| Name |
Type |
Description |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
The input map that was modified |
action |
ceramic.InputMapRebinder.T |
The action that was rebound |
button |
GamepadButton |
The gamepad button that was bound |
| Name |
Type |
Default |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
|
action |
ceramic.InputMapRebinder.T |
|
removeExisting |
Bool |
true |
| Name |
Type |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
action |
ceramic.InputMapRebinder.T |
| Name |
Type |
Default |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
|
action |
ceramic.InputMapRebinder.T |
|
button |
GamepadButton |
|
removeExisting |
Bool |
true |
emitBeforeRebindGamepadAxis(inputMap: InputMap<ceramic.InputMapRebinder.T>, action: ceramic.InputMapRebinder.T, axis: GamepadAxis): Void
Triggered before a gamepad axis is bound to an axis action.
@event beforeRebindGamepadAxis
| Name |
Type |
Description |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
The input map being modified |
action |
ceramic.InputMapRebinder.T |
The axis action being rebound |
axis |
GamepadAxis |
The gamepad axis being bound |
emitAfterRebindGamepadAxis(inputMap: InputMap<ceramic.InputMapRebinder.T>, action: ceramic.InputMapRebinder.T, axis: GamepadAxis): Void
Triggered after a gamepad axis is successfully bound to an axis action.
@event afterRebindGamepadAxis
| Name |
Type |
Description |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
The input map that was modified |
action |
ceramic.InputMapRebinder.T |
The axis action that was rebound |
axis |
GamepadAxis |
The gamepad axis that was bound |
registerGamepadAxisListener(inputMap: InputMap<ceramic.InputMapRebinder.T>, action: ceramic.InputMapRebinder.T, ?removeExisting: Bool = true): Void
| Name |
Type |
Default |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
|
action |
ceramic.InputMapRebinder.T |
|
removeExisting |
Bool |
true |
removeGamepadAxis(inputMap: InputMap<ceramic.InputMapRebinder.T>, action: ceramic.InputMapRebinder.T): Void
| Name |
Type |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
action |
ceramic.InputMapRebinder.T |
rebindGamepadAxis(inputMap: InputMap<ceramic.InputMapRebinder.T>, action: ceramic.InputMapRebinder.T, axis: GamepadAxis, value: Float, removeExisting: Bool): Void
Triggered before a gamepad axis is bound to a button action (axis-to-button conversion).
@event beforeRebindGamepadAxisToButton
| Name |
Type |
Description |
InputMap |
InputMap<ceramic.InputMapRebinder.T> |
The input map being modified |
action |
ceramic.InputMapRebinder.T |
The button action being rebound |
axis |
GamepadAxis |
The gamepad axis being bound as a button |
Triggered after a gamepad axis is successfully bound to a button action.
@event afterRebindGamepadAxisToButton
| Name |
Type |
Description |
InputMap |
InputMap<ceramic.InputMapRebinder.T> |
The input map that was modified |
action |
ceramic.InputMapRebinder.T |
The button action that was rebound |
axis |
GamepadAxis |
The gamepad axis that was bound as a button |
| Name |
Type |
Default |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
|
action |
ceramic.InputMapRebinder.T |
|
removeExisting |
Bool |
true |
| Name |
Type |
inputMap |
InputMap<ceramic.InputMapRebinder.T> |
action |
ceramic.InputMapRebinder.T |
| Name |
Parameters |
:hxGen |
- |
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |