Skip to content

@modoki/engine / index / Input

Variable: Input

const Input: Trait<() => object>

Input resource — the canonical, source-agnostic input snapshot for this frame (Part A2 of the input-and-ui-focus plan). A world-scoped singleton (like Time): the app-pipeline inputSystem merges every attached source into it BEFORE GAME-priority systems run, and game/UI logic reads it via the accessors below — never from window/navigator directly.

It is PLAIN DATA (determinism-guard-safe, trivially serializable), so the headless harness sets it by hand instead of faking a device: world.spawn(Input); setAxis(world, 'moveX', 1); setPressed(world, 'confirm', true); step(1); // characterInputSystem / uiFocusSystem read it deterministically

koota note: AoS (callback) form because the fields are nested objects — the callback runs per entity so the singleton gets its OWN fresh maps (no shared default). inputSystem mutates these in place each frame. This resource is runtime-only (spawned like Time, never hand-authored into a scene) so it is intentionally not registered as an editor-inspectable trait.

Built with Modoki.