| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/events/keycodes/dom3/dom_code.h" | 8 #include "ui/events/keycodes/dom3/dom_code.h" |
| 9 #include "ui/events/keycodes/dom3/dom_key.h" | 9 #include "ui/events/keycodes/dom3/dom_key.h" |
| 10 | 10 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 if (usb_keycode_map[i].native_keycode == native_keycode) { | 86 if (usb_keycode_map[i].native_keycode == native_keycode) { |
| 87 if (usb_keycode_map[i].code != NULL) | 87 if (usb_keycode_map[i].code != NULL) |
| 88 return static_cast<DomCode>(usb_keycode_map[i].usb_keycode); | 88 return static_cast<DomCode>(usb_keycode_map[i].usb_keycode); |
| 89 break; | 89 break; |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 return DomCode::NONE; | 92 return DomCode::NONE; |
| 93 } | 93 } |
| 94 | 94 |
| 95 // static | 95 // static |
| 96 int KeycodeConverter::CodeToNativeKeycode(const char* code) { | |
| 97 if (!code || !*code) | |
| 98 return InvalidNativeKeycode(); | |
| 99 | |
| 100 for (size_t i = 0; i < kKeycodeMapEntries; ++i) { | |
| 101 if (usb_keycode_map[i].code && | |
| 102 strcmp(usb_keycode_map[i].code, code) == 0) { | |
| 103 return usb_keycode_map[i].native_keycode; | |
| 104 } | |
| 105 } | |
| 106 return InvalidNativeKeycode(); | |
| 107 } | |
| 108 | |
| 109 // static | |
| 110 int KeycodeConverter::DomCodeToNativeKeycode(DomCode code) { | 96 int KeycodeConverter::DomCodeToNativeKeycode(DomCode code) { |
| 111 return UsbKeycodeToNativeKeycode(static_cast<uint32_t>(code)); | 97 return UsbKeycodeToNativeKeycode(static_cast<uint32_t>(code)); |
| 112 } | 98 } |
| 113 | 99 |
| 114 // static | 100 // static |
| 115 DomCode KeycodeConverter::CodeStringToDomCode(const char* code) { | 101 DomCode KeycodeConverter::CodeStringToDomCode(const char* code) { |
| 116 if (!code || !*code) { | 102 if (!code || !*code) { |
| 117 LOG(WARNING) << "empty code string"; | 103 LOG(WARNING) << "empty code string"; |
| 118 return DomCode::NONE; | 104 return DomCode::NONE; |
| 119 } | 105 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 for (size_t i = 0; i < kKeycodeMapEntries; ++i) { | 204 for (size_t i = 0; i < kKeycodeMapEntries; ++i) { |
| 219 if (usb_keycode_map[i].code && | 205 if (usb_keycode_map[i].code && |
| 220 strcmp(usb_keycode_map[i].code, code) == 0) { | 206 strcmp(usb_keycode_map[i].code, code) == 0) { |
| 221 return usb_keycode_map[i].usb_keycode; | 207 return usb_keycode_map[i].usb_keycode; |
| 222 } | 208 } |
| 223 } | 209 } |
| 224 return InvalidUsbKeycode(); | 210 return InvalidUsbKeycode(); |
| 225 } | 211 } |
| 226 | 212 |
| 227 } // namespace ui | 213 } // namespace ui |
| OLD | NEW |