| 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 #include "ui/events/keycodes/dom3/dom_code.h" | 7 #include "ui/events/keycodes/dom3/dom_code.h" |
| 8 #include "ui/events/keycodes/dom3/dom_key.h" | 8 #include "ui/events/keycodes/dom3/dom_key.h" |
| 9 | 9 |
| 10 namespace ui { | 10 namespace ui { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // static | 203 // static |
| 204 const char* KeycodeConverter::UsbKeycodeToCode(uint32_t usb_keycode) { | 204 const char* KeycodeConverter::UsbKeycodeToCode(uint32_t usb_keycode) { |
| 205 for (size_t i = 0; i < kKeycodeMapEntries; ++i) { | 205 for (size_t i = 0; i < kKeycodeMapEntries; ++i) { |
| 206 if (usb_keycode_map[i].usb_keycode == usb_keycode) | 206 if (usb_keycode_map[i].usb_keycode == usb_keycode) |
| 207 return usb_keycode_map[i].code; | 207 return usb_keycode_map[i].code; |
| 208 } | 208 } |
| 209 return InvalidKeyboardEventCode(); | 209 return InvalidKeyboardEventCode(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 // static | 212 // static |
| 213 DomCode KeycodeConverter::UsbKeycodeToDomCode(uint32_t usb_keycode) { |
| 214 for (size_t i = 0; i < kKeycodeMapEntries; ++i) { |
| 215 if (usb_keycode_map[i].usb_keycode == usb_keycode) |
| 216 return static_cast<DomCode>(usb_keycode); |
| 217 } |
| 218 return DomCode::NONE; |
| 219 } |
| 220 |
| 221 // static |
| 213 uint32_t KeycodeConverter::CodeToUsbKeycode(const char* code) { | 222 uint32_t KeycodeConverter::CodeToUsbKeycode(const char* code) { |
| 214 if (!code || | 223 if (!code || |
| 215 strcmp(code, InvalidKeyboardEventCode()) == 0) { | 224 strcmp(code, InvalidKeyboardEventCode()) == 0) { |
| 216 return InvalidUsbKeycode(); | 225 return InvalidUsbKeycode(); |
| 217 } | 226 } |
| 218 | 227 |
| 219 for (size_t i = 0; i < kKeycodeMapEntries; ++i) { | 228 for (size_t i = 0; i < kKeycodeMapEntries; ++i) { |
| 220 if (usb_keycode_map[i].code && | 229 if (usb_keycode_map[i].code && |
| 221 strcmp(usb_keycode_map[i].code, code) == 0) { | 230 strcmp(usb_keycode_map[i].code, code) == 0) { |
| 222 return usb_keycode_map[i].usb_keycode; | 231 return usb_keycode_map[i].usb_keycode; |
| 223 } | 232 } |
| 224 } | 233 } |
| 225 return InvalidUsbKeycode(); | 234 return InvalidUsbKeycode(); |
| 226 } | 235 } |
| 227 | 236 |
| 228 } // namespace ui | 237 } // namespace ui |
| OLD | NEW |