| 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 USB_KEYMAP(0x0c0224, 0x00a6, 0xe06a, 0xffff), // AC_Back | 369 USB_KEYMAP(0x0c0224, 0x00a6, 0xe06a, 0xffff), // AC_Back |
| 370 USB_KEYMAP(0x0c0225, 0x00a7, 0xe069, 0xffff), // AC_Forward | 370 USB_KEYMAP(0x0c0225, 0x00a7, 0xe069, 0xffff), // AC_Forward |
| 371 USB_KEYMAP(0x0c0226, 0x0000, 0xe068, 0xffff), // AC_Stop | 371 USB_KEYMAP(0x0c0226, 0x0000, 0xe068, 0xffff), // AC_Stop |
| 372 USB_KEYMAP(0x0c0227, 0x00b5, 0xe067, 0xffff), // AC_Refresh (Reload) | 372 USB_KEYMAP(0x0c0227, 0x00b5, 0xe067, 0xffff), // AC_Refresh (Reload) |
| 373 USB_KEYMAP(0x0c022a, 0x00a4, 0xe066, 0xffff), // AC_Bookmarks (Favorites) | 373 USB_KEYMAP(0x0c022a, 0x00a4, 0xe066, 0xffff), // AC_Bookmarks (Favorites) |
| 374 USB_KEYMAP(0x0c0289, 0x00f0, 0x0000, 0xffff), // AC_Reply | 374 USB_KEYMAP(0x0c0289, 0x00f0, 0x0000, 0xffff), // AC_Reply |
| 375 USB_KEYMAP(0x0c028b, 0x00f1, 0x0000, 0xffff), // AC_ForwardMsg (MailForward) | 375 USB_KEYMAP(0x0c028b, 0x00f1, 0x0000, 0xffff), // AC_ForwardMsg (MailForward) |
| 376 USB_KEYMAP(0x0c028c, 0x00ef, 0x0000, 0xffff), // AC_Send | 376 USB_KEYMAP(0x0c028c, 0x00ef, 0x0000, 0xffff), // AC_Send |
| 377 }; | 377 }; |
| 378 | 378 |
| 379 const uint16_t kInvalidKeycode = usb_keycode_map[0].native_keycode; | 379 inline uint16_t InvalidNativeKeycode() { |
| 380 return usb_keycode_map[0].native_keycode; |
| 381 } |
| 380 | 382 |
| 381 static uint16 UsbKeycodeToNativeKeycode(uint32_t usb_keycode) { | 383 inline uint16_t InvalidUsbKeycode() { |
| 384 return usb_keycode_map[0].usb_keycode; |
| 385 } |
| 386 |
| 387 inline uint16_t UsbKeycodeToNativeKeycode(uint32_t usb_keycode) { |
| 382 // Deal with some special-cases that don't fit the 1:1 mapping. | 388 // Deal with some special-cases that don't fit the 1:1 mapping. |
| 383 if (usb_keycode == 0x070032) // non-US hash. | 389 if (usb_keycode == 0x070032) // non-US hash. |
| 384 usb_keycode = 0x070031; // US backslash. | 390 usb_keycode = 0x070031; // US backslash. |
| 385 #if defined(OS_MACOSX) | 391 #if defined(OS_MACOSX) |
| 386 if (usb_keycode == 0x070046) // PrintScreen. | 392 if (usb_keycode == 0x070046) // PrintScreen. |
| 387 usb_keycode = 0x070068; // F13. | 393 usb_keycode = 0x070068; // F13. |
| 388 #endif | 394 #endif |
| 389 | 395 |
| 390 for (size_t i = 0; i < arraysize(usb_keycode_map); ++i) { | 396 for (size_t i = 0; i < arraysize(usb_keycode_map); ++i) { |
| 391 if (usb_keycode_map[i].usb_keycode == usb_keycode) | 397 if (usb_keycode_map[i].usb_keycode == usb_keycode) |
| 392 return usb_keycode_map[i].native_keycode; | 398 return usb_keycode_map[i].native_keycode; |
| 393 } | 399 } |
| 394 return kInvalidKeycode; | 400 return InvalidNativeKeycode(); |
| 395 } | 401 } |
| 402 |
| 403 inline uint32_t NativeKeycodeToUsbKeycode(uint16_t native_keycode) { |
| 404 for (size_t i = 0; i < arraysize(usb_keycode_map); ++i) { |
| 405 if (usb_keycode_map[i].native_keycode == native_keycode) |
| 406 return usb_keycode_map[i].usb_keycode; |
| 407 } |
| 408 return InvalidUsbKeycode(); |
| 409 } |
| OLD | NEW |