| OLD | NEW |
| (Empty) | |
| 1 // WindowsKeyCodeForKeyEvent is taken from |
| 2 // WebKit/WebCore/platform/gtk/KeyEventGtk.cpp |
| 3 /* |
| 4 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 5 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com |
| 6 * Copyright (C) 2007 Holger Hans Peter Freyther |
| 7 * Copyright (C) 2008 Collabora, Ltd. All rights reserved. |
| 8 * All rights reserved. |
| 9 * |
| 10 * Redistribution and use in source and binary forms, with or without |
| 11 * modification, are permitted provided that the following conditions |
| 12 * are met: |
| 13 * 1. Redistributions of source code must retain the above copyright |
| 14 * notice, this list of conditions and the following disclaimer. |
| 15 * 2. Redistributions in binary form must reproduce the above copyright |
| 16 * notice, this list of conditions and the following disclaimer in the |
| 17 * documentation and/or other materials provided with the distribution. |
| 18 * |
| 19 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 27 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 */ |
| 31 |
| 32 #include "KeyCodeConversion.h" |
| 33 #include "KeyboardCodes.h" |
| 34 |
| 35 #include <gdk/gdkkeysyms.h> |
| 36 |
| 37 namespace WebCore { |
| 38 |
| 39 int windowsKeyCodeForKeyEvent(unsigned int keycode) |
| 40 { |
| 41 switch (keycode) { |
| 42 case GDK_KP_0: |
| 43 return VK_NUMPAD0;// (60) Numeric keypad 0 key |
| 44 case GDK_KP_1: |
| 45 return VK_NUMPAD1;// (61) Numeric keypad 1 key |
| 46 case GDK_KP_2: |
| 47 return VK_NUMPAD2; // (62) Numeric keypad 2 key |
| 48 case GDK_KP_3: |
| 49 return VK_NUMPAD3; // (63) Numeric keypad 3 key |
| 50 case GDK_KP_4: |
| 51 return VK_NUMPAD4; // (64) Numeric keypad 4 key |
| 52 case GDK_KP_5: |
| 53 return VK_NUMPAD5; //(65) Numeric keypad 5 key |
| 54 case GDK_KP_6: |
| 55 return VK_NUMPAD6; // (66) Numeric keypad 6 key |
| 56 case GDK_KP_7: |
| 57 return VK_NUMPAD7; // (67) Numeric keypad 7 key |
| 58 case GDK_KP_8: |
| 59 return VK_NUMPAD8; // (68) Numeric keypad 8 key |
| 60 case GDK_KP_9: |
| 61 return VK_NUMPAD9; // (69) Numeric keypad 9 key |
| 62 case GDK_KP_Multiply: |
| 63 return VK_MULTIPLY; // (6A) Multiply key |
| 64 case GDK_KP_Add: |
| 65 return VK_ADD; // (6B) Add key |
| 66 case GDK_KP_Subtract: |
| 67 return VK_SUBTRACT; // (6D) Subtract key |
| 68 case GDK_KP_Decimal: |
| 69 return VK_DECIMAL; // (6E) Decimal key |
| 70 case GDK_KP_Divide: |
| 71 return VK_DIVIDE; // (6F) Divide key |
| 72 |
| 73 case GDK_BackSpace: |
| 74 return VK_BACK; // (08) BACKSPACE key |
| 75 case GDK_ISO_Left_Tab: |
| 76 case GDK_3270_BackTab: |
| 77 case GDK_Tab: |
| 78 return VK_TAB; // (09) TAB key |
| 79 case GDK_Clear: |
| 80 return VK_CLEAR; // (0C) CLEAR key |
| 81 case GDK_ISO_Enter: |
| 82 case GDK_KP_Enter: |
| 83 case GDK_Return: |
| 84 return VK_RETURN; //(0D) Return key |
| 85 case GDK_Shift_L: |
| 86 case GDK_Shift_R: |
| 87 return VK_SHIFT; // (10) SHIFT key |
| 88 case GDK_Control_L: |
| 89 case GDK_Control_R: |
| 90 return VK_CONTROL; // (11) CTRL key |
| 91 case GDK_Menu: |
| 92 case GDK_Alt_L: |
| 93 case GDK_Alt_R: |
| 94 return VK_MENU; // (12) ALT key |
| 95 |
| 96 case GDK_Pause: |
| 97 return VK_PAUSE; // (13) PAUSE key |
| 98 case GDK_Caps_Lock: |
| 99 return VK_CAPITAL; // (14) CAPS LOCK key |
| 100 case GDK_Kana_Lock: |
| 101 case GDK_Kana_Shift: |
| 102 return VK_KANA; // (15) Input Method Editor (IME) Kana mode |
| 103 case GDK_Hangul: |
| 104 return VK_HANGUL; // VK_HANGUL (15) IME Hangul mode |
| 105 // VK_JUNJA (17) IME Junja mode |
| 106 // VK_FINAL (18) IME final mode |
| 107 case GDK_Hangul_Hanja: |
| 108 return VK_HANJA; // (19) IME Hanja mode |
| 109 case GDK_Kanji: |
| 110 return VK_KANJI; // (19) IME Kanji mode |
| 111 case GDK_Escape: |
| 112 return VK_ESCAPE; // (1B) ESC key |
| 113 // VK_CONVERT (1C) IME convert |
| 114 // VK_NONCONVERT (1D) IME nonconvert |
| 115 // VK_ACCEPT (1E) IME accept |
| 116 // VK_MODECHANGE (1F) IME mode change request |
| 117 case GDK_space: |
| 118 return VK_SPACE; // (20) SPACEBAR |
| 119 case GDK_Page_Up: |
| 120 return VK_PRIOR; // (21) PAGE UP key |
| 121 case GDK_Page_Down: |
| 122 return VK_NEXT; // (22) PAGE DOWN key |
| 123 case GDK_End: |
| 124 return VK_END; // (23) END key |
| 125 case GDK_Home: |
| 126 return VK_HOME; // (24) HOME key |
| 127 case GDK_Left: |
| 128 return VK_LEFT; // (25) LEFT ARROW key |
| 129 case GDK_Up: |
| 130 return VK_UP; // (26) UP ARROW key |
| 131 case GDK_Right: |
| 132 return VK_RIGHT; // (27) RIGHT ARROW key |
| 133 case GDK_Down: |
| 134 return VK_DOWN; // (28) DOWN ARROW key |
| 135 case GDK_Select: |
| 136 return VK_SELECT; // (29) SELECT key |
| 137 case GDK_Print: |
| 138 return VK_PRINT; // (2A) PRINT key |
| 139 case GDK_Execute: |
| 140 return VK_EXECUTE;// (2B) EXECUTE key |
| 141 //dunno on this |
| 142 //case GDK_PrintScreen: |
| 143 // return VK_SNAPSHOT; // (2C) PRINT SCREEN key |
| 144 case GDK_Insert: |
| 145 return VK_INSERT; // (2D) INS key |
| 146 case GDK_Delete: |
| 147 return VK_DELETE; // (2E) DEL key |
| 148 case GDK_Help: |
| 149 return VK_HELP; // (2F) HELP key |
| 150 case GDK_0: |
| 151 case GDK_parenleft: |
| 152 return VK_0; // (30) 0) key |
| 153 case GDK_1: |
| 154 return VK_1; // (31) 1 ! key |
| 155 case GDK_2: |
| 156 case GDK_at: |
| 157 return VK_2; // (32) 2 & key |
| 158 case GDK_3: |
| 159 case GDK_numbersign: |
| 160 return VK_3; //case '3': case '#'; |
| 161 case GDK_4: |
| 162 case GDK_dollar: // (34) 4 key '$'; |
| 163 return VK_4; |
| 164 case GDK_5: |
| 165 case GDK_percent: |
| 166 return VK_5; // (35) 5 key '%' |
| 167 case GDK_6: |
| 168 case GDK_asciicircum: |
| 169 return VK_6; // (36) 6 key '^' |
| 170 case GDK_7: |
| 171 case GDK_ampersand: |
| 172 return VK_7; // (37) 7 key case '&' |
| 173 case GDK_8: |
| 174 case GDK_asterisk: |
| 175 return VK_8; // (38) 8 key '*' |
| 176 case GDK_9: |
| 177 case GDK_parenright: |
| 178 return VK_9; // (39) 9 key '(' |
| 179 case GDK_a: |
| 180 case GDK_A: |
| 181 return VK_A; // (41) A key case 'a': case 'A': return 0x41; |
| 182 case GDK_b: |
| 183 case GDK_B: |
| 184 return VK_B; // (42) B key case 'b': case 'B': return 0x42; |
| 185 case GDK_c: |
| 186 case GDK_C: |
| 187 return VK_C; // (43) C key case 'c': case 'C': return 0x43; |
| 188 case GDK_d: |
| 189 case GDK_D: |
| 190 return VK_D; // (44) D key case 'd': case 'D': return 0x44; |
| 191 case GDK_e: |
| 192 case GDK_E: |
| 193 return VK_E; // (45) E key case 'e': case 'E': return 0x45; |
| 194 case GDK_f: |
| 195 case GDK_F: |
| 196 return VK_F; // (46) F key case 'f': case 'F': return 0x46; |
| 197 case GDK_g: |
| 198 case GDK_G: |
| 199 return VK_G; // (47) G key case 'g': case 'G': return 0x47; |
| 200 case GDK_h: |
| 201 case GDK_H: |
| 202 return VK_H; // (48) H key case 'h': case 'H': return 0x48; |
| 203 case GDK_i: |
| 204 case GDK_I: |
| 205 return VK_I; // (49) I key case 'i': case 'I': return 0x49; |
| 206 case GDK_j: |
| 207 case GDK_J: |
| 208 return VK_J; // (4A) J key case 'j': case 'J': return 0x4A; |
| 209 case GDK_k: |
| 210 case GDK_K: |
| 211 return VK_K; // (4B) K key case 'k': case 'K': return 0x4B; |
| 212 case GDK_l: |
| 213 case GDK_L: |
| 214 return VK_L; // (4C) L key case 'l': case 'L': return 0x4C; |
| 215 case GDK_m: |
| 216 case GDK_M: |
| 217 return VK_M; // (4D) M key case 'm': case 'M': return 0x4D; |
| 218 case GDK_n: |
| 219 case GDK_N: |
| 220 return VK_N; // (4E) N key case 'n': case 'N': return 0x4E; |
| 221 case GDK_o: |
| 222 case GDK_O: |
| 223 return VK_O; // (4F) O key case 'o': case 'O': return 0x4F; |
| 224 case GDK_p: |
| 225 case GDK_P: |
| 226 return VK_P; // (50) P key case 'p': case 'P': return 0x50; |
| 227 case GDK_q: |
| 228 case GDK_Q: |
| 229 return VK_Q; // (51) Q key case 'q': case 'Q': return 0x51; |
| 230 case GDK_r: |
| 231 case GDK_R: |
| 232 return VK_R; // (52) R key case 'r': case 'R': return 0x52; |
| 233 case GDK_s: |
| 234 case GDK_S: |
| 235 return VK_S; // (53) S key case 's': case 'S': return 0x53; |
| 236 case GDK_t: |
| 237 case GDK_T: |
| 238 return VK_T; // (54) T key case 't': case 'T': return 0x54; |
| 239 case GDK_u: |
| 240 case GDK_U: |
| 241 return VK_U; // (55) U key case 'u': case 'U': return 0x55; |
| 242 case GDK_v: |
| 243 case GDK_V: |
| 244 return VK_V; // (56) V key case 'v': case 'V': return 0x56; |
| 245 case GDK_w: |
| 246 case GDK_W: |
| 247 return VK_W; // (57) W key case 'w': case 'W': return 0x57; |
| 248 case GDK_x: |
| 249 case GDK_X: |
| 250 return VK_X; // (58) X key case 'x': case 'X': return 0x58; |
| 251 case GDK_y: |
| 252 case GDK_Y: |
| 253 return VK_Y; // (59) Y key case 'y': case 'Y': return 0x59; |
| 254 case GDK_z: |
| 255 case GDK_Z: |
| 256 return VK_Z; // (5A) Z key case 'z': case 'Z': return 0x5A; |
| 257 case GDK_Meta_L: |
| 258 return VK_LWIN; // (5B) Left Windows key (Microsoft Natural keyboard
) |
| 259 case GDK_Meta_R: |
| 260 return VK_RWIN; // (5C) Right Windows key (Natural keyboard) |
| 261 // VK_APPS (5D) Applications key (Natural keyboard) |
| 262 // VK_SLEEP (5F) Computer Sleep key |
| 263 // VK_SEPARATOR (6C) Separator key |
| 264 // VK_SUBTRACT (6D) Subtract key |
| 265 // VK_DECIMAL (6E) Decimal key |
| 266 // VK_DIVIDE (6F) Divide key |
| 267 // handled by key code above |
| 268 |
| 269 case GDK_Num_Lock: |
| 270 return VK_NUMLOCK; // (90) NUM LOCK key |
| 271 |
| 272 case GDK_Scroll_Lock: |
| 273 return VK_SCROLL; // (91) SCROLL LOCK key |
| 274 |
| 275 // VK_LSHIFT (A0) Left SHIFT key |
| 276 // VK_RSHIFT (A1) Right SHIFT key |
| 277 // VK_LCONTROL (A2) Left CONTROL key |
| 278 // VK_RCONTROL (A3) Right CONTROL key |
| 279 // VK_LMENU (A4) Left MENU key |
| 280 // VK_RMENU (A5) Right MENU key |
| 281 // VK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key |
| 282 // VK_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key |
| 283 // VK_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key |
| 284 // VK_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key |
| 285 // VK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key |
| 286 // VK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key |
| 287 // VK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key |
| 288 // VK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key |
| 289 // VK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key |
| 290 // VK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key |
| 291 // VK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key |
| 292 // VK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key |
| 293 // VK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key |
| 294 // VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key |
| 295 // VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key |
| 296 // VK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key |
| 297 // VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key |
| 298 // VK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key |
| 299 |
| 300 // VK_OEM_1 (BA) Used for miscellaneous characters; it can vary by k
eyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key |
| 301 case GDK_semicolon: |
| 302 case GDK_colon: |
| 303 return VK_OEM_1; //case ';': case ':': return 0xBA; |
| 304 // VK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+'
key |
| 305 case GDK_plus: |
| 306 case GDK_equal: |
| 307 return VK_OEM_PLUS; //case '=': case '+': return 0xBB; |
| 308 // VK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',
' key |
| 309 case GDK_comma: |
| 310 case GDK_less: |
| 311 return VK_OEM_COMMA; //case ',': case '<': return 0xBC; |
| 312 // VK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-
' key |
| 313 case GDK_minus: |
| 314 case GDK_underscore: |
| 315 return VK_OEM_MINUS; //case '-': case '_': return 0xBD; |
| 316 // VK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '
.' key |
| 317 case GDK_period: |
| 318 case GDK_greater: |
| 319 return VK_OEM_PERIOD; //case '.': case '>': return 0xBE; |
| 320 // VK_OEM_2 (BF) Used for miscellaneous characters; it can vary by k
eyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key |
| 321 case GDK_slash: |
| 322 case GDK_question: |
| 323 return VK_OEM_2; //case '/': case '?': return 0xBF; |
| 324 // VK_OEM_3 (C0) Used for miscellaneous characters; it can vary by k
eyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key |
| 325 case GDK_asciitilde: |
| 326 case GDK_quoteleft: |
| 327 return VK_OEM_3; //case '`': case '~': return 0xC0; |
| 328 // VK_OEM_4 (DB) Used for miscellaneous characters; it can vary by k
eyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key |
| 329 case GDK_bracketleft: |
| 330 case GDK_braceleft: |
| 331 return VK_OEM_4; //case '[': case '{': return 0xDB; |
| 332 // VK_OEM_5 (DC) Used for miscellaneous characters; it can vary by k
eyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key |
| 333 case GDK_backslash: |
| 334 case GDK_bar: |
| 335 return VK_OEM_5; //case '\\': case '|': return 0xDC; |
| 336 // VK_OEM_6 (DD) Used for miscellaneous characters; it can vary by k
eyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key |
| 337 case GDK_bracketright: |
| 338 case GDK_braceright: |
| 339 return VK_OEM_6; // case ']': case '}': return 0xDD; |
| 340 // VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by k
eyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double
-quote' key |
| 341 case GDK_quoteright: |
| 342 case GDK_quotedbl: |
| 343 return VK_OEM_7; // case '\'': case '"': return 0xDE; |
| 344 // VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by k
eyboard. |
| 345 // VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or
the backslash key on the RT 102-key keyboard |
| 346 // VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000
/XP: IME PROCESS key |
| 347 // VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters a
s if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual
Key value used for non-keyboard input methods. For more information, see Remark
in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP |
| 348 // VK_ATTN (F6) Attn key |
| 349 // VK_CRSEL (F7) CrSel key |
| 350 // VK_EXSEL (F8) ExSel key |
| 351 // VK_EREOF (F9) Erase EOF key |
| 352 // VK_PLAY (FA) Play key |
| 353 // VK_ZOOM (FB) Zoom key |
| 354 // VK_NONAME (FC) Reserved for future use |
| 355 // VK_PA1 (FD) PA1 key |
| 356 // VK_OEM_CLEAR (FE) Clear key |
| 357 default: |
| 358 return 0; |
| 359 } |
| 360 |
| 361 } |
| 362 |
| 363 } |
| OLD | NEW |