tony / oxwm

Branch: aee3def
Switch branches/tags
master
Zif Added the top row for azerty layout keyboard 2b7bda2 2025-12-14
259 lines · 8.8 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 XK_AMPERSAND: Keysym = 0x26;
81 pub const XK_AGRAVE: Keysym = 0xe0;
82 pub const XK_CCEDILLA: Keysym = 0xe7;
83 pub const XK_EGRAVE: Keysym = 0xe8;
84 pub const XK_EACUTE: Keysym = 0xe9;
85 pub const XK_PARENLEFT: Keysym = 0x28;
86 pub const XK_PARENRIGHT: Keysym = 0x29;
87 pub const XK_QUOTEDBL: Keysym = 0x22;
88 pub const XK_UNDERSCORE: Keysym = 0x5f;
89 pub const XK_HYPHEN: Keysym = 0xad;
90
91 pub const XF86_AUDIO_RAISE_VOLUME: Keysym = 0x1008ff13;
92 pub const XF86_AUDIO_LOWER_VOLUME: Keysym = 0x1008ff11;
93 pub const XF86_AUDIO_MUTE: Keysym = 0x1008ff12;
94 pub const XF86_MON_BRIGHTNESS_UP: Keysym = 0x1008ff02;
95 pub const XF86_MON_BRIGHTNESS_DOWN: Keysym = 0x1008ff03;
96
97 pub fn keysym_from_str(s: &str) -> Option<Keysym> {
98 match s {
99 "Return" => Some(XK_RETURN),
100 "Escape" => Some(XK_ESCAPE),
101 "Space" => Some(XK_SPACE),
102 "Tab" => Some(XK_TAB),
103 "Backspace" => Some(XK_BACKSPACE),
104 "Delete" => Some(XK_DELETE),
105 "F1" => Some(XK_F1),
106 "F2" => Some(XK_F2),
107 "F3" => Some(XK_F3),
108 "F4" => Some(XK_F4),
109 "F5" => Some(XK_F5),
110 "F6" => Some(XK_F6),
111 "F7" => Some(XK_F7),
112 "F8" => Some(XK_F8),
113 "F9" => Some(XK_F9),
114 "F10" => Some(XK_F10),
115 "F11" => Some(XK_F11),
116 "F12" => Some(XK_F12),
117 "A" => Some(XK_A),
118 "B" => Some(XK_B),
119 "C" => Some(XK_C),
120 "D" => Some(XK_D),
121 "E" => Some(XK_E),
122 "F" => Some(XK_F),
123 "G" => Some(XK_G),
124 "H" => Some(XK_H),
125 "I" => Some(XK_I),
126 "J" => Some(XK_J),
127 "K" => Some(XK_K),
128 "L" => Some(XK_L),
129 "M" => Some(XK_M),
130 "N" => Some(XK_N),
131 "O" => Some(XK_O),
132 "P" => Some(XK_P),
133 "Q" => Some(XK_Q),
134 "R" => Some(XK_R),
135 "S" => Some(XK_S),
136 "T" => Some(XK_T),
137 "U" => Some(XK_U),
138 "V" => Some(XK_V),
139 "W" => Some(XK_W),
140 "X" => Some(XK_X),
141 "Y" => Some(XK_Y),
142 "Z" => Some(XK_Z),
143 "0" => Some(XK_0),
144 "1" => Some(XK_1),
145 "2" => Some(XK_2),
146 "3" => Some(XK_3),
147 "4" => Some(XK_4),
148 "5" => Some(XK_5),
149 "6" => Some(XK_6),
150 "7" => Some(XK_7),
151 "8" => Some(XK_8),
152 "9" => Some(XK_9),
153 "Left" => Some(XK_LEFT),
154 "Right" => Some(XK_RIGHT),
155 "Up" => Some(XK_UP),
156 "Down" => Some(XK_DOWN),
157 "Home" => Some(XK_HOME),
158 "End" => Some(XK_END),
159 "PageUp" => Some(XK_PAGE_UP),
160 "PageDown" => Some(XK_PAGE_DOWN),
161 "Insert" => Some(XK_INSERT),
162 "Minus" => Some(XK_MINUS),
163 "Equal" => Some(XK_EQUAL),
164 "BracketLeft" => Some(XK_LEFT_BRACKET),
165 "BracketRight" => Some(XK_RIGHT_BRACKET),
166 "Semicolon" => Some(XK_SEMICOLON),
167 "Apostrophe" => Some(XK_APOSTROPHE),
168 "Grave" => Some(XK_GRAVE),
169 "Backslash" => Some(XK_BACKSLASH),
170 "Comma" => Some(XK_COMMA),
171 "Period" => Some(XK_PERIOD),
172 "Slash" => Some(XK_SLASH),
173 "Print" => Some(XK_PRINT),
174 "Ampersand" => Some(XK_AMPERSAND),
175 "Agrave" => Some(XK_AGRAVE),
176 "Ccedilla" => Some(XK_CCEDILLA),
177 "Egrave" => Some(XK_EGRAVE),
178 "Eacute" => Some(XK_EACUTE),
179 "ParenLeft" => Some(XK_PARENLEFT),
180 "ParenRight" => Some(XK_PARENRIGHT),
181 "QuoteDouble" => Some(XK_QUOTEDBL),
182 "Underscore" => Some(XK_UNDERSCORE),
183 "Hyphen" => Some(XK_HYPHEN),
184 "AudioRaiseVolume" => Some(XF86_AUDIO_RAISE_VOLUME),
185 "AudioLowerVolume" => Some(XF86_AUDIO_LOWER_VOLUME),
186 "AudioMute" => Some(XF86_AUDIO_MUTE),
187 "MonBrightnessUp" => Some(XF86_MON_BRIGHTNESS_UP),
188 "MonBrightnessDown" => Some(XF86_MON_BRIGHTNESS_DOWN),
189 _ => None,
190 }
191 }
192
193 pub fn format_keysym(keysym: Keysym) -> String {
194 match keysym {
195 XK_RETURN => "Return".to_string(),
196 XK_ESCAPE => "Esc".to_string(),
197 XK_SPACE => "Space".to_string(),
198 XK_TAB => "Tab".to_string(),
199 XK_BACKSPACE => "Backspace".to_string(),
200 XK_DELETE => "Del".to_string(),
201 XK_LEFT => "Left".to_string(),
202 XK_RIGHT => "Right".to_string(),
203 XK_UP => "Up".to_string(),
204 XK_DOWN => "Down".to_string(),
205 XK_HOME => "Home".to_string(),
206 XK_END => "End".to_string(),
207 XK_PAGE_UP => "PgUp".to_string(),
208 XK_PAGE_DOWN => "PgDn".to_string(),
209 XK_INSERT => "Ins".to_string(),
210 XK_F1 => "F1".to_string(),
211 XK_F2 => "F2".to_string(),
212 XK_F3 => "F3".to_string(),
213 XK_F4 => "F4".to_string(),
214 XK_F5 => "F5".to_string(),
215 XK_F6 => "F6".to_string(),
216 XK_F7 => "F7".to_string(),
217 XK_F8 => "F8".to_string(),
218 XK_F9 => "F9".to_string(),
219 XK_F10 => "F10".to_string(),
220 XK_F11 => "F11".to_string(),
221 XK_F12 => "F12".to_string(),
222 XK_SLASH => "/".to_string(),
223 XK_COMMA => ",".to_string(),
224 XK_PERIOD => ".".to_string(),
225 XK_MINUS => "-".to_string(),
226 XK_EQUAL => "=".to_string(),
227 XK_GRAVE => "`".to_string(),
228 XK_LEFT_BRACKET => "[".to_string(),
229 XK_RIGHT_BRACKET => "]".to_string(),
230 XK_SEMICOLON => ";".to_string(),
231 XK_APOSTROPHE => "'".to_string(),
232 XK_BACKSLASH => "\\".to_string(),
233 XK_PRINT => "Print".to_string(),
234 XK_AMPERSAND => "&".to_string(),
235 XK_AGRAVE => "à".to_string(),
236 XK_CCEDILLA => "ç".to_string(),
237 XK_EGRAVE => "è".to_string(),
238 XK_EACUTE => "é".to_string(),
239 XK_PARENLEFT => "(".to_string(),
240 XK_PARENRIGHT => ")".to_string(),
241 XK_QUOTEDBL => "\"".to_string(),
242 XK_UNDERSCORE => "_".to_string(),
243 XK_HYPHEN => "-".to_string(),
244 XF86_AUDIO_RAISE_VOLUME => "Vol+".to_string(),
245 XF86_AUDIO_LOWER_VOLUME => "Vol-".to_string(),
246 XF86_AUDIO_MUTE => "Mute".to_string(),
247 XF86_MON_BRIGHTNESS_UP => "Bright+".to_string(),
248 XF86_MON_BRIGHTNESS_DOWN => "Bright-".to_string(),
249 XK_A..=XK_Z => {
250 let ch = (keysym - XK_A + b'A' as u32) as u8 as char;
251 ch.to_string()
252 }
253 XK_0..=XK_9 => {
254 let ch = (keysym - XK_0 + b'0' as u32) as u8 as char;
255 ch.to_string()
256 }
257 _ => format!("0x{:x}", keysym),
258 }
259 }