Gnash  0.8.10
GnashKey.h
Go to the documentation of this file.
00001 // GnashKey.h: map sets of keycodes to each other.
00002 // 
00003 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00004 //   Free Software Foundation, Inc
00005 // 
00006 // This program is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 3 of the License, or
00009 // (at your option) any later version.
00010 // 
00011 // This program is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 // 
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020 #ifndef GNASHKEY_H
00021 #define GNASHKEY_H
00022 
00023 namespace gnash {
00024 
00025 namespace key {
00026 
00029 #ifdef _WIN32
00030 # undef REGISTERED
00031 #endif
00032 
00033 enum modifier
00034 {
00035     GNASH_MOD_NONE = 0,
00036     GNASH_MOD_SHIFT = 1,
00037     GNASH_MOD_CONTROL = 2,
00038     GNASH_MOD_ALT = 4
00039 };
00040 
00041 // Gnash DisplayObject codes. Each code represents a single DisplayObject on the keyboard.
00042 // The first 128 code are ordered by their correspond ASCII value.
00043 enum code
00044 {
00045   INVALID = 0,
00046   UNKNOWN1,
00047   UNKNOWN2,
00048   UNKNOWN3,
00049   UNKNOWN4,
00050   UNKNOWN5,
00051   UNKNOWN6,
00052   UNKNOWN7,
00053   BACKSPACE = 8,
00054   TAB = 9,
00055   UNKNOWN10,
00056   UNKNOWN11,
00057   CLEAR = 12,
00058   ENTER = 13,
00059   UNKNOWN14,
00060   UNKNOWN15,
00061   SHIFT = 16,
00062   CONTROL = 17,
00063   ALT = 18,
00064   PAUSE = 19,
00065   CAPSLOCK = 20,
00066   UNKNOWN21,
00067   UNKNOWN22,
00068   UNKNOWN23,
00069   UNKNOWN24,
00070   UNKNOWN25,  
00071   UNKNOWN26,
00072   ESCAPE = 27,
00073   UNKNOWN28,
00074   UNKNOWN29,
00075   UNKNOWN30,
00076   UNKNOWN31,
00077   SPACE = 32,
00078   EXCLAM = 33,
00079   DOUBLE_QUOTE = 34,
00080   HASH = 35,
00081   DOLLAR = 36,
00082   PERCENT = 37,
00083   AMPERSAND = 38 ,
00084   SINGLE_QUOTE  = 39,
00085   PAREN_LEFT = 40,
00086   PAREN_RIGHT = 41,
00087   ASTERISK = 42,
00088   PLUS = 43,
00089   COMMA = 44,
00090   MINUS = 45,
00091   PERIOD = 46,
00092   SLASH =47,
00093 
00094   _0 = 48,
00095   _1,
00096   _2,
00097   _3,
00098   _4,
00099   _5,
00100   _6,
00101   _7,
00102   _8,
00103   _9 = 57,
00104   
00105   COLON = 58,
00106   SEMICOLON = 59,
00107   LESS = 60,
00108   EQUALS = 61,
00109   MORE = 62,
00110   QUESTION = 63,
00111   AT = 64,
00112   
00113   A = 65,
00114   B,
00115   C,
00116   D,
00117   E,
00118   F,
00119   G,
00120   H,
00121   I,
00122   J,
00123   K,
00124   L,
00125   M,
00126   N,
00127   O,
00128   P,
00129   Q,
00130   R,
00131   S,
00132   T,
00133   U,
00134   V,
00135   W,
00136   X,
00137   Y,
00138   Z = 90,
00139   
00140   LEFT_BRACKET =  91,
00141   BACKSLASH =92,
00142   RIGHT_BRACKET = 93,
00143   CARET = 94,
00144   UNDERSCORE = 95,
00145   BACKQUOTE = 96,
00146   
00147   a = 97,
00148   b,
00149   c,
00150   d,
00151   e,
00152   f,
00153   g,
00154   h,
00155   i,
00156   j,
00157   k,
00158   l,
00159   m,
00160   n,
00161   o,
00162   p,
00163   q,
00164   r,
00165   s,
00166   t,
00167   u,
00168   v,
00169   w,
00170   x,
00171   y,
00172   z = 122,
00173   LEFT_BRACE = 123,
00174   PIPE = 124,
00175   RIGHT_BRACE = 125,
00176   ASCIITILDE = 126,
00177   DELETEKEY = 127,
00178   
00179   KP_0 = 128,
00180   KP_1,
00181   KP_2,
00182   KP_3,
00183   KP_4,
00184   KP_5,
00185   KP_6,
00186   KP_7,
00187   KP_8,
00188   KP_9 = 137,
00189       
00190   F1 = 138,
00191   F2,
00192   F3,
00193   F4,
00194   F5,
00195   F6,
00196   F7,
00197   F8,
00198   F9,
00199   F10,
00200   F11,
00201   F12,
00202   F13,
00203   F14,
00204   F15 = 152,
00205   
00206   UP = 153,
00207   DOWN = 154,
00208   RIGHT = 155,
00209   LEFT = 156,
00210   INSERT = 157,
00211   HOME = 158,
00212   END  = 159,
00213   PGUP = 160,
00214   PGDN = 161,
00215 
00216   KP_ADD = 162,
00217   KP_SUBTRACT = 163,
00218   KP_MULTIPLY = 164,
00219   KP_DIVIDE = 165,
00220   KP_DECIMAL = 166,
00221   KP_ENTER = 167,
00222   
00223   NUM_LOCK = 168,
00224 
00225 // Extended ASCII
00226 
00227   NOBREAKSPACE = 169,
00228   EXCLAM_DOWN = 170,
00229   CENT = 171,
00230   STERLING = 172,
00231   CURRENCY = 173,
00232   YEN = 174,
00233   BROKENBAR = 175,
00234   SECTION = 176,
00235   DIAERESIS = 177,
00236   COPYRIGHT = 178,
00237   ORDFEMININE = 179,
00238   GUILLEMOTLEFT = 180,
00239   NOTSIGN = 181,
00240   HYPHEN = 182,
00241   REGISTERED = 183,
00242   MACRON = 184,
00243   DEGREE = 185,
00244   PLUSMINUS = 186,
00245   TWOSUPERIOR = 187,
00246   THREESUPERIOR = 188,
00247   ACUTE = 189,
00248   MU = 190,
00249   PARAGRAPH = 191,
00250   PERIODCENTRED = 192,
00251   CEDILLA = 193,
00252   ONESUPERIOR = 194,
00253   MASCULINE = 195,
00254   GUILLEMOTRIGHT = 196,
00255   ONEQUARTER = 197,
00256   ONEHALF = 198,
00257   THREEQUARTERS = 199,
00258   QUESTIONDOWN = 200,
00259   AGRAVE = 201,
00260   AACUTE = 202, 
00261   ACIRCUMFLEX = 203,
00262   ATILDE = 204,
00263   ADIAERESIS = 205,
00264   ARING = 206,
00265   AE = 207,
00266   CCEDILLA = 208,
00267   EGRAVE = 209,
00268   EACUTE = 210,
00269   ECIRCUMFLEX = 211,
00270   EDIAERESIS = 212,
00271   IGRAVE = 213,
00272   IACUTE = 214,
00273   ICIRCUMFLEX = 215,
00274   IDIAERESIS = 216,
00275   ETH = 217,
00276   NTILDE = 218,
00277   OGRAVE = 219,
00278   OACUTE = 220,
00279   OCIRCUMFLEX = 221,
00280   OTILDE = 222,
00281   ODIAERESIS = 223,
00282   MULTIPLY = 224,
00283   OSLASH = 225,
00284   UGRAVE = 226,
00285   UACUTE = 227,
00286   UCIRCUMFLEX = 228,
00287   UDIAERESIS = 229,
00288   YACUTE = 230,
00289   THORN = 231,
00290   sSHARP = 232,
00291   aGRAVE = 233,
00292   aACUTE = 234,
00293   aCIRCUMFLEX = 235,
00294   aTILDE = 236,
00295   aDIAERESIS = 237,
00296   aRING = 238,
00297   ae = 239,
00298   cCEDILLA = 240,
00299   eGRAVE = 241,
00300   eACUTE = 242,
00301   eCIRCUMFLEX = 243,
00302   eDIAERESIS = 244,
00303   iGRAVE = 245,
00304   iACUTE = 246,
00305   iCIRCUMFLEX = 247,
00306   iDIAERESIS = 248,
00307   eth = 249,
00308   nTILDE = 250,
00309   oGRAVE = 251,
00310   oACUTE = 252,
00311   oCIRCUMFLEX = 253,
00312   oTILDE = 254,
00313   oDIAERESIS = 255,
00314   DIVISION = 256,
00315   oSLASH = 257,
00316   uGRAVE = 258,
00317   uACUTE = 259,
00318   uCIRCUMFLEX = 260,
00319   uDIAERESIS = 261,
00320   yACUTE = 262,
00321   thorn = 263,
00322   yDIAERESIS = 264,
00323   
00324   // TODO: add other function keys and DisplayObjects not yet known.
00325   HELP = 265,
00326   KEYCOUNT
00327 };
00328 
00329 enum type
00330 {
00331         SWF,
00332         KEY,
00333         ASCII,
00334         TYPES
00335 };
00336 
00337 const unsigned char codeMap[KEYCOUNT][TYPES] = {
00338 //{swfKeyCode, keycode, asciiKeyCode}
00339   {0,   0,   0}, // INVALID = 0
00340   {0,   0,   0}, // UNKNOWN1
00341   {0,   0,   0}, // UNKNOWN2
00342   {0,   0,   0}, // UNKNOWN3
00343   {0,   0,   0}, // UNKNOWN4
00344   {0,   0,   0}, // UNKNOWN5
00345   {0,   0,   0}, // UNKNOWN6
00346   {0,   0,   0}, // UNKNOWN7
00347   {8,   8,   8}, // BACKSPACE = 8
00348   {18,  9,   9}, // TAB = 9
00349   {0,   0,   0}, // UNKNOWN10
00350   {0,   0,   0}, // UNKNOWN11
00351   {0,  12,   0}, // CLEAR = 12
00352   {13, 13,  13}, // ENTER = 13
00353   {0,   0,   0}, // UNKNOWN14
00354   {0,   0,   0}, // UNKNOWN15
00355   {0,  16,   0}, // SHIFT = 16
00356   {0,  17,   0}, // CONTROL = 17
00357   {0,  18,   0}, // ALT = 18
00358   {0,  19,   0}, // PAUSE = 19
00359   {0,  20,   0}, // CAPSLOCK = 20
00360   {0,   0,   0}, // UNKNOWN21
00361   {0,   0,   0}, // UNKNOWN22
00362   {0,   0,   0}, // UNKNOWN23
00363   {0,   0,   0}, // UNKNOWN24
00364   {0,   0,   0}, // UNKNOWN25 
00365   {0,   0,   0}, // UNKNOWN26
00366   {19, 27,  27}, // ESCAPE = 27
00367   {0,   0,   0}, // UNKNOWN28
00368   {0,   0,   0}, // UNKNOWN29
00369   {0,   0,   0}, // UNKNOWN30
00370   {0,   0,   0}, // UNKNOWN31
00371   {32, 32,  32}, // SPACE = 32
00372   {33, 49,  33}, // EXCLAM = 33
00373   {34, 222,  34}, // DOUBLE_QUOTE = 34
00374   {35, 51,  35}, // HASH = 35
00375   {36, 52,  36}, // DOLLAR = 36
00376   {37, 53,  37}, // PERCENT = 37
00377   {38, 55,  38}, // AMPERSAND = 38 
00378   {39, 222,  39}, // SINGLE_QUOTE  = 39
00379   {40, 57,  40}, // PAREN_LEFT = 40
00380   {41, 48,  41}, // PAREN_RIGHT = 41
00381   {42, 56,  42}, // ASTERISK = 42
00382   {43, 187,  43}, // PLUS = 43
00383   {44, 188,  44}, // COMMA = 44
00384   {45, 189,  45}, // MINUS = 45
00385   {46, 190,  46}, // PERIOD = 46
00386   {47, 191,  47}, // SLASH = 47
00387   {48, 48,  48}, // 0 = 48
00388   {49, 49,  49}, // 1
00389   {50, 50,  50}, // 2
00390   {51, 51,  51}, // 3
00391   {52, 52,  52}, // 4
00392   {53, 53,  53}, // 5
00393   {54, 54,  54}, // 6
00394   {55, 55,  55}, // 7
00395   {56, 56,  56}, // 8
00396   {57, 57,  57}, // 9 = 57
00397   {58, 186,  58}, // COLON = 58
00398   {59, 186,  59}, // SEMICOLON = 59
00399   {60, 188,  60}, // LESS = 60
00400   {61, 187,  61}, // EQUALS = 61
00401   {62, 190,  62}, // MORE = 62
00402   {63, 191,  63}, // QUESTION = 63
00403   {64, 50,  64}, // AT = 64
00404   {65, 65,  65}, // A = 65
00405   {66, 66,  66}, // B
00406   {67, 67,  67}, // C
00407   {68, 68,  68}, // D
00408   {69, 69,  69}, // E
00409   {70, 70,  70}, // F
00410   {71, 71,  71}, // G
00411   {72, 72,  72}, // H
00412   {73, 73,  73}, // I
00413   {74, 74,  74}, // J
00414   {75, 75,  75}, // K
00415   {76, 76,  76}, // L
00416   {77, 77,  77}, // M
00417   {78, 78,  78}, // N
00418   {79, 79,  79}, // O
00419   {80, 80,  80}, // P
00420   {81, 81,  81}, // Q
00421   {82, 82,  82}, // R
00422   {83, 83,  83}, // S
00423   {84, 84,  84}, // T
00424   {85, 85,  85}, // U
00425   {86, 86,  86}, // V
00426   {87, 87,  87}, // W
00427   {88, 88,  88}, // X
00428   {89, 89,  89}, // Y
00429   {90, 90,  90}, // Z = 90
00430   {91, 219,  91}, // LEFT_BRACKET = 91
00431   {92, 220,  92}, // BACKSLASH = 92
00432   {93, 221,  93}, // RIGHT_BRACKET = 93
00433   {94, 54,  94}, // CARET = 94
00434   {95, 189,  95}, // UNDERSCORE = 95
00435   {96, 192,  96}, // BACKQUOTE = 96
00436   {97, 65,  97}, // a = 97
00437   {98, 66,  98}, // b
00438   {99, 67,  99}, // c
00439   {100,68, 100}, // d
00440   {101,69, 101}, // e
00441   {102,70, 102}, // f
00442   {103,71, 103}, // g
00443   {104,72, 104}, // h
00444   {105,73, 105}, // i
00445   {106,74, 106}, // j
00446   {107,75, 107}, // k
00447   {108,76, 108}, // l
00448   {109,77, 109}, // m
00449   {110,78, 110}, // n
00450   {111,79, 111}, // o
00451   {112,80, 112}, // p
00452   {113,81, 113}, // q
00453   {114,82, 114}, // r
00454   {115,83, 115}, // s
00455   {116,84, 116}, // t
00456   {117,85, 117}, // u
00457   {118,86, 118}, // v
00458   {119,87, 119}, // w
00459   {120,88, 120}, // x
00460   {121,89, 121}, // y
00461   {122,90, 122}, // z = 122
00462   {123,219,123}, // LEFT_BRACE = 123
00463   {124,220,124}, // PIPE = 124
00464   {125,221,125}, // RIGHT_BRACE = 125
00465   {126,192,126}, // ASCIITILDE = 126
00466   {6,  46, 127}, // DELETE = 127
00467   {48, 96,  48}, // KP_0 = 128
00468   {49, 97,  49}, // KP_1
00469   {50, 98,  50}, // KP_2
00470   {51, 99,  51}, // KP_3
00471   {52, 100, 52}, // KP_4
00472   {53, 101, 53}, // KP_5
00473   {54, 102, 54}, // KP_6
00474   {55, 103, 55}, // KP_7
00475   {56, 104, 56}, // KP_8
00476   {57, 105, 57}, // KP_9
00477   {0,  112,  0}, // F1 = 138
00478   {0,  113,  0}, // F2
00479   {0,  114,  0}, // F3
00480   {0,  115,  0}, // F4
00481   {0,  116,  0}, // F5
00482   {0,  117,  0}, // F6
00483   {0,  118,  0}, // F7
00484   {0,  119,  0}, // F8
00485   {0,  120,  0}, // F9
00486   {0,  121,  0}, // F10
00487   {0,  122,  0}, // F11
00488   {0,  123,  0}, // F12
00489   {0,  124,  0}, // F13
00490   {0,  125,  0}, // F14
00491   {0,  126,  0}, // F15 = 152
00492   {14, 38,   0}, // UP = 153
00493   {15, 40,   0}, // DOWN = 154
00494   {2,  39,   0}, // RIGHT = 155
00495   {1,  37,   0}, // LEFT = 156
00496   {5,  45,   0}, // INSERT = 157
00497   {3,  36,   0}, // HOME = 158
00498   {4,  35,   0}, // END = 159
00499   {16, 33,   0}, // PAGEUP = 160
00500   {17, 34,   0}, // PAGEDOWN = 161
00501   {0, 107,  43}, // KP_ADD = 162
00502   {0, 109,  45}, // KP_SUBTRACT = 163
00503   {0, 106,  42}, // KP_MULITPLY = 164
00504   {0, 111,  47}, // KP_DIVIDE = 165
00505   {0, 110,  46}, // KP_DECIMAL = 166
00506   {13, 13,  13}, // KP_ENTER = 167
00507   {0, 144,   0}, // NUMLOCK = 168
00508   {0, 160,   160}, // NOBREAKSPACE = 169
00509   {0, 161,   161}, //   EXCLAM_DOWN = 170
00510   {0, 162,   162}, //   CENT = 171
00511   {0, 163,   163}, //   STERLING = 172
00512   {0, 164,   164}, //   CURRENCY = 173
00513   {0, 165,   165}, //   YEN = 174
00514   {0, 166,   166}, //   BROKENBAR = 175
00515   {0, 167,   167}, //   SECTION = 176
00516   {0, 168,   168}, //   DIAERESIS = 177
00517   {0, 169,   169}, //   COPYRIGHT = 178
00518   {0, 170,   170}, //   ORDFEMININE = 179
00519   {0, 171,   171}, //   GUILLEMOTLEFT = 180
00520   {0, 172,   172}, //   NOTSIGN = 181
00521   {0, 173,   173}, //   HYPHEN = 182
00522   {0, 174,   174}, //   REGISTERED = 183
00523   {0, 175,   175}, //   MACRON = 184
00524   {0, 176,   176}, //   DEGREE = 185
00525   {0, 177,   177}, //   PLUSMINUS = 186
00526   {0, 178,   178}, //   TWOSUPERIOR = 187
00527   {0, 179,   179}, //   THREESUPERIOR = 188
00528   {0, 180,   180}, //   ACUTE = 189
00529   {0, 181,   181}, //   MU = 190
00530   {0, 182,   182}, //   PARAGRAPH = 191
00531   {0, 183,   183}, //   PERIODCENTRED = 192
00532   {0, 184,   184}, //   CEDILLA = 193
00533   {0, 185,   185}, //   ONESUPERIOR = 194
00534   {0, 186,   186}, //   MASCULINE = 195
00535   {0, 187,   187}, //   GUILLEMOTRIGHT = 196
00536   {0, 188,   188}, //   ONEQUARTER = 197
00537   {0, 189,   189}, //   ONEHALF = 198
00538   {0, 190,   190}, //   THREEQUARTERS = 199
00539   {0, 191,   191}, //   QUESTIONDOWN = 200
00540   {0, 192,   192}, //   AGRAVE = 201
00541   {0, 193,   193}, //   AACUTE = 202
00542   {0, 194,   194}, //   ACIRCUMFLEX = 203
00543   {0, 195,   195}, //   ATILDE = 204
00544   {0, 196,   196}, //   ADIAERISIS = 205
00545   {0, 197,   197}, //   ARING = 206
00546   {0, 198,   198}, //   AE = 207
00547   {0, 199,   199}, //   CCEDILLA = 208
00548   {0, 200,   200}, //   EGRAVE = 209
00549   {0, 201,   201}, //   EACUTE = 210
00550   {0, 202,   202}, //   ECIRCUMFLEX = 211
00551   {0, 203,   203}, //   EDIAERESIS = 212
00552   {0, 204,   204}, //   IGRAVE = 213
00553   {0, 205,   205}, //   IACUTE = 214
00554   {0, 206,   206}, //   ICIRCUMFLEX = 215
00555   {0, 207,   207}, //   IDIAERESIS = 216
00556   {0, 208,   208}, //   ETH = 217
00557   {0, 209,   209}, //   NTILDE = 218
00558   {0, 210,   210}, //   OGRAVE = 219
00559   {0, 211,   211}, //   OACUTE = 220
00560   {0, 212,   212}, //   OCIRCUMFLEX = 221
00561   {0, 213,   213}, //   OTILDE = 222
00562   {0, 214,   214}, //   ODIAERESIS = 223
00563   {0, 215,   215}, //   MULTIPLY = 224
00564   {0, 216,   116}, //   OSLASH = 225
00565   {0, 217,   217}, //   UGRAVE = 226
00566   {0, 218,   218}, //   UACTUE = 227
00567   {0, 219,   219}, //   UCIRCUMFLEX = 228
00568   {0, 220,   220}, //   UDIAERESIS = 229
00569   {0, 221,   221}, //   ZACUTE = 230
00570   {0, 222,   222}, //   THORN = 231
00571   {0, 223,   223}, //   sSHARP = 232
00572   {0, 224,   224}, //   aTILDE = 233
00573   {0, 225,   225}, //   aACUTE = 234
00574   {0, 226,   226}, //   aCIRCUMFLEX = 235
00575   {0, 227,   227}, //   aTILDE = 236
00576   {0, 228,   228}, //   aDIAERESIS = 237
00577   {0, 229,   229}, //   aRING = 238
00578   {0, 230,   230}, //   ae = 239
00579   {0, 231,   231}, //   cCEDILLA = 240
00580   {0, 232,   232}, //   eGRAVE = 241
00581   {0, 233,   233}, //   eACUTE = 242
00582   {0, 234,   234}, //   eCIRCUMFLEX = 243
00583   {0, 235,   235}, //   eDIAERESIS = 244
00584   {0, 236,   236}, //   iGRAVE = 245
00585   {0, 237,   237}, //   iACUTE = 246
00586   {0, 238,   238}, //   iCIRCUMFLEX = 247
00587   {0, 239,   239}, //   iDIAERESIS = 248
00588   {0, 240,   240}, //   eth = 249
00589   {0, 241,   241}, //   nTILDE = 250
00590   {0, 242,   242}, //   oTILDE = 251
00591   {0, 243,   243}, //   oACUTE = 252
00592   {0, 244,   244}, //   oCIRCUMFLEX = 253
00593   {0, 245,   245}, //   oTILDE = 254
00594   {0, 246,   246}, //   oDIAERESIS = 255
00595   {0, 247,   247}, //   DIVISION = 256
00596   {0, 248,   248}, //   oSLASH = 257
00597   {0, 249,   249}, //   uGRAVE = 258
00598   {0, 250,   250}, //   uACUTE = 259
00599   {0, 251,   251}, //   uCIRCUMFLEX = 260 
00600   {0, 252,   252}, //   uDIAERESIS = 261
00601   {0, 253,   253}, //   yACUTE = 262
00602   {0, 254,   254}, //   thorn = 263
00603   {0, 255,   255}, //   yDIAERESIS = 264
00604   {0, 0,     0},   //   HELP (untested)
00605 };
00606 
00607 }   // end namespace key
00608 
00609 } // end namespace gnash
00610 
00611 #endif // GNASHKEY_H