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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 if (usb_keycode_map[i].usb_keycode == usb_keycode) { | 197 if (usb_keycode_map[i].usb_keycode == usb_keycode) { |
198 if (usb_keycode_map[i].code) | 198 if (usb_keycode_map[i].code) |
199 return usb_keycode_map[i].code; | 199 return usb_keycode_map[i].code; |
200 break; | 200 break; |
201 } | 201 } |
202 } | 202 } |
203 return ""; | 203 return ""; |
204 } | 204 } |
205 | 205 |
206 // static | 206 // static |
207 DomCode KeycodeConverter::UsbKeycodeToDomCode(uint32_t usb_keycode) { | |
208 for (size_t i = 0; i < kKeycodeMapEntries; ++i) { | |
209 if (usb_keycode_map[i].usb_keycode == usb_keycode) | |
210 return static_cast<DomCode>(usb_keycode); | |
Wez
2014/12/09 01:36:44
Return usb_keycode_map[i].id rather than the stati
kelvinp
2014/12/09 20:24:18
Unfortunately, the id field does not exist on Linu
| |
211 } | |
212 return DomCode::NONE; | |
213 } | |
214 | |
215 // static | |
207 uint32_t KeycodeConverter::CodeToUsbKeycode(const char* code) { | 216 uint32_t KeycodeConverter::CodeToUsbKeycode(const char* code) { |
208 if (!code || !*code) | 217 if (!code || !*code) |
209 return InvalidUsbKeycode(); | 218 return InvalidUsbKeycode(); |
210 | 219 |
211 for (size_t i = 0; i < kKeycodeMapEntries; ++i) { | 220 for (size_t i = 0; i < kKeycodeMapEntries; ++i) { |
212 if (usb_keycode_map[i].code && | 221 if (usb_keycode_map[i].code && |
213 strcmp(usb_keycode_map[i].code, code) == 0) { | 222 strcmp(usb_keycode_map[i].code, code) == 0) { |
214 return usb_keycode_map[i].usb_keycode; | 223 return usb_keycode_map[i].usb_keycode; |
215 } | 224 } |
216 } | 225 } |
217 return InvalidUsbKeycode(); | 226 return InvalidUsbKeycode(); |
218 } | 227 } |
219 | 228 |
220 } // namespace ui | 229 } // namespace ui |
OLD | NEW |