OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" | 5 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #import <Carbon/Carbon.h> | 9 #import <Carbon/Carbon.h> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/mac/mac_logging.h" | 12 #include "base/mac/mac_logging.h" |
13 #include "base/mac/scoped_cftyperef.h" | 13 #include "base/mac/scoped_cftyperef.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "ui/events/keycodes/dom/keycode_converter.h" | 15 #include "ui/events/keycodes/dom/keycode_converter.h" |
16 | 16 |
17 namespace ui { | 17 namespace ui { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 // This value is not defined but shows up as 0x36. | 21 // This value is not defined but shows up as 0x36. |
22 const int kVK_RightCommand = 0x36; | 22 const int kVK_RightCommand = 0x36; |
| 23 // Context menu is not defined but shows up as 0x6E. |
| 24 const int kVK_ContextMenu = 0x6E; |
23 | 25 |
24 // A struct to hold a Windows keycode to Mac virtual keycode mapping. | 26 // A struct to hold a Windows keycode to Mac virtual keycode mapping. |
25 struct KeyCodeMap { | 27 struct KeyCodeMap { |
26 KeyboardCode keycode; | 28 KeyboardCode keycode; |
27 int macKeycode; | 29 int macKeycode; |
28 unichar characterIgnoringAllModifiers; | 30 unichar characterIgnoringAllModifiers; |
29 }; | 31 }; |
30 | 32 |
31 // Customized less operator for using std::lower_bound() on a KeyCodeMap array. | 33 // Customized less operator for using std::lower_bound() on a KeyCodeMap array. |
32 bool operator<(const KeyCodeMap& a, const KeyCodeMap& b) { | 34 bool operator<(const KeyCodeMap& a, const KeyCodeMap& b) { |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 /* 0x64 */ VKEY_F8, | 421 /* 0x64 */ VKEY_F8, |
420 /* 0x65 */ VKEY_F9, | 422 /* 0x65 */ VKEY_F9, |
421 /* 0x66 */ VKEY_UNKNOWN, // Eisu (JIS Keyboard Only) | 423 /* 0x66 */ VKEY_UNKNOWN, // Eisu (JIS Keyboard Only) |
422 /* 0x67 */ VKEY_F11, | 424 /* 0x67 */ VKEY_F11, |
423 /* 0x68 */ VKEY_UNKNOWN, // Kana (JIS Keyboard Only) | 425 /* 0x68 */ VKEY_UNKNOWN, // Kana (JIS Keyboard Only) |
424 /* 0x69 */ VKEY_F13, | 426 /* 0x69 */ VKEY_F13, |
425 /* 0x6A */ VKEY_F16, | 427 /* 0x6A */ VKEY_F16, |
426 /* 0x6B */ VKEY_F14, | 428 /* 0x6B */ VKEY_F14, |
427 /* 0x6C */ VKEY_UNKNOWN, // n/a | 429 /* 0x6C */ VKEY_UNKNOWN, // n/a |
428 /* 0x6D */ VKEY_F10, | 430 /* 0x6D */ VKEY_F10, |
429 /* 0x6E */ VKEY_UNKNOWN, // n/a (Windows95 key?) | 431 /* 0x6E */ VKEY_APPS, // Context Menu key |
430 /* 0x6F */ VKEY_F12, | 432 /* 0x6F */ VKEY_F12, |
431 /* 0x70 */ VKEY_UNKNOWN, // n/a | 433 /* 0x70 */ VKEY_UNKNOWN, // n/a |
432 /* 0x71 */ VKEY_F15, | 434 /* 0x71 */ VKEY_F15, |
433 /* 0x72 */ VKEY_INSERT, // Help | 435 /* 0x72 */ VKEY_INSERT, // Help |
434 /* 0x73 */ VKEY_HOME, // Home | 436 /* 0x73 */ VKEY_HOME, // Home |
435 /* 0x74 */ VKEY_PRIOR, // Page Up | 437 /* 0x74 */ VKEY_PRIOR, // Page Up |
436 /* 0x75 */ VKEY_DELETE, // Forward Delete | 438 /* 0x75 */ VKEY_DELETE, // Forward Delete |
437 /* 0x76 */ VKEY_F4, | 439 /* 0x76 */ VKEY_F4, |
438 /* 0x77 */ VKEY_END, // End | 440 /* 0x77 */ VKEY_END, // End |
439 /* 0x78 */ VKEY_F2, | 441 /* 0x78 */ VKEY_F2, |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 case kVK_PageDown: | 540 case kVK_PageDown: |
539 return DomKey::PAGE_DOWN; | 541 return DomKey::PAGE_DOWN; |
540 case kVK_LeftArrow: | 542 case kVK_LeftArrow: |
541 return DomKey::ARROW_LEFT; | 543 return DomKey::ARROW_LEFT; |
542 case kVK_RightArrow: | 544 case kVK_RightArrow: |
543 return DomKey::ARROW_RIGHT; | 545 return DomKey::ARROW_RIGHT; |
544 case kVK_DownArrow: | 546 case kVK_DownArrow: |
545 return DomKey::ARROW_DOWN; | 547 return DomKey::ARROW_DOWN; |
546 case kVK_UpArrow: | 548 case kVK_UpArrow: |
547 return DomKey::ARROW_UP; | 549 return DomKey::ARROW_UP; |
| 550 case kVK_ContextMenu: |
| 551 return DomKey::CONTEXT_MENU; |
548 default: | 552 default: |
549 return DomKey::NONE; | 553 return DomKey::NONE; |
550 } | 554 } |
551 } | 555 } |
552 | 556 |
553 DomKey DomKeyFromCharCode(unichar char_code) { | 557 DomKey DomKeyFromCharCode(unichar char_code) { |
554 switch (char_code) { | 558 switch (char_code) { |
555 case NSUpArrowFunctionKey: | 559 case NSUpArrowFunctionKey: |
556 return DomKey::ARROW_UP; | 560 return DomKey::ARROW_UP; |
557 case NSDownArrowFunctionKey: | 561 case NSDownArrowFunctionKey: |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 &unused_is_dead_key); | 871 &unused_is_dead_key); |
868 } | 872 } |
869 if (!std::iscntrl(dom_key_char)) | 873 if (!std::iscntrl(dom_key_char)) |
870 return DomKeyFromCharCode(dom_key_char); | 874 return DomKeyFromCharCode(dom_key_char); |
871 } | 875 } |
872 } | 876 } |
873 return DomKeyFromKeyCode([event keyCode]); | 877 return DomKeyFromKeyCode([event keyCode]); |
874 } | 878 } |
875 | 879 |
876 } // namespace ui | 880 } // namespace ui |
OLD | NEW |