InputMapImpl

EntityInputMapBaseceramic.InputMapImpl (Class) → InputMap

Implementation class for the InputMap system.

This class provides the actual functionality for mapping physical inputs (keyboard, mouse, gamepad) to logical game actions. It supports complex input scenarios including:

  • Multiple inputs bound to a single action
  • Digital-to-analog conversion (e.g., WASD to movement axis)
  • Analog-to-digital conversion (e.g., trigger press threshold)
  • Input state tracking (pressed, just pressed, just released)
  • Gamepad-specific targeting
  • UI focus integration

The implementation uses an efficient index-based system to track bindings and input states, minimizing overhead during runtime input processing.

Instance Members

gamepadId: Int

Target events of a specific gamepad by setting its gamepad id. If kept to default (-1), events from any gamepad will be handled. Useful for multiplayer games where each player has their own controller.


checkJustPressedAtBind: Bool

If set to true, when binding a new input, the system will check if the input was just pressed this frame and set the initial state accordingly. This prevents immediate triggering of "just pressed" events when binding an input that's already being held down.


enabled: Bool

Set to false to disable this input map entirely. When disabled, all input queries will return false/0.0 and no events will be triggered. Useful for pausing input handling or switching between different input schemes.


bindKeyCode(key: ceramic.InputMapImpl.T, keyCode: KeyCode): Void

Binds a keyboard key code to an action. Multiple key codes can be bound to the same action.

Name Type Description
key ceramic.InputMapImpl.T The action to bind to
keyCode KeyCode The keyboard key code to bind

boundKeyCodes(key: ceramic.InputMapImpl.T): ReadOnlyArray<KeyCode>

Gets all key codes currently bound to an action.

Name Type Description
key ceramic.InputMapImpl.T The action to query
Returns Description
ReadOnlyArray<KeyCode> Array of bound key codes (empty if none)

unbindKeyCode(key: ceramic.InputMapImpl.T, keyCode: KeyCode): Void

Removes a key code binding from an action.

Name Type Description
key ceramic.InputMapImpl.T The action to unbind from
keyCode KeyCode The key code to unbind

bindKeyCodeToAxis(key: ceramic.InputMapImpl.T, keyCode: KeyCode, axisValue: Float): Void

Binds a keyboard key to an analog axis action. When the key is pressed, it will set the axis to the specified value. Useful for digital-to-analog conversion (e.g., WASD to movement).

Name Type Description
key ceramic.InputMapImpl.T The axis action to bind to
keyCode KeyCode The keyboard key code to bind
axisValue Float The axis value when pressed (typically -1.0 or 1.0)

boundKeyCodesToAxis(key: ceramic.InputMapImpl.T): ReadOnlyArray<KeyCode>

Gets all key codes bound to an axis action.

Name Type Description
key ceramic.InputMapImpl.T The axis action to query
Returns Description
ReadOnlyArray<KeyCode> Array of bound key codes (empty if none)

boundKeyCodeToAxisValue(key: ceramic.InputMapImpl.T, keyCode: KeyCode): Float

Gets the axis value associated with a key code binding.

Name Type Description
key ceramic.InputMapImpl.T The axis action
keyCode KeyCode The key code to check
Returns Description
Float The axis value for this binding, or 0 if not bound

unbindKeyCodeToAxis(key: ceramic.InputMapImpl.T, keyCode: KeyCode): Void

Removes a key code to axis binding.

Name Type Description
key ceramic.InputMapImpl.T The axis action to unbind from
keyCode KeyCode The key code to unbind

bindScanCode(key: ceramic.InputMapImpl.T, scanCode: ScanCode): Void

Binds a keyboard scan code to an action. Scan codes represent physical key positions and are layout-independent.

Name Type Description
key ceramic.InputMapImpl.T The action to bind to
scanCode ScanCode The scan code to bind

boundScanCodes(key: ceramic.InputMapImpl.T): ReadOnlyArray<ScanCode>

Gets all scan codes currently bound to an action.

Name Type Description
key ceramic.InputMapImpl.T The action to query
Returns Description
ReadOnlyArray<ScanCode> Array of bound scan codes (empty if none)

unbindScanCode(key: ceramic.InputMapImpl.T, scanCode: ScanCode): Void

Removes a scan code binding from an action.

Name Type Description
key ceramic.InputMapImpl.T The action to unbind from
scanCode ScanCode The scan code to unbind

bindScanCodeToAxis(key: ceramic.InputMapImpl.T, scanCode: ScanCode, axisValue: Float): Void
Name Type
key ceramic.InputMapImpl.T
scanCode ScanCode
axisValue Float

boundScanCodesToAxis(key: ceramic.InputMapImpl.T): ReadOnlyArray<ScanCode>
Name Type
key ceramic.InputMapImpl.T
Returns
ReadOnlyArray<ScanCode>

boundScanCodeToAxisValue(key: ceramic.InputMapImpl.T, scanCode: ScanCode): Float
Name Type
key ceramic.InputMapImpl.T
scanCode ScanCode
Returns
Float

unbindScanCodeToAxis(key: ceramic.InputMapImpl.T, scanCode: ScanCode): Void
Name Type
key ceramic.InputMapImpl.T
scanCode ScanCode

bindMouseButton(key: ceramic.InputMapImpl.T, buttonId: Int): Void

Binds a mouse button to an action.

Name Type Description
key ceramic.InputMapImpl.T The action to bind to
buttonId Int The mouse button ID (0=left, 1=right, 2=middle)

boundMouseButtons(key: ceramic.InputMapImpl.T): ReadOnlyArray<Int>

Gets all mouse buttons currently bound to an action.

Name Type Description
key ceramic.InputMapImpl.T The action to query
Returns Description
ReadOnlyArray<Int> Array of bound mouse button IDs (empty if none)

unbindMouseButton(key: ceramic.InputMapImpl.T, buttonId: Int): Void

Removes a mouse button binding from an action.

Name Type Description
key ceramic.InputMapImpl.T The action to unbind from
buttonId Int The mouse button ID to unbind

bindGamepadButton(key: ceramic.InputMapImpl.T, button: GamepadButton): Void

Binds a gamepad button to an action.

Name Type Description
key ceramic.InputMapImpl.T The action to bind to
button GamepadButton The gamepad button to bind

boundGamepadButtons(key: ceramic.InputMapImpl.T): ReadOnlyArray<GamepadButton>

Gets all gamepad buttons currently bound to an action.

Name Type Description
key ceramic.InputMapImpl.T The action to query
Returns Description
ReadOnlyArray<GamepadButton> Array of bound gamepad buttons (empty if none)

unbindGamepadButton(key: ceramic.InputMapImpl.T, button: GamepadButton): Void

Removes a gamepad button binding from an action.

Name Type Description
key ceramic.InputMapImpl.T The action to unbind from
button GamepadButton The gamepad button to unbind

bindGamepadButtonToAxis(key: ceramic.InputMapImpl.T, button: GamepadButton, axisValue: Float): Void
Name Type
key ceramic.InputMapImpl.T
button GamepadButton
axisValue Float

boundGamepadButtonsToAxis(key: ceramic.InputMapImpl.T): ReadOnlyArray<GamepadButton>
Name Type
key ceramic.InputMapImpl.T
Returns
ReadOnlyArray<GamepadButton>

boundGamepadButtonToAxisValue(key: ceramic.InputMapImpl.T, button: GamepadButton): Float
Name Type
key ceramic.InputMapImpl.T
button GamepadButton
Returns
Float

unbindGamepadButtonToAxis(key: ceramic.InputMapImpl.T, button: GamepadButton): Void
Name Type
key ceramic.InputMapImpl.T
button GamepadButton

bindGamepadAxis(key: ceramic.InputMapImpl.T, axis: GamepadAxis): Void

Binds a gamepad analog axis to an axis action. The axis value will be passed through directly.

Name Type Description
key ceramic.InputMapImpl.T The axis action to bind to
axis GamepadAxis The gamepad axis to bind

boundGamepadAxes(key: ceramic.InputMapImpl.T): ReadOnlyArray<GamepadAxis>

Gets all gamepad axes currently bound to an axis action.

Name Type Description
key ceramic.InputMapImpl.T The axis action to query
Returns Description
ReadOnlyArray<GamepadAxis> Array of bound gamepad axes (empty if none)

unbindGamepadAxis(key: ceramic.InputMapImpl.T, axis: GamepadAxis): Void

Removes a gamepad axis binding from an axis action.

Name Type Description
key ceramic.InputMapImpl.T The axis action to unbind from
axis GamepadAxis The gamepad axis to unbind

bindGamepadAxisToButton(key: ceramic.InputMapImpl.T, axis: GamepadAxis, startValue: Float): Void

Binds a gamepad axis to a button action with a threshold. The button will be "pressed" when the axis value crosses the threshold.

Name Type Description
key ceramic.InputMapImpl.T The button action to bind to
axis GamepadAxis The gamepad axis to bind
startValue Float The threshold value (positive for > threshold, negative for < threshold)

boundGamepadAxesToButton(key: ceramic.InputMapImpl.T): ReadOnlyArray<GamepadAxis>
Name Type
key ceramic.InputMapImpl.T
Returns
ReadOnlyArray<GamepadAxis>

boundGamepadAxisToButtonStartValue(key: ceramic.InputMapImpl.T, axis: GamepadAxis): Float
Name Type
key ceramic.InputMapImpl.T
axis GamepadAxis
Returns
Float

unbindGamepadAxisToButton(key: ceramic.InputMapImpl.T, axis: GamepadAxis): Void
Name Type
key ceramic.InputMapImpl.T
axis GamepadAxis

bindConvertedToAxis(key: ceramic.InputMapImpl.T, axisKey: ceramic.InputMapImpl.T, axisValue: Float): Void

Binds a button action to trigger an axis action when pressed. This allows button presses to set axis values.

Name Type Description
key ceramic.InputMapImpl.T The button action that triggers the axis
axisKey ceramic.InputMapImpl.T The axis action to trigger
axisValue Float The axis value to set when button is pressed

pressed(key: ceramic.InputMapImpl.T): Bool

Checks if an action is currently pressed (held down). Returns true for every frame while the input is held.

Name Type Description
key ceramic.InputMapImpl.T The action to check
Returns Description
Bool True if the action is currently pressed

justPressed(key: ceramic.InputMapImpl.T): Bool

Checks if an action was just pressed this frame. Returns true only on the frame the input was initially pressed.

Name Type Description
key ceramic.InputMapImpl.T The action to check
Returns Description
Bool True if the action was just pressed this frame

justReleased(key: ceramic.InputMapImpl.T): Bool

Checks if an action was just released this frame. Returns true only on the frame the input was released.

Name Type Description
key ceramic.InputMapImpl.T The action to check
Returns Description
Bool True if the action was just released this frame

axisValue(key: ceramic.InputMapImpl.T): Float

Gets the current value of an axis action. Returns 0.0 if the input map is disabled or no axis is active.

Name Type Description
key ceramic.InputMapImpl.T The axis action to check
Returns Description
Float The current axis value (typically -1.0 to 1.0)

new(): Void

Private Members

EMPTY_ARRAY: ReadOnlyArray<Int>

nextIndex: Int

keyToIndex: Map

indexToKey: Array<ceramic.InputMapImpl.T>

pressedKeys: Array<Int>

axisValues: Array<Float>

pressedKeyKinds: Array<InputMapKeyKind>

A way to know from which the pressed key comes from



emitKeyDown(key: ceramic.InputMapImpl.T): Void

Triggered when a mapped action is pressed (key down, button pressed, etc.). @event keyDown

Name Type Description
key ceramic.InputMapImpl.T The action that was pressed

emitKeyUp(key: ceramic.InputMapImpl.T): Void

Triggered when a mapped action is released (key up, button released, etc.). @event keyUp

Name Type Description
key ceramic.InputMapImpl.T The action that was released

emitAxis(key: ceramic.InputMapImpl.T, value: Float): Void

Triggered when an analog axis value changes for a mapped action. @event axis

Name Type Description
key ceramic.InputMapImpl.T The action associated with the axis
value Float The new axis value (typically -1.0 to 1.0)

keyToString(key: ceramic.InputMapImpl.T): String
Name Type
key ceramic.InputMapImpl.T
Returns
String

keyForIndex(index: Int): ceramic.InputMapImpl.T
Name Type
index Int
Returns
ceramic.InputMapImpl.T

indexOfKey(key: ceramic.InputMapImpl.T): Int
Name Type
key ceramic.InputMapImpl.T
Returns
Int

Metadata

Name Parameters
:hxGen -
:build tracker.macros.EventsMacro.build()
:autoBuild tracker.macros.EventsMacro.build()
:build ceramic.macros.EntityMacro.buildForCompletion()
:autoBuild ceramic.macros.EntityMacro.buildForCompletion()