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 /// Latest logical pointer coordinates.
19 #[new(skip)]
20 #[get(type(copy))]
21 pub(crate) pointer_position: Point,
22 /// Accumulated logical pointer movement delta during the current frame.
23 #[new(skip)]
24 #[get(type(copy))]
25 pub(crate) pointer_delta: Point,
26 /// Accumulated scroll delta during the current frame.
27 #[new(skip)]
28 #[get(type(copy))]
29 pub(crate) scroll_delta: Point,
30 /// Virtual analog movement stick `(-1.0..=1.0, -1.0..=1.0)` fed by touch drag-joysticks or gamepads.
31 #[new(skip)]
32 #[get(type(copy))]
33 pub(crate) virtual_axis: Point,
34 /// Virtual touch/gamepad primary fire trigger state.
35 #[new(skip)]
36 #[get(type(copy))]
37 pub(crate) virtual_fire: bool,
38 /// Virtual touch/gamepad dash/boost trigger state.
39 #[new(skip)]
40 #[get(type(copy))]
41 pub(crate) virtual_dash: bool,
42 /// Latest keyboard modifier flags reported by key or pointer events.
43 #[new(skip)]
44 #[get(type(copy))]
45 pub(crate) modifiers: Modifiers,
46}
47
48/// Declarative multi-key and pointer-button binding table mapping physical inputs to `GameAction`s.
49#[derive(Clone, Data, Debug)]
50pub struct ActionMap {
51 /// Keyboard bindings grouped by semantic `GameAction`.
52 pub(crate) key_bindings: HashMap<GameAction, Vec<KeyCode>>,
53 /// Pointer button bindings grouped by semantic `GameAction`.
54 pub(crate) button_bindings: HashMap<GameAction, Vec<PointerButton>>,
55}