Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

zkbnames.cpp

Go to the documentation of this file.
00001 #include <qmap.h>
00002 
00003 #include "zkbnames.h"
00004 
00005 QString Null_String((const char*) 0);
00006 
00007 // Implementation of KeyNames
00008 struct Key_Names_t {
00009         int key;
00010         char *name;
00011 };
00012 
00013 static const Key_Names_t Key_Names[] = {
00014         { 32, "Space" },
00015         { 39, "Apostrophe" },
00016         { 44, "Comma" },
00017         { 46, "Period" },
00018         { 47, "Slash" },
00019         { 65, "A" },
00020         { 66, "B" },
00021         { 67, "C" },
00022         { 68, "D" },
00023         { 69, "E" },
00024         { 70, "F" },
00025         { 71, "G" },
00026         { 72, "H" },
00027         { 73, "I" },
00028         { 74, "J" },
00029         { 75, "K" },
00030         { 76, "L" },
00031         { 77, "M" },
00032         { 78, "N" },
00033         { 79, "O" },
00034         { 80, "P" },
00035         { 81, "Q" },
00036         { 82, "R" },
00037         { 83, "S" },
00038         { 84, "T" },
00039         { 85, "U" },
00040         { 86, "V" },
00041         { 87, "W" },
00042         { 88, "X" },
00043         { 89, "Y" },
00044         { 90, "Z" },
00045         { 4096, "Cancel" },
00046         { 4097, "Tab" },
00047         { 4099, "Backspace" },
00048         { 4100, "Enter" },
00049         { 4114, "Left" },
00050         { 4115, "Up" },
00051         { 4116, "Right" },
00052         { 4117, "Down" },
00053         { 4128, "Left Shift" },
00054         { 4130, "Right Shift" },
00055         { 4152, "Calendar" },
00056         { 4153, "Addressbook" },
00057         { 4154, "Menu" },
00058         { 4155, "Home" },
00059         { 4156, "Mail" },
00060         { 4165, "Fn" },
00061         { 4173, "Middle" },
00062         { 4176, "OK" },
00063         { 4177, "Off" },
00064         { 4178, "Light" },
00065         { 0, 0 }
00066 };
00067 
00068 static QMap<QString, int> kn_map;
00069 static QMap<int, QString> kn_rmap;
00070 
00071 void init_kn_maps() {
00072         int i = 0;
00073         while (Key_Names[i].name != 0) {
00074                 int key = Key_Names[i].key;
00075                 QString name(Key_Names[i].name);
00076 
00077                 kn_map.insert(name, key);
00078                 kn_rmap.insert(key, name);
00079                 i++;
00080         }
00081 }
00082 
00083 int KeyNames::find(const QString& key) {
00084         if (kn_map.isEmpty()) {
00085                 init_kn_maps();
00086         }
00087 
00088         QMap<QString, int>::Iterator it = kn_map.find(key);
00089         if (it == kn_map.end()) {
00090                 return -1;
00091         } else {
00092                 return it.data();
00093         }
00094 }
00095 
00096 const QString& KeyNames::find(int k) {
00097         if (kn_map.isEmpty()) {
00098                 init_kn_maps();
00099         }
00100 
00101         QMap<int, QString>::Iterator it = kn_rmap.find(k);
00102         if (it == kn_rmap.end()) {
00103                 return Null_String;
00104         } else {
00105                 return it.data();
00106         }
00107 }
00108 
00109 // Implementation of ModifierNames
00110 struct Modifier_Names_t {
00111         int value;
00112         char* name;
00113 };
00114 
00115 static const Modifier_Names_t Modifier_Names[] = {
00116         { 8, "Shift" },
00117         { 16, "Control" },
00118         { 32, "Alt" },
00119         { 0x4000, "Keypad" },
00120         { 0, 0 }
00121 };
00122 
00123 static QMap<QString, int> mn_map;
00124 static QMap<int, QString> mn_rmap;
00125 
00126 void init_mn_maps() {
00127         int i = 0;
00128         while (Modifier_Names[i].name != 0) {
00129                 int value = Modifier_Names[i].value;
00130                 QString name(Modifier_Names[i].name);
00131 
00132                 mn_map.insert(name, value);
00133                 mn_rmap.insert(value, name);
00134                 i++;
00135         }
00136 }
00137 
00138 int ModifierNames::find(const QString& key) {
00139         if (mn_map.isEmpty()) {
00140                 init_mn_maps();
00141         }
00142 
00143         QMap<QString, int>::Iterator it = mn_map.find(key);
00144         if (it == mn_map.end()) {
00145                 return -1;
00146         } else {
00147                 return it.data();
00148         }
00149 }
00150 
00151 const QString& ModifierNames::find(int k) {
00152         if (mn_map.isEmpty()) {
00153                 init_mn_maps();
00154         }
00155 
00156         QMap<int, QString>::Iterator it = mn_rmap.find(k);
00157         if (it == mn_rmap.end()) {
00158                 return Null_String;
00159         } else {
00160                 return it.data();
00161         }
00162 }
00163 
00164 // Implementation of KeycodeNames
00165 
00166 struct Keycode_Names_t {
00167         char* name;
00168         int keycode;
00169 };
00170 
00171 static const Keycode_Names_t Keycode_Names[] = {
00172         { "Escape", 0x1000 },
00173         { "Tab", 0x1001 },
00174         { "Backtab", 0x1002 },
00175         { "Backspace", 0x1003 },
00176         { "BackSpace", 0x1003 },
00177         { "Return", 0x1004 },
00178         { "Enter", 0x1005 },
00179         { "Insert", 0x1006 },
00180         { "Delete", 0x1007 },
00181         { "Pause", 0x1008 },
00182         { "Print", 0x1009 },
00183         { "SysReq", 0x100a },
00184         { "Home", 0x1010 },
00185         { "End", 0x1011 },
00186         { "Left", 0x1012 },
00187         { "Up", 0x1013 },
00188         { "Right", 0x1014 },
00189         { "Down", 0x1015 },
00190         { "Prior", 0x1016 },
00191         { "PageUp", 0x1016 },
00192         { "Next", 0x1017 },
00193         { "PageDown", 0x1017 },
00194         { "Shift", 0x1020 },
00195         { "Control", 0x1021 },
00196         { "Meta", 0x1022 },
00197         { "Alt", 0x1023 },
00198         { "CapsLock", 0x1024 },
00199         { "NumLock", 0x1025 },
00200         { "ScrollLock", 0x1026 },
00201         { "F1", 0x1030 },
00202         { "F2", 0x1031 },
00203         { "F3", 0x1032 },
00204         { "F4", 0x1033 },
00205         { "F5", 0x1034 },
00206         { "F6", 0x1035 },
00207         { "F7", 0x1036 },
00208         { "F8", 0x1037 },
00209         { "F9", 0x1038 },
00210         { "F10", 0x1039 },
00211         { "F11", 0x103a },
00212         { "F12", 0x103b },
00213         { "F13", 0x103c },
00214         { "F14", 0x103d },
00215         { "F15", 0x103e },
00216         { "F16", 0x103f },
00217         { "F17", 0x1040 },
00218         { "F18", 0x1041 },
00219         { "F19", 0x1042 },
00220         { "F20", 0x1043 },
00221         { "F21", 0x1044 },
00222         { "F22", 0x1045 },
00223         { "F23", 0x1046 },
00224         { "F24", 0x1047 },
00225         { "F25", 0x1048 },
00226         { "F26", 0x1049 },
00227         { "F27", 0x104a },
00228         { "F28", 0x104b },
00229         { "F29", 0x104c },
00230         { "F30", 0x104d },
00231         { "F31", 0x104e },
00232         { "F32", 0x104f },
00233         { "F33", 0x1050 },
00234         { "F34", 0x1051 },
00235         { "F35", 0x1052 },
00236         { "Super_L", 0x1053 },
00237         { "Super_R", 0x1054 },
00238         { "Menu", 0x1055 },
00239         { "Hyper_L", 0x1056 },
00240         { "Hyper_R", 0x1057 },
00241         { "Help", 0x1058 },
00242         { "Space", 0x20 },
00243         { "Any", 0x20 },
00244         { "Exclam", 0x21 },
00245         { "QuoteDbl", 0x22 },
00246         { "NumberSign", 0x23 },
00247         { "Dollar", 0x24 },
00248         { "Percent", 0x25 },
00249         { "Ampersand", 0x26 },
00250         { "Apostrophe", 0x27 },
00251         { "ParenLeft", 0x28 },
00252         { "ParenRight", 0x29 },
00253         { "Asterisk", 0x2a },
00254         { "Plus", 0x2b },
00255         { "Comma", 0x2c },
00256         { "Minus", 0x2d },
00257         { "Period", 0x2e },
00258         { "Slash", 0x2f },
00259         { "0", 0x30 },
00260         { "1", 0x31 },
00261         { "2", 0x32 },
00262         { "3", 0x33 },
00263         { "4", 0x34 },
00264         { "5", 0x35 },
00265         { "6", 0x36 },
00266         { "7", 0x37 },
00267         { "8", 0x38 },
00268         { "9", 0x39 },
00269         { "Colon", 0x3a },
00270         { "Semicolon", 0x3b },
00271         { "Less", 0x3c },
00272         { "Equal", 0x3d },
00273         { "Greater", 0x3e },
00274         { "Question", 0x3f },
00275         { "At", 0x40 },
00276         { "A", 0x41 },
00277         { "B", 0x42 },
00278         { "C", 0x43 },
00279         { "D", 0x44 },
00280         { "E", 0x45 },
00281         { "F", 0x46 },
00282         { "G", 0x47 },
00283         { "H", 0x48 },
00284         { "I", 0x49 },
00285         { "J", 0x4a },
00286         { "K", 0x4b },
00287         { "L", 0x4c },
00288         { "M", 0x4d },
00289         { "N", 0x4e },
00290         { "O", 0x4f },
00291         { "P", 0x50 },
00292         { "Q", 0x51 },
00293         { "R", 0x52 },
00294         { "S", 0x53 },
00295         { "T", 0x54 },
00296         { "U", 0x55 },
00297         { "V", 0x56 },
00298         { "W", 0x57 },
00299         { "X", 0x58 },
00300         { "Y", 0x59 },
00301         { "Z", 0x5a },
00302         { "BracketLeft", 0x5b },
00303         { "Backslash", 0x5c },
00304         { "BracketRight", 0x5d },
00305         { "AsciiCircum", 0x5e },
00306         { "Underscore", 0x5f },
00307         { "QuoteLeft", 0x60 },
00308         { "BraceLeft", 0x7b },
00309         { "Bar", 0x7c },
00310         { "BraceRight", 0x7d },
00311         { "AsciiTilde", 0x7e },
00312         { "nobreakspace", 0x0a0 },
00313         { "exclamdown", 0x0a1 },
00314         { "cent", 0x0a2 },
00315         { "sterling", 0x0a3 },
00316         { "currency", 0x0a4 },
00317         { "yen", 0x0a5 },
00318         { "brokenbar", 0x0a6 },
00319         { "section", 0x0a7 },
00320         { "diaeresis", 0x0a8 },
00321         { "copyright", 0x0a9 },
00322         { "ordfeminine", 0x0aa },
00323         { "guillemotleft", 0x0ab },
00324         { "notsign", 0x0ac },
00325         { "hyphen", 0x0ad },
00326         { "registered", 0x0ae },
00327         { "macron", 0x0af },
00328         { "degree", 0x0b0 },
00329         { "plusminus", 0x0b1 },
00330         { "twosuperior", 0x0b2 },
00331         { "threesuperior", 0x0b3 },
00332         { "acute", 0x0b4 },
00333         { "mu", 0x0b5 },
00334         { "paragraph", 0x0b6 },
00335         { "periodcentered", 0x0b7 },
00336         { "cedilla", 0x0b8 },
00337         { "onesuperior", 0x0b9 },
00338         { "masculine", 0x0ba },
00339         { "guillemotright", 0x0bb },
00340         { "onequarter", 0x0bc },
00341         { "onehalf", 0x0bd },
00342         { "threequarters", 0x0be },
00343         { "questiondown", 0x0bf },
00344         { "Agrave", 0x0c0 },
00345         { "Aacute", 0x0c1 },
00346         { "Acircumflex", 0x0c2 },
00347         { "Atilde", 0x0c3 },
00348         { "Adiaeresis", 0x0c4 },
00349         { "Aring", 0x0c5 },
00350         { "AE", 0x0c6 },
00351         { "Ccedilla", 0x0c7 },
00352         { "Egrave", 0x0c8 },
00353         { "Eacute", 0x0c9 },
00354         { "Ecircumflex", 0x0ca },
00355         { "Ediaeresis", 0x0cb },
00356         { "Igrave", 0x0cc },
00357         { "Iacute", 0x0cd },
00358         { "Icircumflex", 0x0ce },
00359         { "Idiaeresis", 0x0cf },
00360         { "ETH", 0x0d0 },
00361         { "Ntilde", 0x0d1 },
00362         { "Ograve", 0x0d2 },
00363         { "Oacute", 0x0d3 },
00364         { "Ocircumflex", 0x0d4 },
00365         { "Otilde", 0x0d5 },
00366         { "Odiaeresis", 0x0d6 },
00367         { "multiply", 0x0d7 },
00368         { "Ooblique", 0x0d8 },
00369         { "Ugrave", 0x0d9 },
00370         { "Uacute", 0x0da },
00371         { "Ucircumflex", 0x0db },
00372         { "Udiaeresis", 0x0dc },
00373         { "Yacute", 0x0dd },
00374         { "THORN", 0x0de },
00375         { "ssharp", 0x0df },
00376         { "agrave", 0x0e0 },
00377         { "aacute", 0x0e1 },
00378         { "acircumflex", 0x0e2 },
00379         { "atilde", 0x0e3 },
00380         { "adiaeresis", 0x0e4 },
00381         { "aring", 0x0e5 },
00382         { "ae", 0x0e6 },
00383         { "ccedilla", 0x0e7 },
00384         { "egrave", 0x0e8 },
00385         { "eacute", 0x0e9 },
00386         { "ecircumflex", 0x0ea },
00387         { "ediaeresis", 0x0eb },
00388         { "igrave", 0x0ec },
00389         { "iacute", 0x0ed },
00390         { "icircumflex", 0x0ee },
00391         { "idiaeresis", 0x0ef },
00392         { "eth", 0x0f0 },
00393         { "ntilde", 0x0f1 },
00394         { "ograve", 0x0f2 },
00395         { "oacute", 0x0f3 },
00396         { "ocircumflex", 0x0f4 },
00397         { "otilde", 0x0f5 },
00398         { "odiaeresis", 0x0f6 },
00399         { "division", 0x0f7 },
00400         { "oslash", 0x0f8 },
00401         { "ugrave", 0x0f9 },
00402         { "uacute", 0x0fa },
00403         { "ucircumflex", 0x0fb },
00404         { "udiaeresis", 0x0fc },
00405         { "yacute", 0x0fd },
00406         { "thorn", 0x0fe },
00407         { "ydiaeresis", 0x0ff },
00408         { "unknown", 0xffff },
00409         { 0, 0}
00410 };
00411 
00412 static QMap<QString, int> kcn_map;
00413 static QMap<int, QString> kcn_rmap;
00414 
00415 void init_kcn_maps() {
00416         int i = 0;
00417         while (Keycode_Names[i].name != 0) {
00418                 int keycode = Keycode_Names[i].keycode;
00419                 QString name(Keycode_Names[i].name);
00420 
00421                 kcn_map.insert(name, keycode);
00422                 kcn_rmap.insert(keycode, name);
00423                 i++;
00424         }
00425 }
00426 
00427 int KeycodeNames::find(const QString& key) {
00428         if (kcn_map.isEmpty()) {
00429                 init_kcn_maps();
00430         }
00431 
00432         QMap<QString, int>::Iterator it = kcn_map.find(key);
00433         if (it == kcn_map.end()) {
00434                 return -1;
00435         } else {
00436                 return it.data();
00437         }
00438 }
00439 
00440 const QString& KeycodeNames::find(int k) {
00441         if (kcn_map.isEmpty()) {
00442                 init_kcn_maps();
00443         }
00444 
00445         QMap<int, QString>::Iterator it = kcn_rmap.find(k);
00446         if (it == kcn_rmap.end()) {
00447                 return Null_String;
00448         } else {
00449                 return it.data();
00450         }
00451 }
00452 

Generated on Sat Nov 5 16:16:46 2005 for OPIE by  doxygen 1.4.2