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