euv_core/window/input/struct.rs
1use super::*;
2
3/// Keyboard modifier key states.
4#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, Ord, PartialEq, PartialOrd)]
5pub struct Modifiers {
6 /// Shift modifier pressed.
7 #[get(type(copy))]
8 pub(crate) shift: bool,
9 /// Control modifier pressed.
10 #[get(type(copy))]
11 pub(crate) ctrl: bool,
12 /// Alt / Option modifier pressed.
13 #[get(type(copy))]
14 pub(crate) alt: bool,
15 /// Command / Meta / Super modifier pressed.
16 #[get(type(copy))]
17 pub(crate) meta: bool,
18}
19
20/// Unified pointer event normalizing mouse, touch, and stylus/Apple Pencil input.
21#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
22pub struct PointerEvent {
23 /// Stable pointer contact identifier (multi-touch / stylus tracking).
24 #[get(type(copy))]
25 pub(crate) pointer_id: u64,
26 /// Originating pointer hardware class.
27 #[get(type(copy))]
28 pub(crate) device: PointerDevice,
29 /// Logical coordinates inside the window.
30 #[get(type(copy))]
31 pub(crate) position: Point,
32 /// Activated button.
33 #[get(type(copy))]
34 pub(crate) button: PointerButton,
35 /// Normalized contact pressure in `[0.0, 1.0]`.
36 #[get(type(copy))]
37 pub(crate) pressure: f32,
38 /// Active keyboard modifiers.
39 #[get(type(copy))]
40 pub(crate) modifiers: Modifiers,
41}
42
43/// Unified keyboard event payload.
44#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, PartialEq)]
45pub struct KeyEvent {
46 /// Normalized key code.
47 #[get(type(copy))]
48 pub(crate) code: KeyCode,
49 /// Active keyboard modifiers.
50 #[get(type(copy))]
51 pub(crate) modifiers: Modifiers,
52 /// Whether this event is an OS auto-repeat.
53 #[get(type(copy))]
54 pub(crate) repeat: bool,
55}
56
57/// Real-time cross-platform gesture payload emitted reactively through `Context::get_gesture()`.
58#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
59pub struct GestureEvent {
60 /// Monotonic gesture sequence counter ensuring back-to-back identical gestures trigger reactivity.
61 #[get(type(copy))]
62 pub(crate) sequence: u64,
63 /// Classified gesture kind (`Tap`, `DoubleTap`, `LongPress`, `Swipe*`, `Pan`, `Pinch`).
64 #[get(type(copy))]
65 pub(crate) kind: GestureEventKind,
66 /// Starting logical coordinates of the gesture.
67 #[get(type(copy))]
68 pub(crate) origin: Point,
69 /// Ending or current logical coordinates of the gesture.
70 #[get(type(copy))]
71 pub(crate) position: Point,
72 /// Net displacement `(dx, dy)` from `origin` to `position`.
73 #[get(type(copy))]
74 pub(crate) delta: Point,
75 /// Relative pinch scale factor (`1.0` for non-pinch gestures, `> 1.0` zoom in, `< 1.0` zoom out).
76 #[get(type(copy))]
77 pub(crate) scale: f32,
78 /// Number of active pointers/fingers involved in the gesture.
79 #[get(type(copy))]
80 pub(crate) pointer_count: u8,
81 /// Originating pointer device class (`Mouse`, `Touch`, `Stylus`).
82 #[get(type(copy))]
83 pub(crate) device: PointerDevice,
84}