| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "remoting/client/native_device_keymap.h" | 5 #include "remoting/client/native_device_keymap.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | |
| 8 | |
| 9 namespace { | |
| 10 | |
| 11 // TODO(nicholss): Copied from Android, no changes yet. See how broken this is. | |
| 12 | |
| 13 // These must be defined in the same order as the Android keycodes in | |
| 14 // <android/keycodes.h> and | |
| 15 // "ui/events/keycodes/keyboard_code_conversion_android.cc" . Some of these | |
| 16 // mappings assume a US keyboard layout for now. | |
| 17 const uint32_t usb_keycodes[] = { | |
| 18 0, // UNKNOWN | |
| 19 0, // SOFT_LEFT | |
| 20 0, // SOFT_RIGHT | |
| 21 0, // HOME | |
| 22 0, // BACK | |
| 23 0, // CALL | |
| 24 0, // ENDCALL | |
| 25 | |
| 26 0x070027, // 0 | |
| 27 0x07001e, // 1 | |
| 28 0x07001f, // 2 | |
| 29 0x070020, // 3 | |
| 30 0x070021, // 4 | |
| 31 0x070022, // 5 | |
| 32 0x070023, // 6 | |
| 33 0x070024, // 7 | |
| 34 0x070025, // 8 | |
| 35 0x070026, // 9 | |
| 36 | |
| 37 0, // STAR | |
| 38 0, // POUND | |
| 39 0x070052, // DPAD_UP | |
| 40 0x070051, // DPAD_DOWN | |
| 41 0x070050, // DPAD_LEFT | |
| 42 0x07004f, // DPAD_RIGHT | |
| 43 0, // DPAD_CENTER | |
| 44 0, // VOLUME_UP | |
| 45 0, // VOLUME_DOWN | |
| 46 0, // POWER | |
| 47 0, // CAMERA | |
| 48 0, // CLEAR | |
| 49 | |
| 50 0x070004, // A | |
| 51 0x070005, // B | |
| 52 0x070006, // C | |
| 53 0x070007, // D | |
| 54 0x070008, // E | |
| 55 0x070009, // F | |
| 56 0x07000a, // G | |
| 57 0x07000b, // H | |
| 58 0x07000c, // I | |
| 59 0x07000d, // J | |
| 60 0x07000e, // K | |
| 61 0x07000f, // L | |
| 62 0x070010, // M | |
| 63 0x070011, // N | |
| 64 0x070012, // O | |
| 65 0x070013, // P | |
| 66 0x070014, // Q | |
| 67 0x070015, // R | |
| 68 0x070016, // S | |
| 69 0x070017, // T | |
| 70 0x070018, // U | |
| 71 0x070019, // V | |
| 72 0x07001a, // W | |
| 73 0x07001b, // X | |
| 74 0x07001c, // Y | |
| 75 0x07001d, // Z | |
| 76 | |
| 77 0x070036, // COMMA | |
| 78 0x070037, // PERIOD | |
| 79 | |
| 80 0x0700e2, // ALT_LEFT | |
| 81 0x0700e6, // ALT_RIGHT | |
| 82 0x0700e1, // SHIFT_LEFT | |
| 83 0x0700e5, // SHIFT_RIGHT | |
| 84 | |
| 85 0x07002b, // TAB | |
| 86 0x07002c, // SPACE | |
| 87 | |
| 88 0, // SYM | |
| 89 0, // EXPLORER | |
| 90 0, // ENVELOPE | |
| 91 | |
| 92 0x070028, // ENTER | |
| 93 0x07002a, // DEL (backspace) | |
| 94 | |
| 95 0x070035, // GRAVE (backtick) | |
| 96 0x07002d, // MINUS | |
| 97 0x07002e, // EQUALS | |
| 98 0x07002f, // LEFT_BRACKET | |
| 99 0x070030, // RIGHT_BRACKET | |
| 100 0x070031, // BACKSLASH | |
| 101 0x070033, // SEMICOLON | |
| 102 0x070034, // APOSTROPHE | |
| 103 0x070038, // SLASH | |
| 104 | |
| 105 0, // AT | |
| 106 0, // NUM | |
| 107 0, // HEADSETHOOK | |
| 108 0, // FOCUS | |
| 109 0, // PLUS | |
| 110 0, // MENU | |
| 111 0, // NOTIFICATION | |
| 112 0, // SEARCH | |
| 113 0, // MEDIA_PLAY_PAUSE | |
| 114 0, // MEDIA_STOP | |
| 115 0, // MEDIA_NEXT | |
| 116 0, // MEDIA_PREVIOUS | |
| 117 0, // MEDIA_REWIND | |
| 118 0, // MEDIA_FAST_FORWARD | |
| 119 0, // MUTE | |
| 120 | |
| 121 0x07004b, // PAGE_UP | |
| 122 0x07004e, // PAGE_DOWN | |
| 123 | |
| 124 0, // PICTSYMBOLS | |
| 125 0, // SWITCH_CHARSET | |
| 126 0, // BUTTON_A | |
| 127 0, // BUTTON_B | |
| 128 0, // BUTTON_C | |
| 129 0, // BUTTON_X | |
| 130 0, // BUTTON_Y | |
| 131 0, // BUTTON_Z | |
| 132 0, // BUTTON_L1 | |
| 133 0, // BUTTON_R1 | |
| 134 0, // BUTTON_L2 | |
| 135 0, // BUTTON_R2 | |
| 136 0, // BUTTON_THUMBL | |
| 137 0, // BUTTON_THUMBR | |
| 138 0, // BUTTON_START | |
| 139 0, // BUTTON_SELECT | |
| 140 0, // BUTTON_MODE | |
| 141 | |
| 142 0x070029, // ESCAPE | |
| 143 0x07004c, // FORWARD_DEL | |
| 144 | |
| 145 0x0700e0, // CTRL_LEFT | |
| 146 0x0700e4, // CTRL_RIGHT | |
| 147 0, // CAPS_LOCK | |
| 148 0, // SCROLL_LOCK | |
| 149 0x0700e3, // META_LEFT | |
| 150 0x0700e7, // META_RIGHT | |
| 151 0, // FUNCTION | |
| 152 | |
| 153 0x070046, // SYSRQ (printscreen) | |
| 154 0x070048, // BREAK (pause) | |
| 155 0x07004a, // MOVE_HOME (home) | |
| 156 0x07004d, // MOVE_END (end) | |
| 157 0x070049, // INSERT | |
| 158 | |
| 159 0, // FORWARD | |
| 160 0, // MEDIA_PLAY | |
| 161 0, // MEDIA_PAUSE | |
| 162 0, // MEDIA_CLOSE | |
| 163 0, // MEDIA_EJECT | |
| 164 0, // MEDIA_RECORD | |
| 165 | |
| 166 0x07003a, // F1 | |
| 167 0x07003b, // F2 | |
| 168 0x07003c, // F3 | |
| 169 0x07003d, // F4 | |
| 170 0x07003e, // F5 | |
| 171 0x07003f, // F6 | |
| 172 0x070040, // F7 | |
| 173 0x070041, // F8 | |
| 174 0x070042, // F9 | |
| 175 0x070043, // F10 | |
| 176 0x070044, // F11 | |
| 177 0x070045, // F12 | |
| 178 | |
| 179 0, // NUM_LOCK | |
| 180 | |
| 181 0x070062, // NUMPAD_0 | |
| 182 0x070059, // NUMPAD_1 | |
| 183 0x07005a, // NUMPAD_2 | |
| 184 0x07005b, // NUMPAD_3 | |
| 185 0x07005c, // NUMPAD_4 | |
| 186 0x07005d, // NUMPAD_5 | |
| 187 0x07005e, // NUMPAD_6 | |
| 188 0x07005f, // NUMPAD_7 | |
| 189 0x070060, // NUMPAD_8 | |
| 190 0x070061, // NUMPAD_9 | |
| 191 | |
| 192 0x070054, // NUMPAD_DIVIDE | |
| 193 0x070055, // NUMPAD_MULTIPLY | |
| 194 0x070056, // NUMPAD_SUBTRACT | |
| 195 0x070057, // NUMPAD_ADD | |
| 196 0x070063, // NUMPAD_DOT | |
| 197 0x070085, // NUMPAD_COMMA | |
| 198 0x070058, // NUMPAD_ENTER | |
| 199 0x070067, // NUMPAD_EQUALS | |
| 200 0x0700b6, // NUMPAD_LEFT_PAREN | |
| 201 0x0700b7, // NUMPAD_RIGHT_PAREN | |
| 202 }; | |
| 203 | |
| 204 } // namespace | |
| 205 | |
| 206 namespace remoting { | 7 namespace remoting { |
| 207 | 8 |
| 208 uint32_t NativeDeviceKeycodeToUsbKeycode(size_t device_keycode) { | 9 uint32_t NativeDeviceKeycodeToUsbKeycode(size_t device_keycode) { |
| 209 if (device_keycode >= sizeof(usb_keycodes) / sizeof(uint32_t)) { | 10 // For iOS we don't have access to device keycode. The keycode should already |
| 210 LOG(WARNING) << "Attempted to decode out-of-range Android keycode"; | 11 // be in the usb keycode format, so we can just return the same code. |
| 211 return 0; | 12 return device_keycode; |
| 212 } | |
| 213 | |
| 214 return usb_keycodes[device_keycode]; | |
| 215 } | 13 } |
| 216 | 14 |
| 217 } // namespace remoting | 15 } // namespace remoting |
| OLD | NEW |