summaryrefslogtreecommitdiff
path: root/noncore/apps/keyz-cfg/zkbnames.cpp
Unidiff
Diffstat (limited to 'noncore/apps/keyz-cfg/zkbnames.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/keyz-cfg/zkbnames.cpp450
1 files changed, 450 insertions, 0 deletions
diff --git a/noncore/apps/keyz-cfg/zkbnames.cpp b/noncore/apps/keyz-cfg/zkbnames.cpp
new file mode 100644
index 0000000..fec3a2e
--- a/dev/null
+++ b/noncore/apps/keyz-cfg/zkbnames.cpp
@@ -0,0 +1,450 @@
1#ifdef USE_ZKB_NAMES
2
3#include <qmap.h>
4#include <qstring.h>
5
6#include "zkbnames.h"
7
8QString Null_String((const char*) 0);
9
10// Implementation of KeyNames
11static struct {
12 int key;
13 char *name;
14} Key_Names[] = {
15 { 32, "Space" },
16 { 39, "Apostrophe" },
17 { 44, "Comma" },
18 { 46, "Period" },
19 { 47, "Slash" },
20 { 65, "A" },
21 { 66, "B" },
22 { 67, "C" },
23 { 68, "D" },
24 { 69, "E" },
25 { 70, "F" },
26 { 71, "G" },
27 { 72, "H" },
28 { 73, "I" },
29 { 74, "J" },
30 { 75, "K" },
31 { 76, "L" },
32 { 77, "M" },
33 { 78, "N" },
34 { 79, "O" },
35 { 80, "P" },
36 { 81, "Q" },
37 { 82, "R" },
38 { 83, "S" },
39 { 84, "T" },
40 { 85, "U" },
41 { 86, "V" },
42 { 87, "W" },
43 { 88, "X" },
44 { 89, "Y" },
45 { 90, "Z" },
46 { 4096, "Cancel" },
47 { 4097, "Tab" },
48 { 4099, "Backspace" },
49 { 4100, "Enter" },
50 { 4114, "Left" },
51 { 4115, "Up" },
52 { 4116, "Right" },
53 { 4117, "Down" },
54 { 4128, "Left Shift" },
55 { 4130, "Right Shift" },
56 { 4152, "Calendar" },
57 { 4153, "Addressbook" },
58 { 4154, "Menu" },
59 { 4155, "Home" },
60 { 4156, "Mail" },
61 { 4165, "Fn" },
62 { 4173, "Middle" },
63 { 4176, "OK" },
64 { 4177, "Off" },
65 { 4178, "Light" },
66 { 0, 0 }
67};
68
69static QMap<QString, int> kn_map;
70static QMap<int, QString> kn_rmap;
71
72void init_kn_maps() {
73 int i = 0;
74 while (Key_Names[i].name != 0) {
75 int key = Key_Names[i].key;
76 QString name(Key_Names[i].name);
77
78 kn_map.insert(name, key);
79 kn_rmap.insert(key, name);
80 i++;
81 }
82}
83
84int KeyNames::find(const QString& key) {
85 if (kn_map.isEmpty()) {
86 init_kn_maps();
87 }
88
89 QMap<QString, int>::Iterator it = kn_map.find(key);
90 if (it == kn_map.end()) {
91 return -1;
92 } else {
93 return it.data();
94 }
95}
96
97const QString& KeyNames::find(int k) {
98 if (kn_map.isEmpty()) {
99 init_kn_maps();
100 }
101
102 QMap<int, QString>::Iterator it = kn_rmap.find(k);
103 if (it == kn_rmap.end()) {
104 return Null_String;
105 } else {
106 return it.data();
107 }
108}
109
110// Implementation of ModifierNames
111struct {
112 int value;
113 char* name;
114} Modifier_Names[] = {
115 { 8, "Shift" },
116 { 16, "Control" },
117 { 32, "Alt" },
118 { 0x4000, "Keypad" },
119 { 0, 0 }
120};
121
122static QMap<QString, int> mn_map;
123static QMap<int, QString> mn_rmap;
124
125void init_mn_maps() {
126 int i = 0;
127 while (Modifier_Names[i].name != 0) {
128 int value = Modifier_Names[i].value;
129 QString name(Modifier_Names[i].name);
130
131 mn_map.insert(name, value);
132 mn_rmap.insert(value, name);
133 i++;
134 }
135}
136
137int ModifierNames::find(const QString& key) {
138 if (mn_map.isEmpty()) {
139 init_mn_maps();
140 }
141
142 QMap<QString, int>::Iterator it = mn_map.find(key);
143 if (it == mn_map.end()) {
144 return -1;
145 } else {
146 return it.data();
147 }
148}
149
150const QString& ModifierNames::find(int k) {
151 if (mn_map.isEmpty()) {
152 init_mn_maps();
153 }
154
155 QMap<int, QString>::Iterator it = mn_rmap.find(k);
156 if (it == mn_rmap.end()) {
157 return Null_String;
158 } else {
159 return it.data();
160 }
161}
162
163// Implementation of KeycodeNames
164
165struct {
166 char* name;
167 int keycode;
168} Keycode_Names[] = {
169 { "Escape", 0x1000 },
170 { "Tab", 0x1001 },
171 { "Backtab", 0x1002 },
172 { "Backspace", 0x1003 },
173 { "BackSpace", 0x1003 },
174 { "Return", 0x1004 },
175 { "Enter", 0x1005 },
176 { "Insert", 0x1006 },
177 { "Delete", 0x1007 },
178 { "Pause", 0x1008 },
179 { "Print", 0x1009 },
180 { "SysReq", 0x100a },
181 { "Home", 0x1010 },
182 { "End", 0x1011 },
183 { "Left", 0x1012 },
184 { "Up", 0x1013 },
185 { "Right", 0x1014 },
186 { "Down", 0x1015 },
187 { "Prior", 0x1016 },
188 { "PageUp", 0x1016 },
189 { "Next", 0x1017 },
190 { "PageDown", 0x1017 },
191 { "Shift", 0x1020 },
192 { "Control", 0x1021 },
193 { "Meta", 0x1022 },
194 { "Alt", 0x1023 },
195 { "CapsLock", 0x1024 },
196 { "NumLock", 0x1025 },
197 { "ScrollLock", 0x1026 },
198 { "F1", 0x1030 },
199 { "F2", 0x1031 },
200 { "F3", 0x1032 },
201 { "F4", 0x1033 },
202 { "F5", 0x1034 },
203 { "F6", 0x1035 },
204 { "F7", 0x1036 },
205 { "F8", 0x1037 },
206 { "F9", 0x1038 },
207 { "F10", 0x1039 },
208 { "F11", 0x103a },
209 { "F12", 0x103b },
210 { "F13", 0x103c },
211 { "F14", 0x103d },
212 { "F15", 0x103e },
213 { "F16", 0x103f },
214 { "F17", 0x1040 },
215 { "F18", 0x1041 },
216 { "F19", 0x1042 },
217 { "F20", 0x1043 },
218 { "F21", 0x1044 },
219 { "F22", 0x1045 },
220 { "F23", 0x1046 },
221 { "F24", 0x1047 },
222 { "F25", 0x1048 },
223 { "F26", 0x1049 },
224 { "F27", 0x104a },
225 { "F28", 0x104b },
226 { "F29", 0x104c },
227 { "F30", 0x104d },
228 { "F31", 0x104e },
229 { "F32", 0x104f },
230 { "F33", 0x1050 },
231 { "F34", 0x1051 },
232 { "F35", 0x1052 },
233 { "Super_L", 0x1053 },
234 { "Super_R", 0x1054 },
235 { "Menu", 0x1055 },
236 { "Hyper_L", 0x1056 },
237 { "Hyper_R", 0x1057 },
238 { "Help", 0x1058 },
239 { "Space", 0x20 },
240 { "Any", 0x20 },
241 { "Exclam", 0x21 },
242 { "QuoteDbl", 0x22 },
243 { "NumberSign", 0x23 },
244 { "Dollar", 0x24 },
245 { "Percent", 0x25 },
246 { "Ampersand", 0x26 },
247 { "Apostrophe", 0x27 },
248 { "ParenLeft", 0x28 },
249 { "ParenRight", 0x29 },
250 { "Asterisk", 0x2a },
251 { "Plus", 0x2b },
252 { "Comma", 0x2c },
253 { "Minus", 0x2d },
254 { "Period", 0x2e },
255 { "Slash", 0x2f },
256 { "0", 0x30 },
257 { "1", 0x31 },
258 { "2", 0x32 },
259 { "3", 0x33 },
260 { "4", 0x34 },
261 { "5", 0x35 },
262 { "6", 0x36 },
263 { "7", 0x37 },
264 { "8", 0x38 },
265 { "9", 0x39 },
266 { "Colon", 0x3a },
267 { "Semicolon", 0x3b },
268 { "Less", 0x3c },
269 { "Equal", 0x3d },
270 { "Greater", 0x3e },
271 { "Question", 0x3f },
272 { "At", 0x40 },
273 { "A", 0x41 },
274 { "B", 0x42 },
275 { "C", 0x43 },
276 { "D", 0x44 },
277 { "E", 0x45 },
278 { "F", 0x46 },
279 { "G", 0x47 },
280 { "H", 0x48 },
281 { "I", 0x49 },
282 { "J", 0x4a },
283 { "K", 0x4b },
284 { "L", 0x4c },
285 { "M", 0x4d },
286 { "N", 0x4e },
287 { "O", 0x4f },
288 { "P", 0x50 },
289 { "Q", 0x51 },
290 { "R", 0x52 },
291 { "S", 0x53 },
292 { "T", 0x54 },
293 { "U", 0x55 },
294 { "V", 0x56 },
295 { "W", 0x57 },
296 { "X", 0x58 },
297 { "Y", 0x59 },
298 { "Z", 0x5a },
299 { "BracketLeft", 0x5b },
300 { "Backslash", 0x5c },
301 { "BracketRight", 0x5d },
302 { "AsciiCircum", 0x5e },
303 { "Underscore", 0x5f },
304 { "QuoteLeft", 0x60 },
305 { "BraceLeft", 0x7b },
306 { "Bar", 0x7c },
307 { "BraceRight", 0x7d },
308 { "AsciiTilde", 0x7e },
309 { "nobreakspace", 0x0a0 },
310 { "exclamdown", 0x0a1 },
311 { "cent", 0x0a2 },
312 { "sterling", 0x0a3 },
313 { "currency", 0x0a4 },
314 { "yen", 0x0a5 },
315 { "brokenbar", 0x0a6 },
316 { "section", 0x0a7 },
317 { "diaeresis", 0x0a8 },
318 { "copyright", 0x0a9 },
319 { "ordfeminine", 0x0aa },
320 { "guillemotleft", 0x0ab },
321 { "notsign", 0x0ac },
322 { "hyphen", 0x0ad },
323 { "registered", 0x0ae },
324 { "macron", 0x0af },
325 { "degree", 0x0b0 },
326 { "plusminus", 0x0b1 },
327 { "twosuperior", 0x0b2 },
328 { "threesuperior", 0x0b3 },
329 { "acute", 0x0b4 },
330 { "mu", 0x0b5 },
331 { "paragraph", 0x0b6 },
332 { "periodcentered", 0x0b7 },
333 { "cedilla", 0x0b8 },
334 { "onesuperior", 0x0b9 },
335 { "masculine", 0x0ba },
336 { "guillemotright", 0x0bb },
337 { "onequarter", 0x0bc },
338 { "onehalf", 0x0bd },
339 { "threequarters", 0x0be },
340 { "questiondown", 0x0bf },
341 { "Agrave", 0x0c0 },
342 { "Aacute", 0x0c1 },
343 { "Acircumflex", 0x0c2 },
344 { "Atilde", 0x0c3 },
345 { "Adiaeresis", 0x0c4 },
346 { "Aring", 0x0c5 },
347 { "AE", 0x0c6 },
348 { "Ccedilla", 0x0c7 },
349 { "Egrave", 0x0c8 },
350 { "Eacute", 0x0c9 },
351 { "Ecircumflex", 0x0ca },
352 { "Ediaeresis", 0x0cb },
353 { "Igrave", 0x0cc },
354 { "Iacute", 0x0cd },
355 { "Icircumflex", 0x0ce },
356 { "Idiaeresis", 0x0cf },
357 { "ETH", 0x0d0 },
358 { "Ntilde", 0x0d1 },
359 { "Ograve", 0x0d2 },
360 { "Oacute", 0x0d3 },
361 { "Ocircumflex", 0x0d4 },
362 { "Otilde", 0x0d5 },
363 { "Odiaeresis", 0x0d6 },
364 { "multiply", 0x0d7 },
365 { "Ooblique", 0x0d8 },
366 { "Ugrave", 0x0d9 },
367 { "Uacute", 0x0da },
368 { "Ucircumflex", 0x0db },
369 { "Udiaeresis", 0x0dc },
370 { "Yacute", 0x0dd },
371 { "THORN", 0x0de },
372 { "ssharp", 0x0df },
373 { "agrave", 0x0e0 },
374 { "aacute", 0x0e1 },
375 { "acircumflex", 0x0e2 },
376 { "atilde", 0x0e3 },
377 { "adiaeresis", 0x0e4 },
378 { "aring", 0x0e5 },
379 { "ae", 0x0e6 },
380 { "ccedilla", 0x0e7 },
381 { "egrave", 0x0e8 },
382 { "eacute", 0x0e9 },
383 { "ecircumflex", 0x0ea },
384 { "ediaeresis", 0x0eb },
385 { "igrave", 0x0ec },
386 { "iacute", 0x0ed },
387 { "icircumflex", 0x0ee },
388 { "idiaeresis", 0x0ef },
389 { "eth", 0x0f0 },
390 { "ntilde", 0x0f1 },
391 { "ograve", 0x0f2 },
392 { "oacute", 0x0f3 },
393 { "ocircumflex", 0x0f4 },
394 { "otilde", 0x0f5 },
395 { "odiaeresis", 0x0f6 },
396 { "division", 0x0f7 },
397 { "oslash", 0x0f8 },
398 { "ugrave", 0x0f9 },
399 { "uacute", 0x0fa },
400 { "ucircumflex", 0x0fb },
401 { "udiaeresis", 0x0fc },
402 { "yacute", 0x0fd },
403 { "thorn", 0x0fe },
404 { "ydiaeresis", 0x0ff },
405 { "unknown", 0xffff },
406 { 0, 0}
407};
408
409static QMap<QString, int> kcn_map;
410static QMap<int, QString> kcn_rmap;
411
412void init_kcn_maps() {
413 int i = 0;
414 while (Keycode_Names[i].name != 0) {
415 int keycode = Keycode_Names[i].keycode;
416 QString name(Keycode_Names[i].name);
417
418 kcn_map.insert(name, keycode);
419 kcn_rmap.insert(keycode, name);
420 i++;
421 }
422}
423
424int KeycodeNames::find(const QString& key) {
425 if (kcn_map.isEmpty()) {
426 init_kcn_maps();
427 }
428
429 QMap<QString, int>::Iterator it = kcn_map.find(key);
430 if (it == kcn_map.end()) {
431 return -1;
432 } else {
433 return it.data();
434 }
435}
436
437const QString& KeycodeNames::find(int k) {
438 if (kcn_map.isEmpty()) {
439 init_kcn_maps();
440 }
441
442 QMap<int, QString>::Iterator it = kcn_rmap.find(k);
443 if (it == kcn_rmap.end()) {
444 return Null_String;
445 } else {
446 return it.data();
447 }
448}
449
450#endif