Expand description
Action / binding abstraction over raw InputEvents.
Game code asks “is the jump action pressed?” instead of pattern-matching
on every key. Bindings can be reconfigured at runtime (rebind menus,
per-profile mappings) without touching gameplay logic.
The map is updated once per frame from the engine’s input queue; query functions never block and never allocate.
§Example
let mut map = InputMap::new();
map.bind("jump", InputBinding::Key(KeyCode::Space));
map.bind("jump", InputBinding::Mouse(MouseButton::Left)); // also fires on click
map.update(&[InputEvent::KeyPressed { key_code: KeyCode::Space }]);
assert!(map.is_pressed("jump"));
assert!(map.just_pressed("jump"));
map.update(&[]); // next frame, no event
assert!(map.is_pressed("jump")); // still held — no Released event
assert!(!map.just_pressed("jump")); // edge clearedStructs§
- Action
- A user-defined action name like
"jump","fire","menu_back". - Input
Map - Action / binding map. One per engine — registered as a service in the
ServiceRegistryand updated once per frame from the input queue.
Enums§
- Input
Binding - Anything that can be bound to an
Action.