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

Side by Side Diff: ui/events/keycodes/keyboard_code_conversion_android.cc

Issue 1310513010: Support DomCode on Android devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_evdev
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
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/keyboard_code_conversion_android.h" 5 #include "ui/events/keycodes/keyboard_code_conversion_android.h"
6 6
7 #include <android/keycodes.h> 7 #include <android/keycodes.h>
8 #include "base/macros.h"
9 #include "ui/events/keycodes/dom/dom_code.h"
8 10
9 namespace ui { 11 namespace ui {
10 12
11 namespace { 13 namespace {
12 14
15 struct KeyCodeDomCodeEntry {
16 uint32_t usb_keycode;
17 int android_keycode;
18 };
19
20 #define USB_KEYMAP_DECLARATION const KeyCodeDomCodeEntry usb_keycode_map[] =
21 #define USB_KEYMAP(usb, android, evdev, xkb, win, mac, code, id) {usb, android}
22 #include "ui/events/keycodes/dom/keycode_converter_data.inc"
23 #undef USB_KEYMAP
24 #undef USB_KEYMAP_DECLARATION
25
26 const size_t kKeycodeMapEntries = arraysize(usb_keycode_map);
27
13 // The Android NDK does not provide values for these yet: 28 // The Android NDK does not provide values for these yet:
14 enum { 29 enum {
15 AKEYCODE_ESCAPE = 111, 30 AKEYCODE_ESCAPE = 111,
16 AKEYCODE_FORWARD_DEL = 112, 31 AKEYCODE_FORWARD_DEL = 112,
17 AKEYCODE_CTRL_LEFT = 113, 32 AKEYCODE_CTRL_LEFT = 113,
18 AKEYCODE_CTRL_RIGHT = 114, 33 AKEYCODE_CTRL_RIGHT = 114,
19 AKEYCODE_CAPS_LOCK = 115, 34 AKEYCODE_CAPS_LOCK = 115,
20 AKEYCODE_SCROLL_LOCK = 116, 35 AKEYCODE_SCROLL_LOCK = 116,
21 AKEYCODE_META_LEFT = 117, 36 AKEYCODE_META_LEFT = 117,
22 AKEYCODE_META_RIGHT = 118, 37 AKEYCODE_META_RIGHT = 118,
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 return VKEY_DECIMAL; 313 return VKEY_DECIMAL;
299 case AKEYCODE_CHANNEL_UP: 314 case AKEYCODE_CHANNEL_UP:
300 return VKEY_PRIOR; 315 return VKEY_PRIOR;
301 case AKEYCODE_CHANNEL_DOWN: 316 case AKEYCODE_CHANNEL_DOWN:
302 return VKEY_NEXT; 317 return VKEY_NEXT;
303 default: 318 default:
304 return VKEY_UNKNOWN; 319 return VKEY_UNKNOWN;
305 } 320 }
306 } 321 }
307 322
323 DomCode DomCodeFromAndroidKeyCode(int keycode) {
324 for (size_t i = 0; i < kKeycodeMapEntries; ++i) {
325 if (usb_keycode_map[i].android_keycode == keycode)
326 return static_cast<DomCode>(usb_keycode_map[i].usb_keycode);
327 }
328 return DomCode::NONE;
329 }
330
308 } // namespace ui 331 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698