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

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

Issue 23542008: Add a CodeToNativeKeycode helper that converts UIEvent code to native code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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
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 90cd7ed71723e4ba6dcdb3ecb9248bac942140bd..2ec7db8edc39b9246b64993671096e0bc72a1b78 100644
--- a/ui/base/keycodes/usb_keycode_map.h
+++ b/ui/base/keycodes/usb_keycode_map.h
@@ -438,3 +438,14 @@ inline const char* UsbKeycodeToCode(uint32_t usb_keycode) {
}
return InvalidKeyboardEventCode();
}
+
+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.
+ if (code) {
+ // TODO: sort |usb_keycode_map| by |code| so we can use binary search here.
+ for (size_t i = 0; i < arraysize(usb_keycode_map); ++i) {
+ if (usb_keycode_map[i].code && strcmp(usb_keycode_map[i].code, code) == 0)
+ return usb_keycode_map[i].native_keycode;
+ }
+ }
+ return InvalidNativeKeycode();
+}

Powered by Google App Engine
This is Rietveld 408576698