optic_window/lib.rs
1//! Windowing and input subsystem for the Optic engine.
2//!
3//! Wraps [`winit`] (window creation, event loop) and [`gilrs`] (gamepad support)
4//! into a frame-based input model. Input state is captured once per frame as a
5//! snapshot, avoiding callback-driven event handling in game code.
6//!
7//! # Frame-based input
8//!
9//! Every input method accepts an [`Is`] action to query:
10//!
11//! | Action | Meaning |
12//! |--------|---------|
13//! | [`Is::Pressed`] | True only on the exact frame the button went down |
14//! | [`Is::Released`] | True only on the exact frame the button came up |
15//! | [`Is::Held`] | True every frame while the button is held |
16//!
17//! This is the same pattern used by frame-based state machines: `Pressed`
18//! is the leading edge, `Released` is the trailing edge, `Held` is the level.
19//!
20//! # Architecture
21//!
22//! The [`Window`] owns the winit window handle. The [`Events`] struct holds
23//! per-frame input state (keys, mouse, gamepad). The game loop (`optic_loop`)
24//! drives both: it processes winit events into `Events` via
25//! [`process_window_event`](Events::process_window_event) and calls
26//! [`end_frame`](Events::end_frame) at the end of each frame.
27
28mod events;
29mod screen;
30mod window;
31
32pub use events::*;
33pub use screen::*;
34pub use window::*;
35
36pub use winit;
37pub use gilrs;