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§
- Input
Context - Per-frame geometry the click router hit-tests against. All
Rects come from the latestui::drawoutput;currentis the latest published snapshot. Borrowed for the duration of one event dispatch. - Modifiers
- Tree
Render State - Render-side state for the upgrade tree modal. Holds the smoothed camera pan (so panning eases instead of snapping), the active drag tracker, and a snapshot of the last-seen cursor for cursor-change detection.
- 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§
- Input
Event - Platform-neutral input vocabulary. Crossterm’s
Event::{Key,Mouse,Resize,…}and ratzilla’sKeyEvent/MouseEvent/WheelEventboth 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.
- Mouse
Button - 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.
- Wheel
Delta
Functions§
- process_
input_ event - Process one
InputEvent. MutatesUiState; appends produced actions toout. Pure data — does no I/O. The router readsGameState(viactx.currentforprestige_available()/powerups.iter()and viaui::hands::occupied_atfor misclick gating) but never mutates it; all mutation flows through the producedActions andapply_action.