Skip to main content

Crate optic_window

Crate optic_window 

Source
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:

ActionMeaning
Is::PressedTrue only on the exact frame the button went down
Is::ReleasedTrue only on the exact frame the button came up
Is::HeldTrue 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§

pub use winit;
pub use gilrs;

Structs§

ButtonState
Per-button state machine.
Events
Per-frame input state snapshot.
ScreenInfo
Information about a connected monitor/screen.
Window
A winit window wrapper with frame-tracking and cursor management.

Enums§

GamepadAxis
Gamepad analog axis identifier.
GamepadButton
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.