euv_engine/input/struct.rs
1use crate::*;
2
3/// A zero-sized namespace struct providing static input event extraction methods.
4///
5/// This struct follows the same pattern as `App`, serving as a namespace for
6/// free-standing input utility functions that extract data from DOM events.
7#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, Ord, PartialEq, PartialOrd)]
8pub struct Input;
9
10/// Tracks the current state of all input devices (keyboard, mouse, touch)
11/// for a single game frame. The state should be updated by event handlers
12/// and cleared of per-frame data at the end of each frame.
13#[derive(Clone, Data, Debug, New, PartialEq)]
14pub struct InputState {
15 /// Key codes that were pressed during this frame.
16 #[get_mut(pub(crate))]
17 #[new(skip)]
18 pub(crate) keys_pressed: KeyStateSet,
19 /// Key codes that are currently held down.
20 #[get_mut(pub(crate))]
21 #[new(skip)]
22 pub(crate) keys_held: KeyStateSet,
23 /// Key codes that were released during this frame.
24 #[get_mut(pub(crate))]
25 #[new(skip)]
26 pub(crate) keys_released: KeyStateSet,
27 /// Mouse buttons that were pressed during this frame.
28 #[get_mut(pub(crate))]
29 #[new(skip)]
30 pub(crate) mouse_buttons_pressed: HashSet<MouseButton>,
31 /// Mouse buttons that are currently held down.
32 #[get_mut(pub(crate))]
33 #[new(skip)]
34 pub(crate) mouse_buttons_held: HashSet<MouseButton>,
35 /// Mouse buttons that were released during this frame.
36 #[get_mut(pub(crate))]
37 #[new(skip)]
38 pub(crate) mouse_buttons_released: HashSet<MouseButton>,
39 /// The current mouse position in screen coordinates.
40 #[get(type(copy))]
41 #[get_mut(pub(crate))]
42 #[new(skip)]
43 pub(crate) mouse_position: Vector2D,
44 /// The mouse position delta (movement) since the last frame.
45 #[get(type(copy))]
46 #[get_mut(pub(crate))]
47 #[new(skip)]
48 pub(crate) mouse_delta: Vector2D,
49 /// Whether the mouse has moved during this frame.
50 #[get(type(copy))]
51 #[get_mut(pub(crate))]
52 #[new(skip)]
53 pub(crate) mouse_moved: bool,
54 /// Active touch points mapped by identifier to screen position.
55 #[get_mut(pub(crate))]
56 #[new(skip)]
57 pub(crate) touch_points: TouchPointMap,
58 /// Touch point identifiers that started during this frame.
59 #[get_mut(pub(crate))]
60 #[new(skip)]
61 pub(crate) touch_started: HashSet<i32>,
62 /// Touch point identifiers that ended during this frame.
63 #[get_mut(pub(crate))]
64 #[new(skip)]
65 pub(crate) touch_ended: HashSet<i32>,
66}