tony / oxwm

Branch: 8351ba0
Switch branches/tags
master
Aaron Bush Updated XF86 keys to camel case, and also added a whole lot more of 'em. 8351ba0 2025-12-15
391 lines · 14.9 KB Raw Blame History
1 #![allow(dead_code)]
2
3 pub type Keysym = u32;
4 pub const XK_ESCAPE: Keysym = 0xff1b;
5 pub const XK_RETURN: Keysym = 0xff0d;
6 pub const XK_SPACE: Keysym = 0x0020;
7 pub const XK_TAB: Keysym = 0xff09;
8 pub const XK_BACKSPACE: Keysym = 0xff08;
9 pub const XK_DELETE: Keysym = 0xffff;
10 pub const XK_F1: Keysym = 0xffbe;
11 pub const XK_F2: Keysym = 0xffbf;
12 pub const XK_F3: Keysym = 0xffc0;
13 pub const XK_F4: Keysym = 0xffc1;
14 pub const XK_F5: Keysym = 0xffc2;
15 pub const XK_F6: Keysym = 0xffc3;
16 pub const XK_F7: Keysym = 0xffc4;
17 pub const XK_F8: Keysym = 0xffc5;
18 pub const XK_F9: Keysym = 0xffc6;
19 pub const XK_F10: Keysym = 0xffc7;
20 pub const XK_F11: Keysym = 0xffc8;
21 pub const XK_F12: Keysym = 0xffc9;
22 pub const XK_A: Keysym = 0x0061;
23 pub const XK_B: Keysym = 0x0062;
24 pub const XK_C: Keysym = 0x0063;
25 pub const XK_D: Keysym = 0x0064;
26 pub const XK_E: Keysym = 0x0065;
27 pub const XK_F: Keysym = 0x0066;
28 pub const XK_G: Keysym = 0x0067;
29 pub const XK_H: Keysym = 0x0068;
30 pub const XK_I: Keysym = 0x0069;
31 pub const XK_J: Keysym = 0x006a;
32 pub const XK_K: Keysym = 0x006b;
33 pub const XK_L: Keysym = 0x006c;
34 pub const XK_M: Keysym = 0x006d;
35 pub const XK_N: Keysym = 0x006e;
36 pub const XK_O: Keysym = 0x006f;
37 pub const XK_P: Keysym = 0x0070;
38 pub const XK_Q: Keysym = 0x0071;
39 pub const XK_R: Keysym = 0x0072;
40 pub const XK_S: Keysym = 0x0073;
41 pub const XK_T: Keysym = 0x0074;
42 pub const XK_U: Keysym = 0x0075;
43 pub const XK_V: Keysym = 0x0076;
44 pub const XK_W: Keysym = 0x0077;
45 pub const XK_X: Keysym = 0x0078;
46 pub const XK_Y: Keysym = 0x0079;
47 pub const XK_Z: Keysym = 0x007a;
48 pub const XK_0: Keysym = 0x0030;
49 pub const XK_1: Keysym = 0x0031;
50 pub const XK_2: Keysym = 0x0032;
51 pub const XK_3: Keysym = 0x0033;
52 pub const XK_4: Keysym = 0x0034;
53 pub const XK_5: Keysym = 0x0035;
54 pub const XK_6: Keysym = 0x0036;
55 pub const XK_7: Keysym = 0x0037;
56 pub const XK_8: Keysym = 0x0038;
57 pub const XK_9: Keysym = 0x0039;
58 pub const XK_LEFT: Keysym = 0xff51;
59 pub const XK_UP: Keysym = 0xff52;
60 pub const XK_RIGHT: Keysym = 0xff53;
61 pub const XK_DOWN: Keysym = 0xff54;
62 pub const XK_HOME: Keysym = 0xff50;
63 pub const XK_END: Keysym = 0xff57;
64 pub const XK_PAGE_UP: Keysym = 0xff55;
65 pub const XK_PAGE_DOWN: Keysym = 0xff56;
66 pub const XK_INSERT: Keysym = 0xff63;
67 pub const XK_MINUS: Keysym = 0x002d;
68 pub const XK_EQUAL: Keysym = 0x003d;
69 pub const XK_LEFT_BRACKET: Keysym = 0x005b;
70 pub const XK_RIGHT_BRACKET: Keysym = 0x005d;
71 pub const XK_SEMICOLON: Keysym = 0x003b;
72 pub const XK_APOSTROPHE: Keysym = 0x0027;
73 pub const XK_GRAVE: Keysym = 0x0060;
74 pub const XK_BACKSLASH: Keysym = 0x005c;
75 pub const XK_COMMA: Keysym = 0x002c;
76 pub const XK_PERIOD: Keysym = 0x002e;
77 pub const XK_SLASH: Keysym = 0x002f;
78 pub const XK_PRINT: Keysym = 0xff61;
79
80 pub const XF86_AUDIO_MEDIA: Keysym = 0x1008ff32;
81 pub const XF86_AUDIO_NEXT: Keysym = 0x1008ff17;
82 pub const XF86_AUDIO_PAUSE: Keysym = 0x1008ff31;
83 pub const XF86_AUDIO_PLAY: Keysym = 0x1008ff14;
84 pub const XF86_AUDIO_PREV: Keysym = 0x1008ff16;
85 pub const XF86_AUDIO_RAISE_VOLUME: Keysym = 0x1008ff13;
86 pub const XF86_AUDIO_LOWER_VOLUME: Keysym = 0x1008ff11;
87 pub const XF86_AUDIO_MUTE: Keysym = 0x1008ff12;
88 pub const XF86_AUDIO_MIC_MUTE: Keysym = 0x1008ffb2;
89 pub const XF86_AUDIO_RECORD: Keysym = 0x1008ff1c;
90 pub const XF86_AUDIO_REWIND: Keysym = 0x1008ff3e;
91 pub const XF86_AUDIO_STOP: Keysym = 0x1008ff15;
92 pub const XF86_BACK: Keysym = 0x1008ff26;
93 pub const XF86_CALCULATOR: Keysym = 0x1008ff1d;
94 pub const XF86_CLOSE: Keysym = 0x1008ff56;
95 pub const XF86_COPY: Keysym = 0x1008ff57;
96 pub const XF86_CUT: Keysym = 0x1008ff58;
97 pub const XF86_DOS: Keysym = 0x1008ff5a;
98 pub const XF86_DISPLAY: Keysym = 0x1008ff59;
99 pub const XF86_DOCUMENTS: Keysym = 0x1008ff5b;
100 pub const XF86_EJECT: Keysym = 0x1008ff2c;
101 pub const XF86_EXPLORER: Keysym = 0x1008ff5d;
102 pub const XF86_FAVORITES: Keysym = 0x1008ff30;
103 pub const XF86_FINANCE: Keysym = 0x1008ff3c;
104 pub const XF86_FORWARD: Keysym = 0x1008ff27;
105 pub const XF86_GAME: Keysym = 0x1008ff5e;
106 pub const XF86_GO: Keysym = 0x1008ff5f;
107 pub const XF86_HOME_PAGE: Keysym = 0x1008ff18;
108 pub const XF86_MAIL: Keysym = 0x1008ff19;
109 pub const XF86_MAIL_FORWARD: Keysym = 0x1008ff90;
110 pub const XF86_MENU_KB: Keysym = 0x1008ff65;
111 pub const XF86_MESSENGER: Keysym = 0x1008ff8e;
112 pub const XF86_MON_BRIGHTNESS_UP: Keysym = 0x1008ff02;
113 pub const XF86_MON_BRIGHTNESS_DOWN: Keysym = 0x1008ff03;
114 pub const XF86_MY_COMPUTER: Keysym = 0x1008ff33;
115 pub const XF86_NEW: Keysym = 0x1008ff68;
116 pub const XF86_NEXT_VMODE: Keysym = 0x1008fe22;
117 pub const XF86_PREV_VMODE: Keysym = 0x1008fe23;
118 pub const XF86_OPEN: Keysym = 0x1008ff6b;
119 pub const XF86_PASTE: Keysym = 0x1008ff6d;
120 pub const XF86_PHONE: Keysym = 0x1008ff6e;
121 pub const XF86_POWER_OFF: Keysym = 0x1008ff2a;
122 pub const XF86_RELOAD: Keysym = 0x1008ff73;
123 pub const XF86_REPLY: Keysym = 0x1008ff72;
124 pub const XF86_ROTATE_WINDOWS: Keysym = 0x1008ff74;
125 pub const XF86_SAVE: Keysym = 0x1008ff77;
126 pub const XF86_SCREEN_SAVER: Keysym = 0x1008ff2d;
127 pub const XF86_SCROLL_DOWN: Keysym = 0x1008ff79;
128 pub const XF86_SCROLL_UP: Keysym = 0x1008ff78;
129 pub const XF86_SEARCH: Keysym = 0x1008ff1b;
130 pub const XF86_SEND: Keysym = 0x1008ff7b;
131 pub const XF86_SHOP: Keysym = 0x1008ff36;
132 pub const XF86_SLEEP: Keysym = 0x1008ff2f;
133 pub const XF86_TASK_PANE: Keysym = 0x1008ff7f;
134 pub const XF86_TOOLS: Keysym = 0x1008ff81;
135 pub const XF86_WWW: Keysym = 0x1008ff2e;
136 pub const XF86_WAKE_UP: Keysym = 0x1008ff2b;
137 pub const XF86_WEBCAM: Keysym = 0x1008ff8f;
138 pub const XF86_XFER: Keysym = 0x1008ff8a;
139
140 pub fn keysym_from_str(s: &str) -> Option<Keysym> {
141 match s {
142 "Return" => Some(XK_RETURN),
143 "Escape" => Some(XK_ESCAPE),
144 "Space" => Some(XK_SPACE),
145 "Tab" => Some(XK_TAB),
146 "Backspace" => Some(XK_BACKSPACE),
147 "Delete" => Some(XK_DELETE),
148 "F1" => Some(XK_F1),
149 "F2" => Some(XK_F2),
150 "F3" => Some(XK_F3),
151 "F4" => Some(XK_F4),
152 "F5" => Some(XK_F5),
153 "F6" => Some(XK_F6),
154 "F7" => Some(XK_F7),
155 "F8" => Some(XK_F8),
156 "F9" => Some(XK_F9),
157 "F10" => Some(XK_F10),
158 "F11" => Some(XK_F11),
159 "F12" => Some(XK_F12),
160 "A" => Some(XK_A),
161 "B" => Some(XK_B),
162 "C" => Some(XK_C),
163 "D" => Some(XK_D),
164 "E" => Some(XK_E),
165 "F" => Some(XK_F),
166 "G" => Some(XK_G),
167 "H" => Some(XK_H),
168 "I" => Some(XK_I),
169 "J" => Some(XK_J),
170 "K" => Some(XK_K),
171 "L" => Some(XK_L),
172 "M" => Some(XK_M),
173 "N" => Some(XK_N),
174 "O" => Some(XK_O),
175 "P" => Some(XK_P),
176 "Q" => Some(XK_Q),
177 "R" => Some(XK_R),
178 "S" => Some(XK_S),
179 "T" => Some(XK_T),
180 "U" => Some(XK_U),
181 "V" => Some(XK_V),
182 "W" => Some(XK_W),
183 "X" => Some(XK_X),
184 "Y" => Some(XK_Y),
185 "Z" => Some(XK_Z),
186 "0" => Some(XK_0),
187 "1" => Some(XK_1),
188 "2" => Some(XK_2),
189 "3" => Some(XK_3),
190 "4" => Some(XK_4),
191 "5" => Some(XK_5),
192 "6" => Some(XK_6),
193 "7" => Some(XK_7),
194 "8" => Some(XK_8),
195 "9" => Some(XK_9),
196 "Left" => Some(XK_LEFT),
197 "Right" => Some(XK_RIGHT),
198 "Up" => Some(XK_UP),
199 "Down" => Some(XK_DOWN),
200 "Home" => Some(XK_HOME),
201 "End" => Some(XK_END),
202 "PageUp" => Some(XK_PAGE_UP),
203 "PageDown" => Some(XK_PAGE_DOWN),
204 "Insert" => Some(XK_INSERT),
205 "Minus" => Some(XK_MINUS),
206 "Equal" => Some(XK_EQUAL),
207 "BracketLeft" => Some(XK_LEFT_BRACKET),
208 "BracketRight" => Some(XK_RIGHT_BRACKET),
209 "Semicolon" => Some(XK_SEMICOLON),
210 "Apostrophe" => Some(XK_APOSTROPHE),
211 "Grave" => Some(XK_GRAVE),
212 "Backslash" => Some(XK_BACKSLASH),
213 "Comma" => Some(XK_COMMA),
214 "Period" => Some(XK_PERIOD),
215 "Slash" => Some(XK_SLASH),
216 "Print" => Some(XK_PRINT),
217
218 "XF86AudioMedia" => Some(XF86_AUDIO_MEDIA),
219 "XF86AudioNext" => Some(XF86_AUDIO_NEXT),
220 "XF86AudioPause" => Some(XF86_AUDIO_PAUSE),
221 "XF86AudioPlay" => Some(XF86_AUDIO_PLAY),
222 "XF86AudioPrev" => Some(XF86_AUDIO_PREV),
223 "XF86AudioRaiseVolume" => Some(XF86_AUDIO_RAISE_VOLUME),
224 "XF86AudioLowerVolume" => Some(XF86_AUDIO_LOWER_VOLUME),
225 "XF86AudioMute" => Some(XF86_AUDIO_MUTE),
226 "XF86AudioMicMute" => Some(XF86_AUDIO_MIC_MUTE),
227 "XF86AudioRecord" => Some(XF86_AUDIO_RECORD),
228 "XF86AudioRewind" => Some(XF86_AUDIO_REWIND),
229 "XF86AudioStop" => Some(XF86_AUDIO_STOP),
230 "XF86Back" => Some(XF86_BACK),
231 "XF86Calculator" => Some(XF86_CALCULATOR),
232 "XF86Close" => Some(XF86_CLOSE),
233 "XF86Copy" => Some(XF86_COPY),
234 "XF86Cut" => Some(XF86_CUT),
235 "XF86DOS" => Some(XF86_DOS),
236 "XF86Display" => Some(XF86_DISPLAY),
237 "XF86Documents" => Some(XF86_DOCUMENTS),
238 "XF86Eject" => Some(XF86_EJECT),
239 "XF86Explorer" => Some(XF86_EXPLORER),
240 "XF86Favorites" => Some(XF86_FAVORITES),
241 "XF86Finance" => Some(XF86_FINANCE),
242 "XF86Forward" => Some(XF86_FORWARD),
243 "XF86Game" => Some(XF86_GAME),
244 "XF86Go" => Some(XF86_GO),
245 "XF86HomePage" => Some(XF86_HOME_PAGE),
246 "XF86Mail" => Some(XF86_MAIL),
247 "XF86MailForward" => Some(XF86_MAIL_FORWARD),
248 "XF86MenuKB" => Some(XF86_MENU_KB),
249 "XF86Messenger" => Some(XF86_MESSENGER),
250 "XF86MonBrightnessUp" => Some(XF86_MON_BRIGHTNESS_UP ),
251 "XF86MonBrightnessDown" => Some(XF86_MON_BRIGHTNESS_DOWN),
252 "XF86MyComputer" => Some(XF86_MY_COMPUTER),
253 "XF86New" => Some(XF86_NEW),
254 "XF86Next_VMode" => Some(XF86_NEXT_VMODE),
255 "XF86Prev_VMode" => Some(XF86_PREV_VMODE),
256 "XF86Open" => Some(XF86_OPEN),
257 "XF86Paste" => Some(XF86_PASTE),
258 "XF86Phone" => Some(XF86_PHONE),
259 "XF86PowerOff" => Some(XF86_POWER_OFF),
260 "XF86Reload" => Some(XF86_RELOAD),
261 "XF86Reply" => Some(XF86_REPLY),
262 "XF86RotateWindows" => Some(XF86_ROTATE_WINDOWS),
263 "XF86Save" => Some(XF86_SAVE),
264 "XF86ScreenSaver" => Some(XF86_SCREEN_SAVER),
265 "XF86ScrollDown" => Some(XF86_SCROLL_DOWN),
266 "XF86ScrollUp" => Some(XF86_SCROLL_UP),
267 "XF86Search" => Some(XF86_SEARCH),
268 "XF86Send" => Some(XF86_SEND),
269 "XF86Shop" => Some(XF86_SHOP),
270 "XF86Sleep" => Some(XF86_SLEEP),
271 "XF86TaskPane" => Some(XF86_TASK_PANE),
272 "XF86Tools" => Some(XF86_TOOLS),
273 "XF86WWW" => Some(XF86_WWW),
274 "XF86WakeUp" => Some(XF86_WAKE_UP),
275 "XF86WebCam" => Some(XF86_WEBCAM),
276 "XF86Xfer" => Some(XF86_XFER),
277 _ => None,
278 }
279 }
280
281 pub fn format_keysym(keysym: Keysym) -> String {
282 match keysym {
283 XK_RETURN => "Return".to_string(),
284 XK_ESCAPE => "Esc".to_string(),
285 XK_SPACE => "Space".to_string(),
286 XK_TAB => "Tab".to_string(),
287 XK_BACKSPACE => "Backspace".to_string(),
288 XK_DELETE => "Del".to_string(),
289 XK_LEFT => "Left".to_string(),
290 XK_RIGHT => "Right".to_string(),
291 XK_UP => "Up".to_string(),
292 XK_DOWN => "Down".to_string(),
293 XK_HOME => "Home".to_string(),
294 XK_END => "End".to_string(),
295 XK_PAGE_UP => "PgUp".to_string(),
296 XK_PAGE_DOWN => "PgDn".to_string(),
297 XK_INSERT => "Ins".to_string(),
298 XK_F1 => "F1".to_string(),
299 XK_F2 => "F2".to_string(),
300 XK_F3 => "F3".to_string(),
301 XK_F4 => "F4".to_string(),
302 XK_F5 => "F5".to_string(),
303 XK_F6 => "F6".to_string(),
304 XK_F7 => "F7".to_string(),
305 XK_F8 => "F8".to_string(),
306 XK_F9 => "F9".to_string(),
307 XK_F10 => "F10".to_string(),
308 XK_F11 => "F11".to_string(),
309 XK_F12 => "F12".to_string(),
310 XK_SLASH => "/".to_string(),
311 XK_COMMA => ",".to_string(),
312 XK_PERIOD => ".".to_string(),
313 XK_MINUS => "-".to_string(),
314 XK_EQUAL => "=".to_string(),
315 XK_GRAVE => "`".to_string(),
316 XK_LEFT_BRACKET => "[".to_string(),
317 XK_RIGHT_BRACKET => "]".to_string(),
318 XK_SEMICOLON => ";".to_string(),
319 XK_APOSTROPHE => "'".to_string(),
320 XK_BACKSLASH => "\\".to_string(),
321 XK_PRINT => "Print".to_string(),
322 XF86_AUDIO_MEDIA => "Media".to_string(),
323 XF86_AUDIO_NEXT => "Next".to_string(),
324 XF86_AUDIO_PAUSE => "Pause".to_string(),
325 XF86_AUDIO_PLAY => "Play".to_string(),
326 XF86_AUDIO_PREV => "Prev".to_string(),
327 XF86_AUDIO_RAISE_VOLUME => "Vol+".to_string(),
328 XF86_AUDIO_LOWER_VOLUME => "Vol-".to_string(),
329 XF86_AUDIO_MUTE => "Mute".to_string(),
330 XF86_AUDIO_MIC_MUTE => "MicMute".to_string(),
331 XF86_AUDIO_RECORD => "Record".to_string(),
332 XF86_AUDIO_REWIND => "Rewind".to_string(),
333 XF86_AUDIO_STOP => "Stop".to_string(),
334 XF86_BACK => "Back".to_string(),
335 XF86_CALCULATOR => "Calculator".to_string(),
336 XF86_CLOSE => "Close".to_string(),
337 XF86_COPY => "Copy".to_string(),
338 XF86_CUT => "Cut".to_string(),
339 XF86_DOS => "DOS".to_string(),
340 XF86_DISPLAY => "Display".to_string(),
341 XF86_DOCUMENTS => "Documents".to_string(),
342 XF86_EJECT => "Eject".to_string(),
343 XF86_EXPLORER => "Explorer".to_string(),
344 XF86_FAVORITES => "Favorites".to_string(),
345 XF86_FINANCE => "Finance".to_string(),
346 XF86_FORWARD => "Forward".to_string(),
347 XF86_GAME => "Game".to_string(),
348 XF86_GO => "Go".to_string(),
349 XF86_HOME_PAGE => "HomePage".to_string(),
350 XF86_MAIL => "Mail".to_string(),
351 XF86_MAIL_FORWARD => "MailForward".to_string(),
352 XF86_MENU_KB => "MenuKB".to_string(),
353 XF86_MESSENGER => "Messenger".to_string(),
354 XF86_MON_BRIGHTNESS_UP => "Bright+".to_string(),
355 XF86_MON_BRIGHTNESS_DOWN => "Bright-".to_string(),
356 XF86_MY_COMPUTER => "MyComputer".to_string(),
357 XF86_NEW => "New".to_string(),
358 XF86_NEXT_VMODE => "NextVMode".to_string(),
359 XF86_PREV_VMODE => "PrevVMode".to_string(),
360 XF86_OPEN => "Open".to_string(),
361 XF86_PASTE => "Paste".to_string(),
362 XF86_PHONE => "Phone".to_string(),
363 XF86_POWER_OFF => "PowerOff".to_string(),
364 XF86_RELOAD => "Reload".to_string(),
365 XF86_REPLY => "Reply".to_string(),
366 XF86_ROTATE_WINDOWS => "RotateWindows".to_string(),
367 XF86_SAVE => "Save".to_string(),
368 XF86_SCREEN_SAVER => "ScreenSaver".to_string(),
369 XF86_SCROLL_DOWN => "ScrollDown".to_string(),
370 XF86_SCROLL_UP => "ScrollUp".to_string(),
371 XF86_SEARCH => "Search".to_string(),
372 XF86_SEND => "Send".to_string(),
373 XF86_SHOP => "Shop".to_string(),
374 XF86_SLEEP => "Sleep".to_string(),
375 XF86_TASK_PANE => "TaskPane".to_string(),
376 XF86_TOOLS => "Tools".to_string(),
377 XF86_WWW => "WWW".to_string(),
378 XF86_WAKE_UP => "WakeUp".to_string(),
379 XF86_WEBCAM => "WebCam".to_string(),
380 XF86_XFER => "Xfer".to_string(),
381 XK_A..=XK_Z => {
382 let ch = (keysym - XK_A + b'A' as u32) as u8 as char;
383 ch.to_string()
384 }
385 XK_0..=XK_9 => {
386 let ch = (keysym - XK_0 + b'0' as u32) as u8 as char;
387 ch.to_string()
388 }
389 _ => format!("0x{:x}", keysym),
390 }
391 }