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/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 |
8 #import <Carbon/Carbon.h> | 9 #import <Carbon/Carbon.h> |
9 | 10 |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 | 12 |
12 namespace ui { | 13 namespace ui { |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 // A struct to hold a Windows keycode to Mac virtual keycode mapping. | 17 // A struct to hold a Windows keycode to Mac virtual keycode mapping. |
17 struct KeyCodeMap { | 18 struct KeyCodeMap { |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 /* 0x7E */ VKEY_UP, // Up Arrow | 441 /* 0x7E */ VKEY_UP, // Up Arrow |
441 /* 0x7F */ VKEY_UNKNOWN // n/a | 442 /* 0x7F */ VKEY_UNKNOWN // n/a |
442 }; | 443 }; |
443 | 444 |
444 if (keyCode >= 0x80) | 445 if (keyCode >= 0x80) |
445 return VKEY_UNKNOWN; | 446 return VKEY_UNKNOWN; |
446 | 447 |
447 return kKeyboardCodes[keyCode]; | 448 return kKeyboardCodes[keyCode]; |
448 } | 449 } |
449 | 450 |
450 } // anonymous namespace | 451 } // namespace |
451 | 452 |
452 int MacKeyCodeForWindowsKeyCode(KeyboardCode keycode, | 453 int MacKeyCodeForWindowsKeyCode(KeyboardCode keycode, |
453 NSUInteger flags, | 454 NSUInteger flags, |
454 unichar* character, | 455 unichar* character, |
455 unichar* characterIgnoringModifiers) { | 456 unichar* characterIgnoringModifiers) { |
456 KeyCodeMap from; | 457 KeyCodeMap from; |
457 from.keycode = keycode; | 458 from.keycode = keycode; |
458 | 459 |
459 const KeyCodeMap* ptr = std::lower_bound( | 460 const KeyCodeMap* ptr = std::lower_bound( |
460 kKeyCodesMap, kKeyCodesMap + arraysize(kKeyCodesMap), from); | 461 kKeyCodesMap, kKeyCodesMap + arraysize(kKeyCodesMap), from); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 characters = [event charactersIgnoringModifiers]; | 549 characters = [event charactersIgnoringModifiers]; |
549 if ([characters length] > 0) | 550 if ([characters length] > 0) |
550 code = KeyboardCodeFromCharCode([characters characterAtIndex:0]); | 551 code = KeyboardCodeFromCharCode([characters characterAtIndex:0]); |
551 if (code) | 552 if (code) |
552 return code; | 553 return code; |
553 } | 554 } |
554 return KeyboardCodeFromKeyCode([event keyCode]); | 555 return KeyboardCodeFromKeyCode([event keyCode]); |
555 } | 556 } |
556 | 557 |
557 } // namespace ui | 558 } // namespace ui |
OLD | NEW |