1use crate::Vec2;
2
3#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4pub struct PointerId(pub u64);
5
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7pub enum PointerKind {
8 Mouse,
9 Touch,
10 Pen,
11}
12
13#[derive(Clone, Copy, Debug)]
14pub enum PointerButton {
15 Primary, Secondary, Tertiary, }
19
20#[derive(Clone, Copy, Debug)]
21pub enum PointerEventKind {
22 Down(PointerButton),
23 Up(PointerButton),
24 Move,
25 Cancel,
26 Enter,
27 Leave,
28}
29
30#[derive(Clone, Debug)]
31pub struct PointerEvent {
32 pub id: PointerId,
33 pub kind: PointerKind,
34 pub event: PointerEventKind,
35 pub position: Vec2,
36 pub pressure: f32,
37 pub modifiers: Modifiers,
38}
39
40#[derive(Clone, Copy, Debug, Default)]
41pub struct Modifiers {
42 pub shift: bool,
43 pub ctrl: bool,
44 pub alt: bool,
45 pub meta: bool, }
47
48#[derive(Clone, Debug)]
49pub enum Key {
50 Character(char),
51 Enter,
52 Tab,
53 Backspace,
54 Delete,
55 Escape,
56 ArrowLeft,
57 ArrowRight,
58 ArrowUp,
59 ArrowDown,
60 Home,
61 End,
62 PageUp,
63 PageDown,
64 Space,
65 F(u8), }
67
68#[derive(Clone, Debug)]
69pub struct KeyEvent {
70 pub key: Key,
71 pub modifiers: Modifiers,
72 pub is_repeat: bool,
73}
74
75#[derive(Clone, Debug)]
76pub struct TextInputEvent {
77 pub text: String,
78}
79
80#[derive(Clone, Debug)]
81pub enum ImeEvent {
82 Start,
84 Update {
86 text: String,
87 cursor: Option<(usize, usize)>, },
89 Commit(String),
91 Cancel,
93}
94
95#[derive(Clone, Debug)]
96pub enum InputEvent {
97 Pointer(PointerEvent),
98 Key(KeyEvent),
99 Text(TextInputEvent),
100 Ime(ImeEvent),
101}