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, pub command: bool, }
48
49#[derive(Clone, Debug)]
50pub enum Key {
51 Character(char),
52 Enter,
53 Tab,
54 Backspace,
55 Delete,
56 Escape,
57 ArrowLeft,
58 ArrowRight,
59 ArrowUp,
60 ArrowDown,
61 Home,
62 End,
63 PageUp,
64 PageDown,
65 Space,
66 F(u8), }
68
69#[derive(Clone, Debug)]
70pub struct KeyEvent {
71 pub key: Key,
72 pub modifiers: Modifiers,
73 pub is_repeat: bool,
74}
75
76#[derive(Clone, Debug)]
77pub struct TextInputEvent {
78 pub text: String,
79}
80
81#[derive(Clone, Debug)]
82pub enum ImeEvent {
83 Start,
85 Update {
87 text: String,
88 cursor: Option<(usize, usize)>, },
90 Commit(String),
92 Cancel,
94}
95
96#[derive(Clone, Debug)]
97pub enum InputEvent {
98 Pointer(PointerEvent),
99 Key(KeyEvent),
100 Text(TextInputEvent),
101 Ime(ImeEvent),
102}