summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/keyz-cfg/zkbnames.cpp3
-rw-r--r--noncore/apps/keyz-cfg/zkbnames.h4
-rw-r--r--noncore/apps/keyz-cfg/zkbxml.cpp14
3 files changed, 0 insertions, 21 deletions
diff --git a/noncore/apps/keyz-cfg/zkbnames.cpp b/noncore/apps/keyz-cfg/zkbnames.cpp
index fec3a2e..c20a114 100644
--- a/noncore/apps/keyz-cfg/zkbnames.cpp
+++ b/noncore/apps/keyz-cfg/zkbnames.cpp
@@ -1,98 +1,96 @@
1#ifdef USE_ZKB_NAMES
2
3#include <qmap.h> 1#include <qmap.h>
4#include <qstring.h> 2#include <qstring.h>
5 3
6#include "zkbnames.h" 4#include "zkbnames.h"
7 5
8QString Null_String((const char*) 0); 6QString Null_String((const char*) 0);
9 7
10// Implementation of KeyNames 8// Implementation of KeyNames
11static struct { 9static struct {
12 int key; 10 int key;
13 char *name; 11 char *name;
14} Key_Names[] = { 12} Key_Names[] = {
15 { 32, "Space" }, 13 { 32, "Space" },
16 { 39, "Apostrophe" }, 14 { 39, "Apostrophe" },
17 { 44, "Comma" }, 15 { 44, "Comma" },
18 { 46, "Period" }, 16 { 46, "Period" },
19 { 47, "Slash" }, 17 { 47, "Slash" },
20 { 65, "A" }, 18 { 65, "A" },
21 { 66, "B" }, 19 { 66, "B" },
22 { 67, "C" }, 20 { 67, "C" },
23 { 68, "D" }, 21 { 68, "D" },
24 { 69, "E" }, 22 { 69, "E" },
25 { 70, "F" }, 23 { 70, "F" },
26 { 71, "G" }, 24 { 71, "G" },
27 { 72, "H" }, 25 { 72, "H" },
28 { 73, "I" }, 26 { 73, "I" },
29 { 74, "J" }, 27 { 74, "J" },
30 { 75, "K" }, 28 { 75, "K" },
31 { 76, "L" }, 29 { 76, "L" },
32 { 77, "M" }, 30 { 77, "M" },
33 { 78, "N" }, 31 { 78, "N" },
34 { 79, "O" }, 32 { 79, "O" },
35 { 80, "P" }, 33 { 80, "P" },
36 { 81, "Q" }, 34 { 81, "Q" },
37 { 82, "R" }, 35 { 82, "R" },
38 { 83, "S" }, 36 { 83, "S" },
39 { 84, "T" }, 37 { 84, "T" },
40 { 85, "U" }, 38 { 85, "U" },
41 { 86, "V" }, 39 { 86, "V" },
42 { 87, "W" }, 40 { 87, "W" },
43 { 88, "X" }, 41 { 88, "X" },
44 { 89, "Y" }, 42 { 89, "Y" },
45 { 90, "Z" }, 43 { 90, "Z" },
46 { 4096, "Cancel" }, 44 { 4096, "Cancel" },
47 { 4097, "Tab" }, 45 { 4097, "Tab" },
48 { 4099, "Backspace" }, 46 { 4099, "Backspace" },
49 { 4100, "Enter" }, 47 { 4100, "Enter" },
50 { 4114, "Left" }, 48 { 4114, "Left" },
51 { 4115, "Up" }, 49 { 4115, "Up" },
52 { 4116, "Right" }, 50 { 4116, "Right" },
53 { 4117, "Down" }, 51 { 4117, "Down" },
54 { 4128, "Left Shift" }, 52 { 4128, "Left Shift" },
55 { 4130, "Right Shift" }, 53 { 4130, "Right Shift" },
56 { 4152, "Calendar" }, 54 { 4152, "Calendar" },
57 { 4153, "Addressbook" }, 55 { 4153, "Addressbook" },
58 { 4154, "Menu" }, 56 { 4154, "Menu" },
59 { 4155, "Home" }, 57 { 4155, "Home" },
60 { 4156, "Mail" }, 58 { 4156, "Mail" },
61 { 4165, "Fn" }, 59 { 4165, "Fn" },
62 { 4173, "Middle" }, 60 { 4173, "Middle" },
63 { 4176, "OK" }, 61 { 4176, "OK" },
64 { 4177, "Off" }, 62 { 4177, "Off" },
65 { 4178, "Light" }, 63 { 4178, "Light" },
66 { 0, 0 } 64 { 0, 0 }
67}; 65};
68 66
69static QMap<QString, int> kn_map; 67static QMap<QString, int> kn_map;
70static QMap<int, QString> kn_rmap; 68static QMap<int, QString> kn_rmap;
71 69
72void init_kn_maps() { 70void init_kn_maps() {
73 int i = 0; 71 int i = 0;
74 while (Key_Names[i].name != 0) { 72 while (Key_Names[i].name != 0) {
75 int key = Key_Names[i].key; 73 int key = Key_Names[i].key;
76 QString name(Key_Names[i].name); 74 QString name(Key_Names[i].name);
77 75
78 kn_map.insert(name, key); 76 kn_map.insert(name, key);
79 kn_rmap.insert(key, name); 77 kn_rmap.insert(key, name);
80 i++; 78 i++;
81 } 79 }
82} 80}
83 81
84int KeyNames::find(const QString& key) { 82int KeyNames::find(const QString& key) {
85 if (kn_map.isEmpty()) { 83 if (kn_map.isEmpty()) {
86 init_kn_maps(); 84 init_kn_maps();
87 } 85 }
88 86
89 QMap<QString, int>::Iterator it = kn_map.find(key); 87 QMap<QString, int>::Iterator it = kn_map.find(key);
90 if (it == kn_map.end()) { 88 if (it == kn_map.end()) {
91 return -1; 89 return -1;
92 } else { 90 } else {
93 return it.data(); 91 return it.data();
94 } 92 }
95} 93}
96 94
97const QString& KeyNames::find(int k) { 95const QString& KeyNames::find(int k) {
98 if (kn_map.isEmpty()) { 96 if (kn_map.isEmpty()) {
@@ -354,97 +352,96 @@ struct {
354 { "Iacute", 0x0cd }, 352 { "Iacute", 0x0cd },
355 { "Icircumflex", 0x0ce }, 353 { "Icircumflex", 0x0ce },
356 { "Idiaeresis", 0x0cf }, 354 { "Idiaeresis", 0x0cf },
357 { "ETH", 0x0d0 }, 355 { "ETH", 0x0d0 },
358 { "Ntilde", 0x0d1 }, 356 { "Ntilde", 0x0d1 },
359 { "Ograve", 0x0d2 }, 357 { "Ograve", 0x0d2 },
360 { "Oacute", 0x0d3 }, 358 { "Oacute", 0x0d3 },
361 { "Ocircumflex", 0x0d4 }, 359 { "Ocircumflex", 0x0d4 },
362 { "Otilde", 0x0d5 }, 360 { "Otilde", 0x0d5 },
363 { "Odiaeresis", 0x0d6 }, 361 { "Odiaeresis", 0x0d6 },
364 { "multiply", 0x0d7 }, 362 { "multiply", 0x0d7 },
365 { "Ooblique", 0x0d8 }, 363 { "Ooblique", 0x0d8 },
366 { "Ugrave", 0x0d9 }, 364 { "Ugrave", 0x0d9 },
367 { "Uacute", 0x0da }, 365 { "Uacute", 0x0da },
368 { "Ucircumflex", 0x0db }, 366 { "Ucircumflex", 0x0db },
369 { "Udiaeresis", 0x0dc }, 367 { "Udiaeresis", 0x0dc },
370 { "Yacute", 0x0dd }, 368 { "Yacute", 0x0dd },
371 { "THORN", 0x0de }, 369 { "THORN", 0x0de },
372 { "ssharp", 0x0df }, 370 { "ssharp", 0x0df },
373 { "agrave", 0x0e0 }, 371 { "agrave", 0x0e0 },
374 { "aacute", 0x0e1 }, 372 { "aacute", 0x0e1 },
375 { "acircumflex", 0x0e2 }, 373 { "acircumflex", 0x0e2 },
376 { "atilde", 0x0e3 }, 374 { "atilde", 0x0e3 },
377 { "adiaeresis", 0x0e4 }, 375 { "adiaeresis", 0x0e4 },
378 { "aring", 0x0e5 }, 376 { "aring", 0x0e5 },
379 { "ae", 0x0e6 }, 377 { "ae", 0x0e6 },
380 { "ccedilla", 0x0e7 }, 378 { "ccedilla", 0x0e7 },
381 { "egrave", 0x0e8 }, 379 { "egrave", 0x0e8 },
382 { "eacute", 0x0e9 }, 380 { "eacute", 0x0e9 },
383 { "ecircumflex", 0x0ea }, 381 { "ecircumflex", 0x0ea },
384 { "ediaeresis", 0x0eb }, 382 { "ediaeresis", 0x0eb },
385 { "igrave", 0x0ec }, 383 { "igrave", 0x0ec },
386 { "iacute", 0x0ed }, 384 { "iacute", 0x0ed },
387 { "icircumflex", 0x0ee }, 385 { "icircumflex", 0x0ee },
388 { "idiaeresis", 0x0ef }, 386 { "idiaeresis", 0x0ef },
389 { "eth", 0x0f0 }, 387 { "eth", 0x0f0 },
390 { "ntilde", 0x0f1 }, 388 { "ntilde", 0x0f1 },
391 { "ograve", 0x0f2 }, 389 { "ograve", 0x0f2 },
392 { "oacute", 0x0f3 }, 390 { "oacute", 0x0f3 },
393 { "ocircumflex", 0x0f4 }, 391 { "ocircumflex", 0x0f4 },
394 { "otilde", 0x0f5 }, 392 { "otilde", 0x0f5 },
395 { "odiaeresis", 0x0f6 }, 393 { "odiaeresis", 0x0f6 },
396 { "division", 0x0f7 }, 394 { "division", 0x0f7 },
397 { "oslash", 0x0f8 }, 395 { "oslash", 0x0f8 },
398 { "ugrave", 0x0f9 }, 396 { "ugrave", 0x0f9 },
399 { "uacute", 0x0fa }, 397 { "uacute", 0x0fa },
400 { "ucircumflex", 0x0fb }, 398 { "ucircumflex", 0x0fb },
401 { "udiaeresis", 0x0fc }, 399 { "udiaeresis", 0x0fc },
402 { "yacute", 0x0fd }, 400 { "yacute", 0x0fd },
403 { "thorn", 0x0fe }, 401 { "thorn", 0x0fe },
404 { "ydiaeresis", 0x0ff }, 402 { "ydiaeresis", 0x0ff },
405 { "unknown", 0xffff }, 403 { "unknown", 0xffff },
406 { 0, 0} 404 { 0, 0}
407}; 405};
408 406
409static QMap<QString, int> kcn_map; 407static QMap<QString, int> kcn_map;
410static QMap<int, QString> kcn_rmap; 408static QMap<int, QString> kcn_rmap;
411 409
412void init_kcn_maps() { 410void init_kcn_maps() {
413 int i = 0; 411 int i = 0;
414 while (Keycode_Names[i].name != 0) { 412 while (Keycode_Names[i].name != 0) {
415 int keycode = Keycode_Names[i].keycode; 413 int keycode = Keycode_Names[i].keycode;
416 QString name(Keycode_Names[i].name); 414 QString name(Keycode_Names[i].name);
417 415
418 kcn_map.insert(name, keycode); 416 kcn_map.insert(name, keycode);
419 kcn_rmap.insert(keycode, name); 417 kcn_rmap.insert(keycode, name);
420 i++; 418 i++;
421 } 419 }
422} 420}
423 421
424int KeycodeNames::find(const QString& key) { 422int KeycodeNames::find(const QString& key) {
425 if (kcn_map.isEmpty()) { 423 if (kcn_map.isEmpty()) {
426 init_kcn_maps(); 424 init_kcn_maps();
427 } 425 }
428 426
429 QMap<QString, int>::Iterator it = kcn_map.find(key); 427 QMap<QString, int>::Iterator it = kcn_map.find(key);
430 if (it == kcn_map.end()) { 428 if (it == kcn_map.end()) {
431 return -1; 429 return -1;
432 } else { 430 } else {
433 return it.data(); 431 return it.data();
434 } 432 }
435} 433}
436 434
437const QString& KeycodeNames::find(int k) { 435const QString& KeycodeNames::find(int k) {
438 if (kcn_map.isEmpty()) { 436 if (kcn_map.isEmpty()) {
439 init_kcn_maps(); 437 init_kcn_maps();
440 } 438 }
441 439
442 QMap<int, QString>::Iterator it = kcn_rmap.find(k); 440 QMap<int, QString>::Iterator it = kcn_rmap.find(k);
443 if (it == kcn_rmap.end()) { 441 if (it == kcn_rmap.end()) {
444 return Null_String; 442 return Null_String;
445 } else { 443 } else {
446 return it.data(); 444 return it.data();
447 } 445 }
448} 446}
449 447
450#endif
diff --git a/noncore/apps/keyz-cfg/zkbnames.h b/noncore/apps/keyz-cfg/zkbnames.h
index 58462ff..0d1e7f5 100644
--- a/noncore/apps/keyz-cfg/zkbnames.h
+++ b/noncore/apps/keyz-cfg/zkbnames.h
@@ -1,27 +1,23 @@
1#ifndef ZKBNAMES_H 1#ifndef ZKBNAMES_H
2#define ZKBNAMES_H 2#define ZKBNAMES_H
3 3
4#ifdef USE_ZKB_NAMES
5
6#include <qstring.h> 4#include <qstring.h>
7 5
8class KeyNames { 6class KeyNames {
9public: 7public:
10 static int find(const QString& key); 8 static int find(const QString& key);
11 static const QString& find(int); 9 static const QString& find(int);
12}; 10};
13 11
14class KeycodeNames { 12class KeycodeNames {
15public: 13public:
16 static int find(const QString& key); 14 static int find(const QString& key);
17 static const QString& find(int); 15 static const QString& find(int);
18}; 16};
19 17
20class ModifierNames { 18class ModifierNames {
21public: 19public:
22 static int find(const QString& key); 20 static int find(const QString& key);
23 static const QString& find(int); 21 static const QString& find(int);
24}; 22};
25
26#endif
27#endif 23#endif
diff --git a/noncore/apps/keyz-cfg/zkbxml.cpp b/noncore/apps/keyz-cfg/zkbxml.cpp
index 76472cb..5b0084c 100644
--- a/noncore/apps/keyz-cfg/zkbxml.cpp
+++ b/noncore/apps/keyz-cfg/zkbxml.cpp
@@ -396,192 +396,178 @@ bool ZkbXmlHandler::start_event(const QXmlAttributes& attr) {
396 if (!err.isEmpty()) { 396 if (!err.isEmpty()) {
397 return false; 397 return false;
398 } 398 }
399 nattr++; 399 nattr++;
400 } 400 }
401 401
402 if (pidx >= 0) { 402 if (pidx >= 0) {
403 pressed = str2bool(attr.value(pidx)); 403 pressed = str2bool(attr.value(pidx));
404 if (!err.isEmpty()) { 404 if (!err.isEmpty()) {
405 return false; 405 return false;
406 } 406 }
407 nattr++; 407 nattr++;
408 } else { 408 } else {
409 setError("Missing pressed attribute"); 409 setError("Missing pressed attribute");
410 return false; 410 return false;
411 } 411 }
412 412
413 if (aidx >= 0) { 413 if (aidx >= 0) {
414 autorepeat = str2bool(attr.value(aidx)); 414 autorepeat = str2bool(attr.value(aidx));
415 if (!err.isEmpty()) { 415 if (!err.isEmpty()) {
416 return false; 416 return false;
417 } 417 }
418 nattr++; 418 nattr++;
419 } 419 }
420 420
421 if (attr.length() > nattr) { 421 if (attr.length() > nattr) {
422 setError("Unsupported attributes"); 422 setError("Unsupported attributes");
423 return false; 423 return false;
424 } 424 }
425 425
426 return startEventElement(keycode, unicode, modifiers, pressed, 426 return startEventElement(keycode, unicode, modifiers, pressed,
427 autorepeat); 427 autorepeat);
428} 428}
429 429
430bool ZkbXmlHandler::start_next_state(const QXmlAttributes& attr) { 430bool ZkbXmlHandler::start_next_state(const QXmlAttributes& attr) {
431 int nattr = 0; 431 int nattr = 0;
432 int nidx = attr.index("name"); 432 int nidx = attr.index("name");
433 QString name; 433 QString name;
434 434
435 if (elements.first() != Map_Tag) { 435 if (elements.first() != Map_Tag) {
436 setError("next-state element should be used only " 436 setError("next-state element should be used only "
437 "within map element"); 437 "within map element");
438 return false; 438 return false;
439 } 439 }
440 440
441 if (nidx >= 0) { 441 if (nidx >= 0) {
442 name = attr.value(nidx); 442 name = attr.value(nidx);
443 nattr++; 443 nattr++;
444 } else { 444 } else {
445 setError("Missing name attribute"); 445 setError("Missing name attribute");
446 return false; 446 return false;
447 } 447 }
448 448
449 if (attr.length() > nattr) { 449 if (attr.length() > nattr) {
450 setError("Unsupported attributes"); 450 setError("Unsupported attributes");
451 return false; 451 return false;
452 } 452 }
453 453
454 return startNextStateElement(name); 454 return startNextStateElement(name);
455} 455}
456 456
457bool ZkbXmlHandler::end_keymap() { 457bool ZkbXmlHandler::end_keymap() {
458 return endKeymapElement(); 458 return endKeymapElement();
459} 459}
460 460
461bool ZkbXmlHandler::end_include() { 461bool ZkbXmlHandler::end_include() {
462 return endIncludeElement(); 462 return endIncludeElement();
463} 463}
464 464
465bool ZkbXmlHandler::end_label() { 465bool ZkbXmlHandler::end_label() {
466 return endLabelElement(); 466 return endLabelElement();
467} 467}
468 468
469bool ZkbXmlHandler::end_state() { 469bool ZkbXmlHandler::end_state() {
470 return endStateElement(); 470 return endStateElement();
471} 471}
472 472
473bool ZkbXmlHandler::end_map() { 473bool ZkbXmlHandler::end_map() {
474 return endMapElement(); 474 return endMapElement();
475} 475}
476 476
477bool ZkbXmlHandler::end_event() { 477bool ZkbXmlHandler::end_event() {
478 return endEventElement(); 478 return endEventElement();
479} 479}
480 480
481bool ZkbXmlHandler::end_next_state() { 481bool ZkbXmlHandler::end_next_state() {
482 return endNextStateElement(); 482 return endNextStateElement();
483} 483}
484 484
485void ZkbXmlHandler::setError(const QString& e) { 485void ZkbXmlHandler::setError(const QString& e) {
486 err = e; 486 err = e;
487} 487}
488 488
489int ZkbXmlHandler::str2key(const QString& s) { 489int ZkbXmlHandler::str2key(const QString& s) {
490 int ret; 490 int ret;
491 491
492#ifdef USE_ZKB_NAMES
493 ret = KeyNames::find(s); 492 ret = KeyNames::find(s);
494 if (ret == -1) { 493 if (ret == -1) {
495 setError("Invalid value: " + s); 494 setError("Invalid value: " + s);
496 } 495 }
497 496
498#else
499 ret = str2uint(s);
500#endif
501
502 return ret; 497 return ret;
503} 498}
504 499
505int ZkbXmlHandler::str2modifier(const QString& val) { 500int ZkbXmlHandler::str2modifier(const QString& val) {
506 int ret; 501 int ret;
507 502
508#ifdef USE_ZKB_NAMES
509 int n, i; 503 int n, i;
510 ret = 0; 504 ret = 0;
511 n = 0; 505 n = 0;
512 do { 506 do {
513 i = val.find('|', n); 507 i = val.find('|', n);
514 if (i < 0) { 508 if (i < 0) {
515 i = val.length(); 509 i = val.length();
516 } 510 }
517 511
518 QString s = val.mid(n, i - n); 512 QString s = val.mid(n, i - n);
519 int v = ModifierNames::find(s.stripWhiteSpace()); 513 int v = ModifierNames::find(s.stripWhiteSpace());
520 514
521 if (v == -1) { 515 if (v == -1) {
522 setError("Invalid value: " + val); 516 setError("Invalid value: " + val);
523 return -1; 517 return -1;
524 } 518 }
525 519
526 ret |= v; 520 ret |= v;
527 n = i + 1; 521 n = i + 1;
528 } while (n < val.length()); 522 } while (n < val.length());
529#else
530 ret = str2uint(val);
531#endif
532 523
533 return ret; 524 return ret;
534} 525}
535 526
536bool ZkbXmlHandler::str2bool(const QString& s) { 527bool ZkbXmlHandler::str2bool(const QString& s) {
537 if (s == "true") { 528 if (s == "true") {
538 return true; 529 return true;
539 } else { 530 } else {
540 return false; 531 return false;
541 } 532 }
542} 533}
543 534
544int ZkbXmlHandler::str2unicode(const QString& s) { 535int ZkbXmlHandler::str2unicode(const QString& s) {
545 return str2uint(s); 536 return str2uint(s);
546} 537}
547 538
548int ZkbXmlHandler::str2keycode(const QString& s) { 539int ZkbXmlHandler::str2keycode(const QString& s) {
549 int ret; 540 int ret;
550 541
551#ifdef USE_ZKB_NAMES
552 ret = KeycodeNames::find(s); 542 ret = KeycodeNames::find(s);
553 if (ret == -1) { 543 if (ret == -1) {
554 setError("Invalid value: " + s); 544 setError("Invalid value: " + s);
555 } 545 }
556 546
557#else
558 ret = str2uint(s);
559#endif
560
561 return ret; 547 return ret;
562} 548}
563 549
564int ZkbXmlHandler::str2uint(const QString& s) { 550int ZkbXmlHandler::str2uint(const QString& s) {
565 int ret; 551 int ret;
566 bool ok; 552 bool ok;
567 QString val = s; 553 QString val = s;
568 int r; 554 int r;
569 555
570 if (val.left(2) == "0x") { 556 if (val.left(2) == "0x") {
571 val = s.mid(2); 557 val = s.mid(2);
572 r = 16; 558 r = 16;
573 } else if (val.left(1) == "0") { 559 } else if (val.left(1) == "0") {
574 val = s.mid(1); 560 val = s.mid(1);
575 r = 8; 561 r = 8;
576 } else { 562 } else {
577 r = 10; 563 r = 10;
578 } 564 }
579 565
580 ret = val.toInt(&ok, r); 566 ret = val.toInt(&ok, r);
581 if (!ok) { 567 if (!ok) {
582 setError("Invalid value: " + s); 568 setError("Invalid value: " + s);
583 ret = -1; 569 ret = -1;
584 } 570 }
585 571
586 return ret; 572 return ret;
587} 573}