OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/base/keycodes/keyboard_code_conversion_mac.h" | 5 #import "ui/base/keycodes/keyboard_code_conversion_mac.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #import <Carbon/Carbon.h> | 8 #import <Carbon/Carbon.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
24 bool operator<(const KeyCodeMap& a, const KeyCodeMap& b) { | 24 bool operator<(const KeyCodeMap& a, const KeyCodeMap& b) { |
25 return a.keycode < b.keycode; | 25 return a.keycode < b.keycode; |
26 } | 26 } |
27 | 27 |
28 // This array must keep sorted ascending according to the value of |keycode|, | 28 // This array must keep sorted ascending according to the value of |keycode|, |
29 // so that we can binary search it. | 29 // so that we can binary search it. |
30 // TODO(suzhe): This map is not complete, missing entries have macKeycode == -1. | 30 // TODO(suzhe): This map is not complete, missing entries have macKeycode == -1. |
31 const KeyCodeMap kKeyCodesMap[] = { | 31 const KeyCodeMap kKeyCodesMap[] = { |
32 { VKEY_BACK /* 0x08 */, kVK_Delete, kBackspaceCharCode }, | 32 { VKEY_BACK /* 0x08 */, kVK_Delete, kBackspaceCharCode }, |
33 { VKEY_TAB /* 0x09 */, kVK_Tab, kTabCharCode }, | 33 { VKEY_TAB /* 0x09 */, kVK_Tab, kTabCharCode }, |
34 { VKEY_BACKTAB /* 0x0A */, 0x21E4, '\031' }, | |
Peter Kasting
2012/01/24 19:14:44
Where do these values come from? (I noticed for e
aaron.randolph
2012/01/24 21:18:34
That would make sense. I got the other value from
| |
34 { VKEY_CLEAR /* 0x0C */, kVK_ANSI_KeypadClear, kClearCharCode }, | 35 { VKEY_CLEAR /* 0x0C */, kVK_ANSI_KeypadClear, kClearCharCode }, |
35 { VKEY_RETURN /* 0x0D */, kVK_Return, kReturnCharCode }, | 36 { VKEY_RETURN /* 0x0D */, kVK_Return, kReturnCharCode }, |
36 { VKEY_SHIFT /* 0x10 */, kVK_Shift, 0 }, | 37 { VKEY_SHIFT /* 0x10 */, kVK_Shift, 0 }, |
37 { VKEY_CONTROL /* 0x11 */, kVK_Control, 0 }, | 38 { VKEY_CONTROL /* 0x11 */, kVK_Control, 0 }, |
38 { VKEY_MENU /* 0x12 */, kVK_Option, 0 }, | 39 { VKEY_MENU /* 0x12 */, kVK_Option, 0 }, |
39 { VKEY_PAUSE /* 0x13 */, -1, NSPauseFunctionKey }, | 40 { VKEY_PAUSE /* 0x13 */, -1, NSPauseFunctionKey }, |
40 { VKEY_CAPITAL /* 0x14 */, kVK_CapsLock, 0 }, | 41 { VKEY_CAPITAL /* 0x14 */, kVK_CapsLock, 0 }, |
41 { VKEY_KANA /* 0x15 */, kVK_JIS_Kana, 0 }, | 42 { VKEY_KANA /* 0x15 */, kVK_JIS_Kana, 0 }, |
42 { VKEY_HANGUL /* 0x15 */, -1, 0 }, | 43 { VKEY_HANGUL /* 0x15 */, -1, 0 }, |
43 { VKEY_JUNJA /* 0x17 */, -1, 0 }, | 44 { VKEY_JUNJA /* 0x17 */, -1, 0 }, |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 characters = [event charactersIgnoringModifiers]; | 548 characters = [event charactersIgnoringModifiers]; |
548 if ([characters length] > 0) | 549 if ([characters length] > 0) |
549 code = KeyboardCodeFromCharCode([characters characterAtIndex:0]); | 550 code = KeyboardCodeFromCharCode([characters characterAtIndex:0]); |
550 if (code) | 551 if (code) |
551 return code; | 552 return code; |
552 } | 553 } |
553 return KeyboardCodeFromKeyCode([event keyCode]); | 554 return KeyboardCodeFromKeyCode([event keyCode]); |
554 } | 555 } |
555 | 556 |
556 } // namespace ui | 557 } // namespace ui |
OLD | NEW |