Expand description
Windowing and input subsystem for the Optic engine.
Wraps winit (window creation, event loop) and gilrs (gamepad support)
into a frame-based input model. Input state is captured once per frame as a
snapshot, avoiding callback-driven event handling in game code.
§Frame-based input
Every input method accepts an Is action to query:
| Action | Meaning |
|---|---|
Is::Pressed | True only on the exact frame the button went down |
Is::Released | True only on the exact frame the button came up |
Is::Held | True every frame while the button is held |
This is the same pattern used by frame-based state machines: Pressed
is the leading edge, Released is the trailing edge, Held is the level.
§Architecture
The Window owns the winit window handle. The Events struct holds
per-frame input state (keys, mouse, gamepad). The game loop (optic_loop)
drives both: it processes winit events into Events via
process_window_event and calls
end_frame at the end of each frame.
Re-exports§
Structs§
- Button
State - Per-button state machine.
- Events
- Per-frame input state snapshot.
- Screen
Info - Information about a connected monitor/screen.
- Window
- A winit window wrapper with frame-tracking and cursor management.
Enums§
- Gamepad
Axis - Gamepad analog axis identifier.
- Gamepad
Button - Gamepad button identifier.
- Is
- Input action filter for frame-based queries.
- KeyCode
- Code representing the location of a physical key
- Mouse
- Mouse button identifier.
Constants§
- MAX_
GAMEPADS - Maximum number of supported gamepads.