Skip to main content

Module input

Module input 

Source
Expand description

Platform-agnostic input router.

Defines a small InputEvent vocabulary that’s a strict superset of what we need to translate from any input source (crossterm on native, ratzilla on web). The router consumes one InputEvent and produces zero or more Actions into a caller-owned Vec<Action> buffer; it also mutates the UiState that doesn’t belong on the sim side (mode, zoom_idx, running, last_mouse_pos).

Adapters live next to their event source — app.rs::translate_crossterm produces InputEvent from crossterm::event::Event, and (when the wasm port lands) a sibling adapter does the same for ratzilla::event. Both feed the same router so behavior parity is enforced by sharing code, not by duplicating it.

Geometry (fingerer_rows, upgrade_rows, help_hits, etc.) is passed in via InputContext — the renderer recomputes these every frame and the click handler hit-tests against the latest set.

Structs§

InputContext
Per-frame geometry the click router hit-tests against. All Rects come from the latest ui::draw output; current is the latest published snapshot. Borrowed for the duration of one event dispatch.
Modifiers
UiState
State that lives on the input/render side of the boundary, not on the sim. Persistence-wise: not serialized, recreated fresh on each launch.

Enums§

InputEvent
Platform-neutral input vocabulary. Crossterm’s Event::{Key,Mouse,Resize,…} and ratzilla’s KeyEvent/MouseEvent/WheelEvent both narrow into this — anything we don’t need (focus, paste, resize) is dropped at the adapter.
KeyCode
Subset of key codes the game actually consumes. Anything else from the underlying terminal event is dropped at the adapter.
MouseButton
Subset of mouse buttons the game cares about. Middle-click is dropped at every adapter (it had no game effect on native and we don’t intend one on web either); add a variant here if a future input source wants it routed.
WheelDelta

Functions§

process_input_event
Process one InputEvent. Mutates UiState; appends produced actions to out. Pure data — does no I/O. The router reads GameState (via ctx.current for prestige_available() / golden.is_some() and via ui::hands::occupied_at for misclick gating) but never mutates it; all mutation flows through the produced Actions and apply_action.