1#[derive(Debug, Clone, Copy)]
4#[repr(u32)]
5pub enum MouseEventKind {
6 Null = 0,
7 Change = 3, }
10
11#[derive(Debug, Clone, Copy, PartialEq, Eq)]
14#[repr(transparent)]
15pub struct MiceBtnStatus(u32);
16
17impl MiceBtnStatus {
18 pub const BTN_LEFT: Self = Self(1);
19 pub const BTN_RIGHT: Self = Self(2);
20 pub const BTN_MID: Self = Self(3);
21 pub const NO_BUTTONS: Self = Self(0);
22
23 pub const fn contains(&self, other: Self) -> bool {
24 (self.0 & other.0) == other.0
25 }
26
27 pub const fn or(&self, other: Self) -> Self {
28 Self(self.0 | other.0)
29 }
30
31 pub const fn and(&self, other: Self) -> Self {
32 Self(self.0 & other.0)
33 }
34
35 pub const fn not(&self) -> Self {
36 Self(!self.0)
37 }
38}
39
40#[derive(Debug, Clone, Copy)]
42pub struct MiceEvent {
43 pub kind: MouseEventKind,
44 pub buttons_status: MiceBtnStatus,
46 pub x_rel_change: i16,
48 pub y_rel_change: i16,
52}
53
54impl MiceEvent {
55 pub const fn null() -> Self {
57 Self {
58 kind: MouseEventKind::Null,
59 buttons_status: MiceBtnStatus(0),
60 x_rel_change: 0,
61 y_rel_change: 0,
62 }
63 }
64}
65
66#[derive(Debug, Clone, Copy)]
67#[repr(u32)]
68pub enum KeyEventKind {
69 Null = 0,
70 Press = 1,
71 Release = 2,
72}
73
74#[derive(Debug, Clone, Copy)]
76#[repr(C)]
77pub struct KeyEvent {
78 pub kind: KeyEventKind,
79 pub code: KeyCode,
80}
81
82impl KeyEvent {
83 pub const fn null() -> Self {
85 Self {
86 kind: KeyEventKind::Null,
87 code: KeyCode::Null,
88 }
89 }
90}
91
92#[derive(Clone, Copy, Debug, PartialEq, Eq)]
93#[repr(u32)]
94pub enum KeyCode {
95 Null = 0,
96 F1,
97 F2,
98 F3,
99 F4,
100 F5,
101 F6,
102 F7,
103 F8,
104 F9,
105 F10,
106 F11,
107 F12,
108 PrintScr,
109
110 Esc,
111 Key1,
112 Key2,
113 Key3,
114 Key4,
115 Key5,
116 Key6,
117 Key7,
118 Key8,
119 Key9,
120 Key0,
121 Minus,
122 Equals,
123 Backspace,
124
125 KeyQ,
126 KeyW,
127 KeyE,
128 KeyR,
129 KeyT,
130 KeyY,
131 KeyU,
132 KeyI,
133 KeyO,
134 KeyP,
135 LeftBrace,
136 RightBrace,
137 BackSlash,
138
139 KeyA,
140 KeyS,
141 KeyD,
142 KeyF,
143 KeyG,
144 KeyH,
145 KeyJ,
146 KeyK,
147 KeyL,
148 Semicolon,
149 DoubleQuote,
150 Return,
151
152 KeyZ,
153 KeyX,
154 KeyC,
155 KeyV,
156 KeyB,
157 KeyN,
158 KeyM,
159 BackQuote,
160 Comma,
161 Dot,
162 Slash,
163
164 Tab,
165 CapsLock,
166 Ctrl,
167 Shift,
168 Alt,
169 Super,
170 Space,
171 Up,
172 Down,
173 Left,
174 Right,
175
176 PageUp,
177 PageDown,
178 Insert,
179 Delete,
180 Home,
181 End,
182
183 LastKey,
185}