The input module converts raw hardware events into gameplay-facing actions.
RawInputEvent: physical input events captured by the view layer.InputKeymap<T>: maps physical keys to actions of typeT.InputActionState<T>: frame-based action state (isPressed,justPressed,justReleased).InputEvent<T>: optional event stream for action transitions.InputSystem<T>: updatesInputActionStateand emitsInputEventfromRawInputEvent.
- Emit
RawInputEventfrom the platform/view layer. - Run
InputSystem<T>early in the frame. - Gameplay systems read
InputActionState<T>directly. - Optional: consume
InputEvent<T>for one-shot reactions (UI/audio).
final inputState = InputActionState<PlayerAction>();
engine.addSystem(
InputSystem<PlayerAction>(
eventBus: engine.events,
actionState: inputState,
keymap: InputKeymap<PlayerAction>()
..registerAction(action: PlayerAction.moveLeft, keys: [LogicalKeyboardKey.keyA])
..registerAction(action: PlayerAction.moveRight, keys: [LogicalKeyboardKey.keyD]),
),
);
if (inputState.isPressed(PlayerAction.moveLeft)) {
// apply movement this frame
}