OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" |
| 6 |
| 7 #include <algorithm> |
| 8 |
| 9 #include "base/strings/string16.h" |
| 10 #include "ui/events/event.h" |
| 11 #include "ui/events/keycodes/dom3/dom_code.h" |
| 12 #include "ui/events/keycodes/dom3/dom_key.h" |
| 13 #include "ui/events/keycodes/keyboard_code_conversion.h" |
| 14 |
| 15 namespace ui { |
| 16 |
| 17 namespace { |
| 18 |
| 19 // All of the characters have low ordinals, so we use bit 15 to flag dead keys. |
| 20 #define DK 0x8000 |
| 21 |
| 22 const struct PrintableCodeEntry { |
| 23 DomCode dom_code; |
| 24 base::char16 character[4]; |
| 25 } printable_code_map[] = { |
| 26 // Stub table based on X US international. |
| 27 {DomCode::KEY_A, {'a', 'A', 0x00E1, 0x00C1}}, |
| 28 {DomCode::KEY_B, {'b', 'B', 'b', 'B'}}, |
| 29 {DomCode::KEY_C, {'c', 'C', 0x00A9, 0x00A2}}, |
| 30 {DomCode::KEY_D, {'d', 'D', 0x00F0, 0x00D0}}, |
| 31 {DomCode::KEY_E, {'e', 'E', 0x00E9, 0x00C9}}, |
| 32 {DomCode::KEY_F, {'f', 'F', 'f', 'F'}}, |
| 33 {DomCode::KEY_G, {'g', 'G', 'g', 'G'}}, |
| 34 {DomCode::KEY_H, {'h', 'H', 'h', 'H'}}, |
| 35 {DomCode::KEY_I, {'i', 'I', 0x00ED, 0x00CD}}, |
| 36 {DomCode::KEY_J, {'j', 'J', 'j', 'J'}}, |
| 37 {DomCode::KEY_K, {'k', 'K', 0x0153, 0x0152}}, |
| 38 {DomCode::KEY_L, {'l', 'L', 0x00F8, 0x00D8}}, |
| 39 {DomCode::KEY_M, {'m', 'M', 0x00B5, 0x00B5}}, |
| 40 {DomCode::KEY_N, {'n', 'N', 0x00F1, 0x00D1}}, |
| 41 {DomCode::KEY_O, {'o', 'O', 0x00F3, 0x00D3}}, |
| 42 {DomCode::KEY_P, {'p', 'P', 0x00F6, 0x00D6}}, |
| 43 {DomCode::KEY_Q, {'q', 'Q', 0x00E4, 0x00C4}}, |
| 44 {DomCode::KEY_R, {'r', 'R', 0x00AE, 0x00AE}}, |
| 45 {DomCode::KEY_S, {'s', 'S', 0x00DF, 0x00A7}}, |
| 46 {DomCode::KEY_T, {'t', 'T', 0x00FE, 0x00DE}}, |
| 47 {DomCode::KEY_U, {'u', 'U', 0x00FA, 0x00DA}}, |
| 48 {DomCode::KEY_V, {'v', 'V', 'v', 'V'}}, |
| 49 {DomCode::KEY_W, {'w', 'W', 0x00E5, 0x00C5}}, |
| 50 {DomCode::KEY_X, {'x', 'X', 'x', 'X'}}, |
| 51 {DomCode::KEY_Y, {'y', 'Y', 0x00FC, 0x00DC}}, |
| 52 {DomCode::KEY_Z, {'z', 'Z', 0x00E6, 0x00C6}}, |
| 53 {DomCode::DIGIT1, {'1', '!', 0x00A1, 0x00B9}}, |
| 54 {DomCode::DIGIT2, {'2', '@', 0x00B2, DK|0x030B}}, |
| 55 {DomCode::DIGIT3, {'3', '#', 0x00B3, DK|0x0304}}, |
| 56 {DomCode::DIGIT4, {'4', '$', 0x00A4, 0x00A3}}, |
| 57 {DomCode::DIGIT5, {'5', '%', 0x20AC, DK|0x0327}}, |
| 58 {DomCode::DIGIT6, {'6', '^', DK|0x0302, 0x00BC}}, |
| 59 {DomCode::DIGIT7, {'7', '&', 0x00BD, DK|0x031B}}, |
| 60 {DomCode::DIGIT8, {'8', '*', 0x00BE, DK|0x0328}}, |
| 61 {DomCode::DIGIT9, {'9', '(', 0x2018, DK|0x0306}}, |
| 62 {DomCode::DIGIT0, {'0', ')', 0x2019, DK|0x030A}}, |
| 63 {DomCode::SPACE, {' ', ' ', 0x00A0, 0x00A0}}, |
| 64 {DomCode::MINUS, {'-', '_', 0x00A5, DK|0x0323}}, |
| 65 {DomCode::EQUAL, {'=', '+', 0x00D7, 0x00F7}}, |
| 66 {DomCode::BRACKET_LEFT, {'[', '{', 0x00AB, 0x201C}}, |
| 67 {DomCode::BRACKET_RIGHT, {']', '}', 0x00BB, 0x201D}}, |
| 68 {DomCode::BACKSLASH, {'\\', '|', 0x00AC, 0x00A6}}, |
| 69 {DomCode::SEMICOLON, {';', ':', 0x00B6, 0x00B0}}, |
| 70 {DomCode::QUOTE, {'\'', '"', DK|0x0301, DK|0x0308}}, |
| 71 {DomCode::BACKQUOTE, {'`', '~', DK|0x0300, DK|0x0303}}, |
| 72 {DomCode::COMMA, {',', '<', 0x00E7, 0x00C7}}, |
| 73 {DomCode::PERIOD, {'.', '>', DK|0x0307, DK|0x030C}}, |
| 74 {DomCode::SLASH, {'/', '?', 0x00BF, DK|0x0309}}, |
| 75 {DomCode::INTL_BACKSLASH, {'\\', '|', '\\', '|'}}, |
| 76 {DomCode::INTL_YEN, {0x00A5, '|', 0x00A5, '|'}}, |
| 77 {DomCode::NUMPAD_DIVIDE, {'/', '/', '/', '/'}}, |
| 78 {DomCode::NUMPAD_MULTIPLY, {'*', '*', '*', '*'}}, |
| 79 {DomCode::NUMPAD_SUBTRACT, {'-', '-', '-', '-'}}, |
| 80 {DomCode::NUMPAD_ADD, {'+', '+', '+', '+'}}, |
| 81 {DomCode::NUMPAD1, {'1', '1', '1', '1'}}, |
| 82 {DomCode::NUMPAD2, {'2', '2', '2', '2'}}, |
| 83 {DomCode::NUMPAD3, {'3', '3', '3', '3'}}, |
| 84 {DomCode::NUMPAD4, {'4', '4', '4', '4'}}, |
| 85 {DomCode::NUMPAD5, {'5', '5', '5', '5'}}, |
| 86 {DomCode::NUMPAD6, {'6', '6', '6', '6'}}, |
| 87 {DomCode::NUMPAD7, {'7', '7', '7', '7'}}, |
| 88 {DomCode::NUMPAD8, {'8', '8', '8', '8'}}, |
| 89 {DomCode::NUMPAD9, {'9', '9', '9', '9'}}, |
| 90 {DomCode::NUMPAD0, {'0', '0', '0', '0'}}, |
| 91 {DomCode::NUMPAD_DECIMAL, {'.', '.', '.', '.'}}, |
| 92 {DomCode::NUMPAD_EQUAL, {'=', '=', '=', '='}}, |
| 93 {DomCode::NUMPAD_COMMA, {',', ',', ',', ','}}, |
| 94 {DomCode::NUMPAD_PAREN_LEFT, {'(', '(', '(', '('}}, |
| 95 {DomCode::NUMPAD_PAREN_RIGHT, {')', ')', ')', ')'}}, |
| 96 {DomCode::NUMPAD_SIGN_CHANGE, {0x00B1, 0x00B1, 0x2213, 0x2213}}, |
| 97 }; |
| 98 |
| 99 const struct NonPrintableCodeEntry { |
| 100 DomCode dom_code; |
| 101 DomKey dom_key; |
| 102 base::char16 character; |
| 103 } non_printable_code_map[] = { |
| 104 {DomCode::ABORT, DomKey::CANCEL}, |
| 105 {DomCode::AGAIN, DomKey::AGAIN}, |
| 106 {DomCode::ALT_LEFT, DomKey::ALT}, |
| 107 {DomCode::ALT_RIGHT, DomKey::ALT}, |
| 108 {DomCode::ARROW_DOWN, DomKey::ARROW_DOWN}, |
| 109 {DomCode::ARROW_LEFT, DomKey::ARROW_LEFT}, |
| 110 {DomCode::ARROW_RIGHT, DomKey::ARROW_RIGHT}, |
| 111 {DomCode::ARROW_UP, DomKey::ARROW_UP}, |
| 112 {DomCode::BACKSPACE, DomKey::BACKSPACE, 0x0008}, |
| 113 {DomCode::BRIGHTNESS_DOWN, DomKey::BRIGHTNESS_DOWN}, |
| 114 {DomCode::BRIGHTNESS_UP, DomKey::BRIGHTNESS_UP}, |
| 115 // {DomCode::BRIGHTNESS_AUTO, DomKey::_} |
| 116 // {DomCode::BRIGHTNESS_MAXIMUM, DomKey::_} |
| 117 // {DomCode::BRIGHTNESS_MINIMIUM, DomKey::_} |
| 118 // {DomCode::BRIGHTNESS_TOGGLE, DomKey::_} |
| 119 {DomCode::BROWSER_BACK, DomKey::BROWSER_BACK}, |
| 120 {DomCode::BROWSER_FAVORITES, DomKey::BROWSER_FAVORITES}, |
| 121 {DomCode::BROWSER_FORWARD, DomKey::BROWSER_FORWARD}, |
| 122 {DomCode::BROWSER_HOME, DomKey::BROWSER_HOME}, |
| 123 {DomCode::BROWSER_REFRESH, DomKey::BROWSER_REFRESH}, |
| 124 {DomCode::BROWSER_SEARCH, DomKey::BROWSER_SEARCH}, |
| 125 {DomCode::BROWSER_STOP, DomKey::BROWSER_STOP}, |
| 126 {DomCode::CAPS_LOCK, DomKey::CAPS_LOCK}, |
| 127 {DomCode::CONTEXT_MENU, DomKey::CONTEXT_MENU}, |
| 128 {DomCode::CONTROL_LEFT, DomKey::CONTROL}, |
| 129 {DomCode::CONTROL_RIGHT, DomKey::CONTROL}, |
| 130 {DomCode::CONVERT, DomKey::CONVERT}, |
| 131 {DomCode::COPY, DomKey::COPY}, |
| 132 {DomCode::CUT, DomKey::CUT}, |
| 133 {DomCode::DEL, DomKey::DEL, 0x007F}, |
| 134 {DomCode::EJECT, DomKey::EJECT}, |
| 135 {DomCode::END, DomKey::END}, |
| 136 {DomCode::ENTER, DomKey::ENTER, 0x000D}, |
| 137 {DomCode::ESCAPE, DomKey::ESCAPE, 0x001B}, |
| 138 {DomCode::F1, DomKey::F1}, |
| 139 {DomCode::F2, DomKey::F2}, |
| 140 {DomCode::F3, DomKey::F3}, |
| 141 {DomCode::F4, DomKey::F4}, |
| 142 {DomCode::F5, DomKey::F5}, |
| 143 {DomCode::F6, DomKey::F6}, |
| 144 {DomCode::F7, DomKey::F7}, |
| 145 {DomCode::F8, DomKey::F8}, |
| 146 {DomCode::F9, DomKey::F9}, |
| 147 {DomCode::F10, DomKey::F10}, |
| 148 {DomCode::F11, DomKey::F11}, |
| 149 {DomCode::F12, DomKey::F12}, |
| 150 {DomCode::F13, DomKey::F13}, |
| 151 {DomCode::F14, DomKey::F14}, |
| 152 {DomCode::F15, DomKey::F15}, |
| 153 {DomCode::F16, DomKey::F16}, |
| 154 {DomCode::F17, DomKey::F17}, |
| 155 {DomCode::F18, DomKey::F18}, |
| 156 {DomCode::F19, DomKey::F19}, |
| 157 {DomCode::F20, DomKey::F20}, |
| 158 {DomCode::F21, DomKey::F21}, |
| 159 {DomCode::F22, DomKey::F22}, |
| 160 {DomCode::F23, DomKey::F23}, |
| 161 {DomCode::F24, DomKey::F24}, |
| 162 {DomCode::FIND, DomKey::FIND}, |
| 163 {DomCode::FN, DomKey::FN}, |
| 164 {DomCode::FN_LOCK, DomKey::FN_LOCK}, |
| 165 {DomCode::HELP, DomKey::HELP}, |
| 166 {DomCode::HOME, DomKey::HOME}, |
| 167 {DomCode::HYPER, DomKey::HYPER}, |
| 168 {DomCode::INSERT, DomKey::INSERT}, |
| 169 // {DomCode::INTL_RO, DomKey::_} |
| 170 {DomCode::KANA_MODE, DomKey::KANA_MODE}, |
| 171 {DomCode::LANG1, DomKey::HANGUL_MODE}, |
| 172 {DomCode::LANG2, DomKey::HANJA_MODE}, |
| 173 {DomCode::LANG3, DomKey::KATAKANA}, |
| 174 {DomCode::LANG4, DomKey::HIRAGANA}, |
| 175 {DomCode::LANG5, DomKey::ZENKAKU_HANKAKU}, |
| 176 {DomCode::LAUNCH_APP1, DomKey::LAUNCH_MY_COMPUTER}, |
| 177 {DomCode::LAUNCH_APP2, DomKey::LAUNCH_CALCULATOR}, |
| 178 {DomCode::LAUNCH_MAIL, DomKey::LAUNCH_MAIL}, |
| 179 {DomCode::LAUNCH_SCREEN_SAVER, DomKey::LAUNCH_SCREEN_SAVER}, |
| 180 // {DomCode::LAUNCH_DOCUMENTS, DomKey::_} |
| 181 // {DomCode::LAUNCH_FILE_BROWSER, DomKey::_} |
| 182 // {DomCode::LAUNCH_KEYBOARD_LAYOUT, DomKey::_} |
| 183 {DomCode::LOCK_SCREEN, DomKey::LAUNCH_SCREEN_SAVER}, |
| 184 {DomCode::MAIL_FORWARD, DomKey::MAIL_FORWARD}, |
| 185 {DomCode::MAIL_REPLY, DomKey::MAIL_REPLY}, |
| 186 {DomCode::MAIL_SEND, DomKey::MAIL_SEND}, |
| 187 {DomCode::MEDIA_PLAY_PAUSE, DomKey::MEDIA_PLAY_PAUSE}, |
| 188 {DomCode::MEDIA_SELECT, DomKey::MEDIA_SELECT}, |
| 189 {DomCode::MEDIA_STOP, DomKey::MEDIA_STOP}, |
| 190 {DomCode::MEDIA_TRACK_NEXT, DomKey::MEDIA_TRACK_NEXT}, |
| 191 {DomCode::MEDIA_TRACK_PREVIOUS, DomKey::MEDIA_TRACK_PREVIOUS}, |
| 192 // {DomCode::MENU, DomKey::_} |
| 193 {DomCode::NON_CONVERT, DomKey::NON_CONVERT}, |
| 194 {DomCode::NUM_LOCK, DomKey::NUM_LOCK}, |
| 195 {DomCode::NUMPAD_BACKSPACE, DomKey::BACKSPACE, 0x0008}, |
| 196 {DomCode::NUMPAD_CLEAR, DomKey::CLEAR}, |
| 197 {DomCode::NUMPAD_ENTER, DomKey::ENTER, 0x000D}, |
| 198 // {DomCode::NUMPAD_CLEAR_ENTRY, DomKey::_} |
| 199 // {DomCode::NUMPAD_MEMORY_ADD, DomKey::_} |
| 200 // {DomCode::NUMPAD_MEMORY_CLEAR, DomKey::_} |
| 201 // {DomCode::NUMPAD_MEMORY_RECALL, DomKey::_} |
| 202 // {DomCode::NUMPAD_MEMORY_STORE, DomKey::_} |
| 203 // {DomCode::NUMPAD_MEMORY_SUBTRACT, DomKey::_} |
| 204 {DomCode::OPEN, DomKey::OPEN}, |
| 205 {DomCode::OS_LEFT, DomKey::OS}, |
| 206 {DomCode::OS_RIGHT, DomKey::OS}, |
| 207 {DomCode::PAGE_DOWN, DomKey::PAGE_DOWN}, |
| 208 {DomCode::PAGE_UP, DomKey::PAGE_UP}, |
| 209 {DomCode::PASTE, DomKey::PASTE}, |
| 210 {DomCode::PAUSE, DomKey::PAUSE}, |
| 211 {DomCode::POWER, DomKey::POWER}, |
| 212 {DomCode::PRINT_SCREEN, DomKey::PRINT_SCREEN}, |
| 213 {DomCode::PROPS, DomKey::PROPS}, |
| 214 {DomCode::SCROLL_LOCK, DomKey::SCROLL_LOCK}, |
| 215 {DomCode::SELECT, DomKey::SELECT}, |
| 216 // {DomCode::SELECT_TASK, DomKey::_} |
| 217 {DomCode::SHIFT_LEFT, DomKey::SHIFT}, |
| 218 {DomCode::SHIFT_RIGHT, DomKey::SHIFT}, |
| 219 {DomCode::SUPER, DomKey::SUPER}, |
| 220 {DomCode::TAB, DomKey::TAB, 0x0009}, |
| 221 {DomCode::UNDO, DomKey::UNDO}, |
| 222 // {DomCode::VOICE_COMMAND, DomKey::_} |
| 223 {DomCode::VOLUME_DOWN, DomKey::VOLUME_DOWN}, |
| 224 {DomCode::VOLUME_MUTE, DomKey::VOLUME_MUTE}, |
| 225 {DomCode::VOLUME_UP, DomKey::VOLUME_UP}, |
| 226 {DomCode::WAKE_UP, DomKey::WAKE_UP}, |
| 227 {DomCode::ZOOM_TOGGLE, DomKey::ZOOM_TOGGLE}, |
| 228 }; |
| 229 |
| 230 // TODO(kpschoedel): move this to a shared location. |
| 231 // Map DOM Level 3 .key values to legacy Windows-based VKEY values. |
| 232 // This applies to non-printable keys. |
| 233 KeyboardCode DomKeyToKeyboardCode(DomKey dom_key) { |
| 234 switch (dom_key) { |
| 235 // No value. |
| 236 case DomKey::NONE: |
| 237 return VKEY_UNKNOWN; |
| 238 // Special Key Values |
| 239 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-special |
| 240 case DomKey::UNIDENTIFIED: |
| 241 return VKEY_UNKNOWN; |
| 242 // Modifier Keys |
| 243 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-modifier |
| 244 case DomKey::ALT: |
| 245 return VKEY_MENU; |
| 246 case DomKey::ALT_GRAPH: |
| 247 return VKEY_ALTGR; |
| 248 case DomKey::CAPS_LOCK: |
| 249 return VKEY_CAPITAL; |
| 250 case DomKey::CONTROL: |
| 251 return VKEY_CONTROL; |
| 252 case DomKey::NUM_LOCK: |
| 253 return VKEY_NUMLOCK; |
| 254 case DomKey::OS: |
| 255 return VKEY_LWIN; |
| 256 case DomKey::SCROLL_LOCK: |
| 257 return VKEY_SCROLL; |
| 258 case DomKey::SHIFT: |
| 259 return VKEY_SHIFT; |
| 260 // Whitespace Keys |
| 261 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-whitespace |
| 262 case DomKey::ENTER: |
| 263 return VKEY_RETURN; |
| 264 case DomKey::SEPARATOR: |
| 265 return VKEY_SEPARATOR; |
| 266 case DomKey::TAB: |
| 267 return VKEY_TAB; |
| 268 // Navigation Keys |
| 269 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-navigation |
| 270 case DomKey::ARROW_DOWN: |
| 271 return VKEY_DOWN; |
| 272 case DomKey::ARROW_LEFT: |
| 273 return VKEY_LEFT; |
| 274 case DomKey::ARROW_RIGHT: |
| 275 return VKEY_RIGHT; |
| 276 case DomKey::ARROW_UP: |
| 277 return VKEY_UP; |
| 278 case DomKey::END: |
| 279 return VKEY_END; |
| 280 case DomKey::HOME: |
| 281 return VKEY_HOME; |
| 282 case DomKey::PAGE_DOWN: |
| 283 return VKEY_NEXT; |
| 284 case DomKey::PAGE_UP: |
| 285 return VKEY_PRIOR; |
| 286 // Editing Keys |
| 287 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-editing |
| 288 case DomKey::BACKSPACE: |
| 289 return VKEY_BACK; |
| 290 case DomKey::CLEAR: |
| 291 return VKEY_CLEAR; |
| 292 case DomKey::CR_SEL: |
| 293 return VKEY_CRSEL; |
| 294 case DomKey::DEL: |
| 295 return VKEY_DELETE; |
| 296 case DomKey::ERASE_EOF: |
| 297 return VKEY_EREOF; |
| 298 case DomKey::EX_SEL: |
| 299 return VKEY_EXSEL; |
| 300 case DomKey::INSERT: |
| 301 return VKEY_INSERT; |
| 302 // UI Keys |
| 303 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-ui |
| 304 case DomKey::ACCEPT: |
| 305 return VKEY_ACCEPT; |
| 306 case DomKey::ATTN: |
| 307 return VKEY_ATTN; |
| 308 case DomKey::CONTEXT_MENU: |
| 309 return VKEY_APPS; |
| 310 case DomKey::ESCAPE: |
| 311 return VKEY_ESCAPE; |
| 312 case DomKey::EXECUTE: |
| 313 return VKEY_EXECUTE; |
| 314 case DomKey::HELP: |
| 315 return VKEY_HELP; |
| 316 case DomKey::PAUSE: |
| 317 return VKEY_PAUSE; |
| 318 case DomKey::PLAY: |
| 319 return VKEY_PLAY; |
| 320 case DomKey::SELECT: |
| 321 return VKEY_SELECT; |
| 322 // Device Keys |
| 323 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-device |
| 324 case DomKey::BRIGHTNESS_DOWN: |
| 325 return VKEY_BRIGHTNESS_DOWN; |
| 326 case DomKey::BRIGHTNESS_UP: |
| 327 return VKEY_BRIGHTNESS_UP; |
| 328 case DomKey::POWER: |
| 329 return VKEY_POWER; |
| 330 case DomKey::PRINT_SCREEN: |
| 331 return VKEY_SNAPSHOT; |
| 332 // IME and Composition Keys |
| 333 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-composition |
| 334 #if 0 // TODO(kpschoedel) |
| 335 case DomKey::COMPOSE: |
| 336 return VKEY_COMPOSE; |
| 337 #endif |
| 338 case DomKey::CONVERT: |
| 339 return VKEY_CONVERT; |
| 340 case DomKey::FINAL_MODE: |
| 341 return VKEY_FINAL; |
| 342 case DomKey::MODE_CHANGE: |
| 343 return VKEY_MODECHANGE; |
| 344 case DomKey::NON_CONVERT: |
| 345 return VKEY_NONCONVERT; |
| 346 case DomKey::PROCESS: |
| 347 return VKEY_PROCESSKEY; |
| 348 // Keys specific to Korean keyboards |
| 349 case DomKey::HANGUL_MODE: |
| 350 return VKEY_HANGUL; |
| 351 case DomKey::HANJA_MODE: |
| 352 return VKEY_HANJA; |
| 353 case DomKey::JUNJA_MODE: |
| 354 return VKEY_JUNJA; |
| 355 // Keys specific to Japanese keyboards |
| 356 case DomKey::HANKAKU: |
| 357 return VKEY_DBE_SBCSCHAR; |
| 358 case DomKey::KANA_MODE: |
| 359 return VKEY_KANA; |
| 360 case DomKey::KANJI_MODE: |
| 361 return VKEY_KANJI; |
| 362 case DomKey::ZENKAKU: |
| 363 return VKEY_DBE_DBCSCHAR; |
| 364 case DomKey::ZENKAKU_HANKAKU: |
| 365 return VKEY_DBE_DBCSCHAR; |
| 366 // General-Purpose Function Keys |
| 367 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-function |
| 368 case DomKey::F1: |
| 369 return VKEY_F1; |
| 370 case DomKey::F2: |
| 371 return VKEY_F2; |
| 372 case DomKey::F3: |
| 373 return VKEY_F3; |
| 374 case DomKey::F4: |
| 375 return VKEY_F4; |
| 376 case DomKey::F5: |
| 377 return VKEY_F5; |
| 378 case DomKey::F6: |
| 379 return VKEY_F6; |
| 380 case DomKey::F7: |
| 381 return VKEY_F7; |
| 382 case DomKey::F8: |
| 383 return VKEY_F8; |
| 384 case DomKey::F9: |
| 385 return VKEY_F9; |
| 386 case DomKey::F10: |
| 387 return VKEY_F10; |
| 388 case DomKey::F11: |
| 389 return VKEY_F11; |
| 390 case DomKey::F12: |
| 391 return VKEY_F12; |
| 392 case DomKey::F13: |
| 393 return VKEY_F13; |
| 394 case DomKey::F14: |
| 395 return VKEY_F14; |
| 396 case DomKey::F15: |
| 397 return VKEY_F15; |
| 398 case DomKey::F16: |
| 399 return VKEY_F16; |
| 400 case DomKey::F17: |
| 401 return VKEY_F17; |
| 402 case DomKey::F18: |
| 403 return VKEY_F18; |
| 404 case DomKey::F19: |
| 405 return VKEY_F19; |
| 406 case DomKey::F20: |
| 407 return VKEY_F20; |
| 408 case DomKey::F21: |
| 409 return VKEY_F21; |
| 410 case DomKey::F22: |
| 411 return VKEY_F22; |
| 412 case DomKey::F23: |
| 413 return VKEY_F23; |
| 414 case DomKey::F24: |
| 415 return VKEY_F24; |
| 416 // Multimedia Keys |
| 417 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-multimedia |
| 418 case DomKey::MEDIA_PLAY_PAUSE: |
| 419 return VKEY_MEDIA_PLAY_PAUSE; |
| 420 case DomKey::MEDIA_SELECT: |
| 421 return VKEY_MEDIA_LAUNCH_MEDIA_SELECT; |
| 422 case DomKey::MEDIA_STOP: |
| 423 return VKEY_MEDIA_STOP; |
| 424 case DomKey::MEDIA_TRACK_NEXT: |
| 425 return VKEY_MEDIA_NEXT_TRACK; |
| 426 case DomKey::MEDIA_TRACK_PREVIOUS: |
| 427 return VKEY_MEDIA_PREV_TRACK; |
| 428 case DomKey::PRINT: |
| 429 return VKEY_PRINT; |
| 430 case DomKey::VOLUME_DOWN: |
| 431 return VKEY_VOLUME_DOWN; |
| 432 case DomKey::VOLUME_MUTE: |
| 433 return VKEY_VOLUME_MUTE; |
| 434 case DomKey::VOLUME_UP: |
| 435 return VKEY_VOLUME_UP; |
| 436 // Application Keys |
| 437 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-apps |
| 438 case DomKey::LAUNCH_CALCULATOR: |
| 439 return VKEY_MEDIA_LAUNCH_APP2; |
| 440 case DomKey::LAUNCH_MAIL: |
| 441 return VKEY_MEDIA_LAUNCH_MAIL; |
| 442 case DomKey::LAUNCH_MY_COMPUTER: |
| 443 return VKEY_MEDIA_LAUNCH_APP1; |
| 444 // Browser Keys |
| 445 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-browser |
| 446 case DomKey::BROWSER_BACK: |
| 447 return VKEY_BACK; |
| 448 case DomKey::BROWSER_FAVORITES: |
| 449 return VKEY_BROWSER_FAVORITES; |
| 450 case DomKey::BROWSER_FORWARD: |
| 451 return VKEY_BROWSER_FORWARD; |
| 452 case DomKey::BROWSER_HOME: |
| 453 return VKEY_BROWSER_HOME; |
| 454 case DomKey::BROWSER_REFRESH: |
| 455 return VKEY_BROWSER_REFRESH; |
| 456 case DomKey::BROWSER_SEARCH: |
| 457 return VKEY_BROWSER_SEARCH; |
| 458 case DomKey::BROWSER_STOP: |
| 459 return VKEY_BROWSER_STOP; |
| 460 // Media Controller Keys |
| 461 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-media-controller |
| 462 case DomKey::ZOOM_TOGGLE: |
| 463 return VKEY_ZOOM; |
| 464 // No value. |
| 465 default: |
| 466 return VKEY_UNKNOWN; |
| 467 } |
| 468 } |
| 469 |
| 470 // TODO(kpschoedel): move this to a shared location. |
| 471 // This table maps DOM Level 3 .code values to legacy Windows-based VKEY |
| 472 // values, where the VKEYs are interpreted positionally. |
| 473 const struct DomCodeToKeyboardCodeEntry { |
| 474 DomCode dom_code; |
| 475 KeyboardCode key_code; |
| 476 } dom_code_to_keyboard_code[] = { |
| 477 // Entries are ordered by numeric value of the DomCode enum, |
| 478 // which is the USB physical key code. |
| 479 // DomCode::HYPER 0x000010 Hyper |
| 480 // DomCode::SUPER 0x000011 Super |
| 481 // DomCode::FN 0x000012 Fn |
| 482 // DomCode::FN_LOCK 0x000013 FLock |
| 483 // DomCode::SUSPEND 0x000014 Suspend |
| 484 // DomCode::RESUME 0x000015 Resume |
| 485 // DomCode::TURBO 0x000016 Turbo |
| 486 {DomCode::SLEEP, VKEY_SLEEP}, // 0x010082 Sleep |
| 487 // DomCode::WAKE_UP 0x010083 WakeUp |
| 488 {DomCode::KEY_A, VKEY_A}, // 0x070004 KeyA |
| 489 {DomCode::KEY_B, VKEY_B}, // 0x070005 KeyB |
| 490 {DomCode::KEY_C, VKEY_C}, // 0x070006 KeyC |
| 491 {DomCode::KEY_D, VKEY_D}, // 0x070007 KeyD |
| 492 {DomCode::KEY_E, VKEY_E}, // 0x070008 KeyE |
| 493 {DomCode::KEY_F, VKEY_F}, // 0x070009 KeyF |
| 494 {DomCode::KEY_G, VKEY_G}, // 0x07000A KeyG |
| 495 {DomCode::KEY_H, VKEY_H}, // 0x07000B KeyH |
| 496 {DomCode::KEY_I, VKEY_I}, // 0x07000C KeyI |
| 497 {DomCode::KEY_J, VKEY_J}, // 0x07000D KeyJ |
| 498 {DomCode::KEY_K, VKEY_K}, // 0x07000E KeyK |
| 499 {DomCode::KEY_L, VKEY_L}, // 0x07000F KeyL |
| 500 {DomCode::KEY_M, VKEY_M}, // 0x070010 KeyM |
| 501 {DomCode::KEY_N, VKEY_N}, // 0x070011 KeyN |
| 502 {DomCode::KEY_O, VKEY_O}, // 0x070012 KeyO |
| 503 {DomCode::KEY_P, VKEY_P}, // 0x070013 KeyP |
| 504 {DomCode::KEY_Q, VKEY_Q}, // 0x070014 KeyQ |
| 505 {DomCode::KEY_R, VKEY_R}, // 0x070015 KeyR |
| 506 {DomCode::KEY_S, VKEY_S}, // 0x070016 KeyS |
| 507 {DomCode::KEY_T, VKEY_T}, // 0x070017 KeyT |
| 508 {DomCode::KEY_U, VKEY_U}, // 0x070018 KeyU |
| 509 {DomCode::KEY_V, VKEY_V}, // 0x070019 KeyV |
| 510 {DomCode::KEY_W, VKEY_W}, // 0x07001A KeyW |
| 511 {DomCode::KEY_X, VKEY_X}, // 0x07001B KeyX |
| 512 {DomCode::KEY_Y, VKEY_Y}, // 0x07001C KeyY |
| 513 {DomCode::KEY_Z, VKEY_Z}, // 0x07001D KeyZ |
| 514 {DomCode::DIGIT1, VKEY_1}, // 0x07001E Digit1 |
| 515 {DomCode::DIGIT2, VKEY_2}, // 0x07001F Digit2 |
| 516 {DomCode::DIGIT3, VKEY_3}, // 0x070020 Digit3 |
| 517 {DomCode::DIGIT4, VKEY_4}, // 0x070021 Digit4 |
| 518 {DomCode::DIGIT5, VKEY_5}, // 0x070022 Digit5 |
| 519 {DomCode::DIGIT6, VKEY_6}, // 0x070023 Digit6 |
| 520 {DomCode::DIGIT7, VKEY_7}, // 0x070024 Digit7 |
| 521 {DomCode::DIGIT8, VKEY_8}, // 0x070025 Digit8 |
| 522 {DomCode::DIGIT9, VKEY_9}, // 0x070026 Digit9 |
| 523 {DomCode::DIGIT0, VKEY_0}, // 0x070027 Digit0 |
| 524 {DomCode::ENTER, VKEY_RETURN}, // 0x070028 Enter |
| 525 {DomCode::ESCAPE, VKEY_ESCAPE}, // 0x070029 Escape |
| 526 {DomCode::BACKSPACE, VKEY_BACK}, // 0x07002A Backspace |
| 527 {DomCode::TAB, VKEY_TAB}, // 0x07002B Tab |
| 528 {DomCode::SPACE, VKEY_SPACE}, // 0x07002C Space |
| 529 {DomCode::MINUS, VKEY_OEM_MINUS}, // 0x07002D Minus |
| 530 {DomCode::EQUAL, VKEY_OEM_PLUS}, // 0x07002E Equal |
| 531 {DomCode::BRACKET_LEFT, VKEY_OEM_4}, // 0x07002F BracketLeft |
| 532 {DomCode::BRACKET_RIGHT, VKEY_OEM_6}, // 0x070030 BracketRight |
| 533 {DomCode::BACKSLASH, VKEY_OEM_5}, // 0x070031 Backslash |
| 534 // DomCode::INTL_HASH, VKEY_OEM_5 // 0x070032 IntlHash |
| 535 {DomCode::SEMICOLON, VKEY_OEM_1}, // 0x070033 Semicolon |
| 536 {DomCode::QUOTE, VKEY_OEM_7}, // 0x070034 Quote |
| 537 {DomCode::BACKQUOTE, VKEY_OEM_3}, // 0x070035 Backquote |
| 538 {DomCode::COMMA, VKEY_OEM_COMMA}, // 0x070036 Comma |
| 539 {DomCode::PERIOD, VKEY_OEM_PERIOD}, // 0x070037 Period |
| 540 {DomCode::SLASH, VKEY_OEM_2}, // 0x070038 Slash |
| 541 {DomCode::CAPS_LOCK, VKEY_CAPITAL}, // 0x070039 CapsLock |
| 542 {DomCode::F1, VKEY_F1}, // 0x07003A F1 |
| 543 {DomCode::F2, VKEY_F2}, // 0x07003B F2 |
| 544 {DomCode::F3, VKEY_F3}, // 0x07003C F3 |
| 545 {DomCode::F4, VKEY_F4}, // 0x07003D F4 |
| 546 {DomCode::F5, VKEY_F5}, // 0x07003E F5 |
| 547 {DomCode::F6, VKEY_F6}, // 0x07003F F6 |
| 548 {DomCode::F7, VKEY_F7}, // 0x070040 F7 |
| 549 {DomCode::F8, VKEY_F8}, // 0x070041 F8 |
| 550 {DomCode::F9, VKEY_F9}, // 0x070042 F9 |
| 551 {DomCode::F10, VKEY_F10}, // 0x070043 F10 |
| 552 {DomCode::F11, VKEY_F11}, // 0x070044 F11 |
| 553 {DomCode::F12, VKEY_F12}, // 0x070045 F12 |
| 554 {DomCode::PRINT_SCREEN, VKEY_SNAPSHOT}, // 0x070046 PrintScreen |
| 555 {DomCode::SCROLL_LOCK, VKEY_SCROLL}, // 0x070047 ScrollLock |
| 556 {DomCode::PAUSE, VKEY_PAUSE}, // 0x070048 Pause |
| 557 {DomCode::INSERT, VKEY_INSERT}, // 0x070049 Insert |
| 558 {DomCode::HOME, VKEY_HOME}, // 0x07004A Home |
| 559 {DomCode::PAGE_UP, VKEY_PRIOR}, // 0x07004B PageUp |
| 560 {DomCode::DEL, VKEY_DELETE}, // 0x07004C Delete |
| 561 {DomCode::END, VKEY_END}, // 0x07004D End |
| 562 {DomCode::PAGE_DOWN, VKEY_NEXT}, // 0x07004E PageDown |
| 563 {DomCode::ARROW_RIGHT, VKEY_RIGHT}, // 0x07004F ArrowRight |
| 564 {DomCode::ARROW_LEFT, VKEY_LEFT}, // 0x070050 ArrowLeft |
| 565 {DomCode::ARROW_DOWN, VKEY_DOWN}, // 0x070051 ArrowDown |
| 566 {DomCode::ARROW_UP, VKEY_UP}, // 0x070052 ArrowUp |
| 567 {DomCode::NUM_LOCK, VKEY_NUMLOCK}, // 0x070053 NumLock |
| 568 {DomCode::NUMPAD_DIVIDE, VKEY_DIVIDE}, // 0x070054 NumpadDivide |
| 569 {DomCode::NUMPAD_MULTIPLY, VKEY_MULTIPLY}, // 0x070055 NumpadMultiply |
| 570 {DomCode::NUMPAD_SUBTRACT, VKEY_SUBTRACT}, // 0x070056 NumpadSubtract |
| 571 {DomCode::NUMPAD_ADD, VKEY_ADD}, // 0x070057 NumpadAdd |
| 572 {DomCode::NUMPAD_ENTER, VKEY_RETURN}, // 0x070058 NumpadEnter |
| 573 {DomCode::NUMPAD1, VKEY_NUMPAD1}, // 0x070059 Numpad1 |
| 574 {DomCode::NUMPAD2, VKEY_NUMPAD2}, // 0x07005A Numpad2 |
| 575 {DomCode::NUMPAD3, VKEY_NUMPAD3}, // 0x07005B Numpad3 |
| 576 {DomCode::NUMPAD4, VKEY_NUMPAD4}, // 0x07005C Numpad4 |
| 577 {DomCode::NUMPAD5, VKEY_NUMPAD5}, // 0x07005D Numpad5 |
| 578 {DomCode::NUMPAD6, VKEY_NUMPAD6}, // 0x07005E Numpad6 |
| 579 {DomCode::NUMPAD7, VKEY_NUMPAD7}, // 0x07005F Numpad7 |
| 580 {DomCode::NUMPAD8, VKEY_NUMPAD8}, // 0x070060 Numpad8 |
| 581 {DomCode::NUMPAD9, VKEY_NUMPAD9}, // 0x070061 Numpad9 |
| 582 {DomCode::NUMPAD0, VKEY_NUMPAD0}, // 0x070062 Numpad0 |
| 583 {DomCode::NUMPAD_DECIMAL, VKEY_DECIMAL}, // 0x070063 NumpadDecimal |
| 584 {DomCode::INTL_BACKSLASH, VKEY_OEM_102}, // 0x070064 IntlBackslash |
| 585 {DomCode::CONTEXT_MENU, VKEY_APPS}, // 0x070065 ContextMenu |
| 586 {DomCode::POWER, VKEY_POWER}, // 0x070066 Power |
| 587 // DomCode::NUMPAD_EQUAL 0x070067 NumpadEqual |
| 588 // DomCode::OPEN 0x070074 Open |
| 589 {DomCode::HELP, VKEY_HELP}, // 0x070075 Help |
| 590 {DomCode::SELECT, VKEY_SELECT}, // 0x070077 Select |
| 591 // DomCode::AGAIN 0x070079 Again |
| 592 // DomCode::UNDO 0x07007A Undo |
| 593 // DomCode::CUT 0x07007B Cut |
| 594 // DomCode::COPY 0x07007C Copy |
| 595 // DomCode::PASTE 0x07007D Paste |
| 596 // DomCode::FIND 0x07007E Find |
| 597 {DomCode::VOLUME_MUTE, VKEY_VOLUME_MUTE}, // 0x07007F VolumeMute |
| 598 {DomCode::VOLUME_UP, VKEY_VOLUME_UP}, // 0x070080 VolumeUp |
| 599 {DomCode::VOLUME_DOWN, VKEY_VOLUME_DOWN}, // 0x070081 VolumeDown |
| 600 {DomCode::NUMPAD_COMMA, VKEY_OEM_COMMA}, // 0x070085 NumpadComma |
| 601 {DomCode::INTL_RO, VKEY_OEM_102}, // 0x070087 IntlRo |
| 602 {DomCode::KANA_MODE, VKEY_KANA}, // 0x070088 KanaMode |
| 603 {DomCode::INTL_YEN, VKEY_OEM_5}, // 0x070089 IntlYen |
| 604 {DomCode::CONVERT, VKEY_CONVERT}, // 0x07008A Convert |
| 605 {DomCode::NON_CONVERT, VKEY_NONCONVERT}, // 0x07008B NonConvert |
| 606 {DomCode::LANG1, VKEY_KANA}, // 0x070090 Lang1 |
| 607 {DomCode::LANG2, VKEY_KANJI}, // 0x070091 Lang2 |
| 608 // DomCode::LANG3 0x070092 Lang3 |
| 609 // DomCode::LANG4 0x070093 Lang4 |
| 610 // DomCode::LANG5 0x070094 Lang5 |
| 611 // DomCode::ABORT 0x07009B Abort |
| 612 // DomCode::PROPS 0x0700A3 Props |
| 613 // DomCode::NUMPAD_PAREN_LEFT 0x0700B6 NumpadParenLeft |
| 614 // DomCode::NUMPAD_PAREN_RIGHT 0x0700B7 NumpadParenRight |
| 615 {DomCode::NUMPAD_BACKSPACE, VKEY_BACK}, // 0x0700BB NumpadBackspace |
| 616 // DomCode::NUMPAD_MEMORY_STORE 0x0700D0 NumpadMemoryStore |
| 617 // DomCode::NUMPAD_MEMORY_RECALL 0x0700D1 NumpadMemoryRecall |
| 618 // DomCode::NUMPAD_MEMORY_CLEAR 0x0700D2 NumpadMemoryClear |
| 619 // DomCode::NUMPAD_MEMORY_ADD 0x0700D3 NumpadMemoryAdd |
| 620 // DomCode::NUMPAD_MEMORY_SUBTRACT 0x0700D4 |
| 621 // NumpadMemorySubtract |
| 622 {DomCode::NUMPAD_CLEAR, VKEY_CLEAR}, // 0x0700D8 NumpadClear |
| 623 {DomCode::NUMPAD_CLEAR_ENTRY, VKEY_CLEAR}, // 0x0700D9 NumpadClearEntry |
| 624 {DomCode::CONTROL_LEFT, VKEY_LCONTROL}, // 0x0700E0 ControlLeft |
| 625 {DomCode::SHIFT_LEFT, VKEY_LSHIFT}, // 0x0700E1 ShiftLeft |
| 626 {DomCode::ALT_LEFT, VKEY_LMENU}, // 0x0700E2 AltLeft |
| 627 {DomCode::OS_LEFT, VKEY_LWIN}, // 0x0700E3 OSLeft |
| 628 {DomCode::CONTROL_RIGHT, VKEY_RCONTROL}, // 0x0700E4 ControlRight |
| 629 {DomCode::SHIFT_RIGHT, VKEY_RSHIFT}, // 0x0700E5 ShiftRight |
| 630 {DomCode::ALT_RIGHT, VKEY_RMENU}, // 0x0700E6 AltRight |
| 631 {DomCode::OS_RIGHT, VKEY_RWIN}, // 0x0700E7 OSRight |
| 632 {DomCode::MEDIA_TRACK_NEXT, |
| 633 VKEY_MEDIA_NEXT_TRACK}, // 0x0C00B5 MediaTrackNext |
| 634 {DomCode::MEDIA_TRACK_PREVIOUS, |
| 635 VKEY_MEDIA_PREV_TRACK}, // 0x0C00B6 MediaTrackPrevious |
| 636 {DomCode::MEDIA_STOP, VKEY_MEDIA_STOP}, // 0x0C00B7 MediaStop |
| 637 // DomCode::EJECT 0x0C00B8 Eject |
| 638 {DomCode::MEDIA_PLAY_PAUSE, |
| 639 VKEY_MEDIA_PLAY_PAUSE}, // 0x0C00CD MediaPlayPause |
| 640 {DomCode::MEDIA_SELECT, |
| 641 VKEY_MEDIA_LAUNCH_MEDIA_SELECT}, // 0x0C0183 MediaSelect |
| 642 {DomCode::LAUNCH_MAIL, VKEY_MEDIA_LAUNCH_MAIL}, // 0x0C018A LaunchMail |
| 643 {DomCode::LAUNCH_APP2, VKEY_MEDIA_LAUNCH_APP2}, // 0x0C0192 LaunchApp2 |
| 644 {DomCode::LAUNCH_APP1, VKEY_MEDIA_LAUNCH_APP1}, // 0x0C0194 LaunchApp1 |
| 645 {DomCode::BROWSER_SEARCH, VKEY_BROWSER_SEARCH}, // 0x0C0221 BrowserSearch |
| 646 {DomCode::BROWSER_HOME, VKEY_BROWSER_HOME}, // 0x0C0223 BrowserHome |
| 647 {DomCode::BROWSER_BACK, VKEY_BROWSER_BACK}, // 0x0C0224 BrowserBack |
| 648 {DomCode::BROWSER_FORWARD, |
| 649 VKEY_BROWSER_FORWARD}, // 0x0C0225 BrowserForward |
| 650 {DomCode::BROWSER_STOP, VKEY_BROWSER_STOP}, // 0x0C0226 BrowserStop |
| 651 {DomCode::BROWSER_REFRESH, |
| 652 VKEY_BROWSER_REFRESH}, // 0x0C0227 BrowserRefresh |
| 653 {DomCode::BROWSER_FAVORITES, |
| 654 VKEY_BROWSER_FAVORITES}, // 0x0C022A BrowserFavorites |
| 655 }; |
| 656 |
| 657 // TODO(kpschoedel): move this to a shared location. |
| 658 // Map DOM Level 3 .code values to legacy Windows-based VKEY values, |
| 659 // where the VKEYs are interpreted positionally. |
| 660 KeyboardCode DomCodeToKeyboardCode(DomCode dom_code) { |
| 661 const DomCodeToKeyboardCodeEntry* end = |
| 662 dom_code_to_keyboard_code + arraysize(dom_code_to_keyboard_code); |
| 663 const DomCodeToKeyboardCodeEntry* found = |
| 664 std::lower_bound(dom_code_to_keyboard_code, end, dom_code, |
| 665 [](const DomCodeToKeyboardCodeEntry& a, DomCode b) { |
| 666 return static_cast<int>(a.dom_code) < static_cast<int>(b); |
| 667 }); |
| 668 if ((found != end) && (found->dom_code == dom_code)) |
| 669 return found->key_code; |
| 670 return VKEY_UNKNOWN; |
| 671 } |
| 672 |
| 673 // TODO(kpschoedel): move this to a shared location. |
| 674 bool ControlCharacter(DomCode dom_code, |
| 675 DomKey* dom_key, |
| 676 base::char16* character) { |
| 677 int code = static_cast<int>(dom_code); |
| 678 const int kKeyA = static_cast<int>(DomCode::KEY_A); |
| 679 // Control-A - Control-Z map to 0x01 - 0x1A. |
| 680 if (code >= kKeyA && code <= static_cast<int>(DomCode::KEY_Z)) { |
| 681 *character = static_cast<base::char16>(code - kKeyA + 1); |
| 682 switch (dom_code) { |
| 683 case DomCode::KEY_H: |
| 684 *dom_key = DomKey::BACKSPACE; |
| 685 case DomCode::KEY_I: |
| 686 *dom_key = DomKey::TAB; |
| 687 case DomCode::KEY_M: |
| 688 *dom_key = DomKey::ENTER; |
| 689 default: |
| 690 *dom_key = DomKey::CHARACTER; |
| 691 } |
| 692 return true; |
| 693 } |
| 694 switch (dom_code) { |
| 695 case DomCode::DIGIT2: |
| 696 // NUL |
| 697 *character = 0; |
| 698 *dom_key = DomKey::CHARACTER; |
| 699 return true; |
| 700 case DomCode::ENTER: |
| 701 // NL |
| 702 *character = 0x0A; |
| 703 *dom_key = DomKey::CHARACTER; |
| 704 return true; |
| 705 case DomCode::BRACKET_LEFT: |
| 706 // ESC |
| 707 *character = 0x1B; |
| 708 *dom_key = DomKey::ESCAPE; |
| 709 return true; |
| 710 case DomCode::BACKSLASH: |
| 711 // FS |
| 712 *character = 0x1C; |
| 713 *dom_key = DomKey::CHARACTER; |
| 714 return true; |
| 715 case DomCode::BRACKET_RIGHT: |
| 716 // GS |
| 717 *character = 0x1D; |
| 718 *dom_key = DomKey::CHARACTER; |
| 719 return true; |
| 720 case DomCode::DIGIT6: |
| 721 // RS |
| 722 *character = 0x1E; |
| 723 *dom_key = DomKey::CHARACTER; |
| 724 return true; |
| 725 case DomCode::MINUS: |
| 726 // US |
| 727 *character = 0x1F; |
| 728 *dom_key = DomKey::CHARACTER; |
| 729 return true; |
| 730 default: |
| 731 return false; |
| 732 } |
| 733 } |
| 734 |
| 735 } // anonymous namespace |
| 736 |
| 737 StubKeyboardLayoutEngine::StubKeyboardLayoutEngine() { |
| 738 } |
| 739 |
| 740 StubKeyboardLayoutEngine::~StubKeyboardLayoutEngine() { |
| 741 } |
| 742 |
| 743 bool StubKeyboardLayoutEngine::CanSetCurrentLayout() const { |
| 744 return false; |
| 745 } |
| 746 |
| 747 bool StubKeyboardLayoutEngine::SetCurrentLayoutByName( |
| 748 const std::string& layout_name) { |
| 749 return false; |
| 750 } |
| 751 |
| 752 bool StubKeyboardLayoutEngine::UsesISOLevel5Shift() const { |
| 753 return false; |
| 754 } |
| 755 |
| 756 bool StubKeyboardLayoutEngine::UsesAltGr() const { |
| 757 return true; |
| 758 } |
| 759 |
| 760 bool StubKeyboardLayoutEngine::Lookup(DomCode dom_code, |
| 761 int flags, |
| 762 DomKey* out_dom_key, |
| 763 base::char16* out_character, |
| 764 KeyboardCode* out_key_code) const { |
| 765 if ((flags & EF_CONTROL_DOWN) == EF_CONTROL_DOWN) { |
| 766 if (ControlCharacter(dom_code, out_dom_key, out_character)) { |
| 767 *out_key_code = DomCodeToKeyboardCode(dom_code); |
| 768 return true; |
| 769 } |
| 770 } else { |
| 771 for (size_t i = 0; i < arraysize(printable_code_map); ++i) { |
| 772 const PrintableCodeEntry* e = &printable_code_map[i]; |
| 773 if (e->dom_code == dom_code) { |
| 774 int state = (((flags & EF_ALTGR_DOWN) == EF_ALTGR_DOWN) << 1) | |
| 775 ((flags & EF_SHIFT_DOWN) == EF_SHIFT_DOWN); |
| 776 base::char16 ch = e->character[state]; |
| 777 *out_dom_key = (ch & DK) ? DomKey::DEAD : DomKey::CHARACTER; |
| 778 *out_character = ch; |
| 779 if ((flags & EF_CAPS_LOCK_DOWN) == EF_CAPS_LOCK_DOWN) { |
| 780 ch = (ch & ~DK) | 0x20; |
| 781 if ((ch >= 'a') && (ch <= 'z')) |
| 782 *out_character = e->character[state ^ 1]; |
| 783 } |
| 784 *out_key_code = DomCodeToKeyboardCode(dom_code); |
| 785 return true; |
| 786 } |
| 787 } |
| 788 } |
| 789 |
| 790 for (size_t i = 0; i < arraysize(non_printable_code_map); ++i) { |
| 791 const NonPrintableCodeEntry* e = &non_printable_code_map[i]; |
| 792 if (e->dom_code == dom_code) { |
| 793 *out_dom_key = e->dom_key; |
| 794 *out_character = e->character; |
| 795 *out_key_code = DomKeyToKeyboardCode(e->dom_key); |
| 796 return true; |
| 797 } |
| 798 } |
| 799 |
| 800 return false; |
| 801 } |
| 802 |
| 803 } // namespace ui |
OLD | NEW |