Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: ui/base/keycodes/usb_keycode_map.h

Issue 12320014: Switch Pepper Linux to use shared USB<->native key conversion table. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix missed kInvalidKeycode. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/event_executor_win.cc ('k') | ui/base/keycodes/usb_keycode_map_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/keycodes/usb_keycode_map.h
diff --git a/ui/base/keycodes/usb_keycode_map.h b/ui/base/keycodes/usb_keycode_map.h
index 53b8627a1988c0a1e3086f4f80d96cebb7ceb67c..6549bf8e335638f1e38bed11fc3deda7d3750b5f 100644
--- a/ui/base/keycodes/usb_keycode_map.h
+++ b/ui/base/keycodes/usb_keycode_map.h
@@ -376,9 +376,15 @@ const usb_keymap usb_keycode_map[] = {
USB_KEYMAP(0x0c028c, 0x00ef, 0x0000, 0xffff), // AC_Send
};
-const uint16_t kInvalidKeycode = usb_keycode_map[0].native_keycode;
+inline uint16_t InvalidNativeKeycode() {
+ return usb_keycode_map[0].native_keycode;
+}
+
+inline uint16_t InvalidUsbKeycode() {
+ return usb_keycode_map[0].usb_keycode;
+}
-static uint16 UsbKeycodeToNativeKeycode(uint32_t usb_keycode) {
+inline uint16_t UsbKeycodeToNativeKeycode(uint32_t usb_keycode) {
// Deal with some special-cases that don't fit the 1:1 mapping.
if (usb_keycode == 0x070032) // non-US hash.
usb_keycode = 0x070031; // US backslash.
@@ -391,5 +397,13 @@ static uint16 UsbKeycodeToNativeKeycode(uint32_t usb_keycode) {
if (usb_keycode_map[i].usb_keycode == usb_keycode)
return usb_keycode_map[i].native_keycode;
}
- return kInvalidKeycode;
+ return InvalidNativeKeycode();
+}
+
+inline uint32_t NativeKeycodeToUsbKeycode(uint16_t native_keycode) {
+ for (size_t i = 0; i < arraysize(usb_keycode_map); ++i) {
+ if (usb_keycode_map[i].native_keycode == native_keycode)
+ return usb_keycode_map[i].usb_keycode;
+ }
+ return InvalidUsbKeycode();
}
« no previous file with comments | « remoting/host/event_executor_win.cc ('k') | ui/base/keycodes/usb_keycode_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698