OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "ui/events/keycodes/dom4/keycode_converter.h" | 5 #include "ui/events/keycodes/dom4/keycode_converter.h" |
6 | 6 |
7 namespace ui { | 7 namespace ui { |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 70 } |
71 return InvalidNativeKeycode(); | 71 return InvalidNativeKeycode(); |
72 } | 72 } |
73 | 73 |
74 // USB keycodes | 74 // USB keycodes |
75 // Note that USB keycodes are not part of any web standard. | 75 // Note that USB keycodes are not part of any web standard. |
76 // Please don't use USB keycodes in new code. | 76 // Please don't use USB keycodes in new code. |
77 | 77 |
78 // static | 78 // static |
79 uint16_t KeycodeConverter::InvalidUsbKeycode() { | 79 uint16_t KeycodeConverter::InvalidUsbKeycode() { |
80 return usb_keycode_map[0].usb_keycode; | 80 return static_cast<uint16_t>(usb_keycode_map[0].usb_keycode); |
81 } | 81 } |
82 | 82 |
83 // static | 83 // static |
84 uint16_t KeycodeConverter::UsbKeycodeToNativeKeycode(uint32_t usb_keycode) { | 84 uint16_t KeycodeConverter::UsbKeycodeToNativeKeycode(uint32_t usb_keycode) { |
85 // Deal with some special-cases that don't fit the 1:1 mapping. | 85 // Deal with some special-cases that don't fit the 1:1 mapping. |
86 if (usb_keycode == 0x070032) // non-US hash. | 86 if (usb_keycode == 0x070032) // non-US hash. |
87 usb_keycode = 0x070031; // US backslash. | 87 usb_keycode = 0x070031; // US backslash. |
88 #if defined(OS_MACOSX) | 88 #if defined(OS_MACOSX) |
89 if (usb_keycode == 0x070046) // PrintScreen. | 89 if (usb_keycode == 0x070046) // PrintScreen. |
90 usb_keycode = 0x070068; // F13. | 90 usb_keycode = 0x070068; // F13. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 for (size_t i = 0; i < kKeycodeMapEntries; ++i) { | 125 for (size_t i = 0; i < kKeycodeMapEntries; ++i) { |
126 if (usb_keycode_map[i].code && | 126 if (usb_keycode_map[i].code && |
127 strcmp(usb_keycode_map[i].code, code) == 0) { | 127 strcmp(usb_keycode_map[i].code, code) == 0) { |
128 return usb_keycode_map[i].usb_keycode; | 128 return usb_keycode_map[i].usb_keycode; |
129 } | 129 } |
130 } | 130 } |
131 return InvalidUsbKeycode(); | 131 return InvalidUsbKeycode(); |
132 } | 132 } |
133 | 133 |
134 } // namespace ui | 134 } // namespace ui |
OLD | NEW |