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 // Data in this file was created by referencing: | 5 // Data in this file was created by referencing: |
6 // USB HID Usage Tables (v1.11) 27 June 2001 | 6 // USB HID Usage Tables (v1.11) 27 June 2001 |
7 // HIToolbox/Events.h (Mac) | 7 // HIToolbox/Events.h (Mac) |
8 | 8 |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 return InvalidUsbKeycode(); | 431 return InvalidUsbKeycode(); |
432 } | 432 } |
433 | 433 |
434 inline const char* UsbKeycodeToCode(uint32_t usb_keycode) { | 434 inline const char* UsbKeycodeToCode(uint32_t usb_keycode) { |
435 for (size_t i = 0; i < arraysize(usb_keycode_map); ++i) { | 435 for (size_t i = 0; i < arraysize(usb_keycode_map); ++i) { |
436 if (usb_keycode_map[i].usb_keycode == usb_keycode) | 436 if (usb_keycode_map[i].usb_keycode == usb_keycode) |
437 return usb_keycode_map[i].code; | 437 return usb_keycode_map[i].code; |
438 } | 438 } |
439 return InvalidKeyboardEventCode(); | 439 return InvalidKeyboardEventCode(); |
440 } | 440 } |
441 | |
442 inline uint16_t CodeToNativeKeycode(const char* code) { | |
garykac
2013/09/04 23:04:03
Please move this up next to NativeKeycodeToCode. T
weitao
2013/09/04 23:41:27
Done.
| |
443 if (code) { | |
444 // TODO: sort |usb_keycode_map| by |code| so we can use binary search here. | |
445 for (size_t i = 0; i < arraysize(usb_keycode_map); ++i) { | |
446 if (usb_keycode_map[i].code && strcmp(usb_keycode_map[i].code, code) == 0) | |
447 return usb_keycode_map[i].native_keycode; | |
448 } | |
449 } | |
450 return InvalidNativeKeycode(); | |
451 } | |
OLD | NEW |