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
3 // found in the LICENSE file.
5 #include "remoting/client/jni/android_keymap.h"
7 #include "base/logging.h"
11 // These must be defined in the same order as the Android keycodes in
12 // <android/keycodes.h> and
13 // "ui/events/keycodes/keyboard_code_conversion_android.cc" . Some of these
14 // mappings assume a US keyboard layout for now.
15 const uint32 usb_keycodes
[] = {
38 0x070051, // DPAD_DOWN
39 0x070050, // DPAD_LEFT
40 0x07004f, // DPAD_RIGHT
79 0x0700e6, // ALT_RIGHT
80 0x0700e1, // SHIFT_LEFT
81 0x0700e5, // SHIFT_RIGHT
91 0x07002a, // DEL (backspace)
93 0x070035, // GRAVE (backtick)
96 0x07002f, // LEFT_BRACKET
97 0x070030, // RIGHT_BRACKET
98 0x070031, // BACKSLASH
99 0x070033, // SEMICOLON
100 0x070034, // APOSTROPHE
111 0, // MEDIA_PLAY_PAUSE
116 0, // MEDIA_FAST_FORWARD
120 0x07004e, // PAGE_DOWN
141 0x07004c, // FORWARD_DEL
143 0x0700e0, // CTRL_LEFT
144 0x0700e4, // CTRL_RIGHT
147 0x0700e3, // META_LEFT
148 0x0700e7, // META_RIGHT
151 0x070046, // SYSRQ (printscreen)
152 0x070048, // BREAK (pause)
153 0x07004a, // MOVE_HOME (home)
154 0x07004d, // MOVE_END (end)
179 0x070062, // NUMPAD_0
180 0x070059, // NUMPAD_1
181 0x07005a, // NUMPAD_2
182 0x07005b, // NUMPAD_3
183 0x07005c, // NUMPAD_4
184 0x07005d, // NUMPAD_5
185 0x07005e, // NUMPAD_6
186 0x07005f, // NUMPAD_7
187 0x070060, // NUMPAD_8
188 0x070061, // NUMPAD_9
190 0x070054, // NUMPAD_DIVIDE
191 0x070055, // NUMPAD_MULTIPLY
192 0x070056, // NUMPAD_SUBTRACT
193 0x070057, // NUMPAD_ADD
194 0x070063, // NUMPAD_DOT
195 0x070085, // NUMPAD_COMMA
196 0x070058, // NUMPAD_ENTER
197 0x070067, // NUMPAD_EQUALS
198 0x0700b6, // NUMPAD_LEFT_PAREN
199 0x0700b7, // NUMPAD_RIGHT_PAREN
206 uint32
AndroidKeycodeToUsbKeycode(size_t android
) {
207 if (android
>= sizeof (usb_keycodes
) / sizeof (uint32
)) {
208 LOG(WARNING
) << "Attempted to decode out-of-range Android keycode";
212 return usb_keycodes
[android
];
215 } // namespace remoting