euv_core/game/input/struct.rs
1use super::*;
2
3/// Real-time polled keyboard, pointer, and scroll input state for games and interactive viewports.
4#[derive(Clone, Data, Debug, Default, New)]
5pub struct InputState {
6 /// Set of keys currently held down.
7 #[new(skip)]
8 pub(crate) keys_down: HashSet<KeyCode>,
9 /// Set of keys pressed during the current frame.
10 #[new(skip)]
11 pub(crate) keys_just_pressed: HashSet<KeyCode>,
12 /// Set of keys released during the current frame.
13 #[new(skip)]
14 pub(crate) keys_just_released: HashSet<KeyCode>,
15 /// Set of pointer buttons currently held down.
16 #[new(skip)]
17 pub(crate) buttons_down: HashSet<PointerButton>,
18 /// Set of pointer buttons pressed during the current frame.
19 #[new(skip)]
20 pub(crate) buttons_just_pressed: HashSet<PointerButton>,
21 /// Set of pointer buttons released during the current frame.
22 #[new(skip)]
23 pub(crate) buttons_just_released: HashSet<PointerButton>,
24 /// Latest logical pointer coordinates.
25 #[new(skip)]
26 #[get(type(copy))]
27 pub(crate) pointer_position: Point,
28 /// Accumulated logical pointer movement delta during the current frame.
29 #[new(skip)]
30 #[get(type(copy))]
31 pub(crate) pointer_delta: Point,
32 /// Accumulated scroll delta during the current frame.
33 #[new(skip)]
34 #[get(type(copy))]
35 pub(crate) scroll_delta: Point,
36 /// Virtual analog movement stick `(-1.0..=1.0, -1.0..=1.0)` fed by touch drag-joysticks or gamepads.
37 #[new(skip)]
38 #[get(type(copy))]
39 pub(crate) virtual_axis: Point,
40 /// Virtual touch/gamepad primary fire trigger state.
41 #[new(skip)]
42 #[get(type(copy))]
43 pub(crate) virtual_fire: bool,
44 /// Virtual touch/gamepad dash/boost trigger state.
45 #[new(skip)]
46 #[get(type(copy))]
47 pub(crate) virtual_dash: bool,
48 /// Latest keyboard modifier flags reported by key or pointer events.
49 #[new(skip)]
50 #[get(type(copy))]
51 pub(crate) modifiers: Modifiers,
52}
53
54/// Declarative multi-key and pointer-button binding table mapping physical inputs to `GameAction`s.
55#[derive(Clone, Data, Debug)]
56pub struct ActionMap {
57 /// Keyboard bindings grouped by semantic `GameAction`.
58 pub(crate) key_bindings: HashMap<GameAction, Vec<KeyCode>>,
59 /// Pointer button bindings grouped by semantic `GameAction`.
60 pub(crate) button_bindings: HashMap<GameAction, Vec<PointerButton>>,
61}