MD Downloads: prevent search text from overlapping with the cancel search (X)
[chromium-blink-merge.git] / ui / events / keycodes / keyboard_code_conversion_android.cc
blob6d7a0cb564a67b165e52d0f710790314d0a337b3
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 "ui/events/keycodes/keyboard_code_conversion_android.h"
7 #include <android/keycodes.h>
9 namespace ui {
11 namespace {
13 // The Android NDK does not provide values for these yet:
14 enum {
15 AKEYCODE_ESCAPE = 111,
16 AKEYCODE_FORWARD_DEL = 112,
17 AKEYCODE_CTRL_LEFT = 113,
18 AKEYCODE_CTRL_RIGHT = 114,
19 AKEYCODE_CAPS_LOCK = 115,
20 AKEYCODE_SCROLL_LOCK = 116,
21 AKEYCODE_META_LEFT = 117,
22 AKEYCODE_META_RIGHT = 118,
23 AKEYCODE_BREAK = 121,
24 AKEYCODE_MOVE_HOME = 122,
25 AKEYCODE_MOVE_END = 123,
26 AKEYCODE_INSERT = 124,
27 AKEYCODE_MEDIA_PLAY = 126,
28 AKEYCODE_MEDIA_PAUSE = 127,
29 AKEYCODE_F1 = 131,
30 AKEYCODE_F2 = 132,
31 AKEYCODE_F3 = 133,
32 AKEYCODE_F4 = 134,
33 AKEYCODE_F5 = 135,
34 AKEYCODE_F6 = 136,
35 AKEYCODE_F7 = 137,
36 AKEYCODE_F8 = 138,
37 AKEYCODE_F9 = 139,
38 AKEYCODE_F10 = 140,
39 AKEYCODE_F11 = 141,
40 AKEYCODE_F12 = 142,
41 AKEYCODE_NUM_LOCK = 143,
42 AKEYCODE_NUMPAD_0 = 144,
43 AKEYCODE_NUMPAD_1 = 145,
44 AKEYCODE_NUMPAD_2 = 146,
45 AKEYCODE_NUMPAD_3 = 147,
46 AKEYCODE_NUMPAD_4 = 148,
47 AKEYCODE_NUMPAD_5 = 149,
48 AKEYCODE_NUMPAD_6 = 150,
49 AKEYCODE_NUMPAD_7 = 151,
50 AKEYCODE_NUMPAD_8 = 152,
51 AKEYCODE_NUMPAD_9 = 153,
52 AKEYCODE_NUMPAD_DIVIDE = 154,
53 AKEYCODE_NUMPAD_MULTIPLY = 155,
54 AKEYCODE_NUMPAD_SUBTRACT = 156,
55 AKEYCODE_NUMPAD_ADD = 157,
56 AKEYCODE_NUMPAD_DOT = 158,
57 AKEYCODE_VOLUME_MUTE = 164,
58 AKEYCODE_CHANNEL_UP = 166,
59 AKEYCODE_CHANNEL_DOWN = 167,
62 } // namespace
64 KeyboardCode KeyboardCodeFromAndroidKeyCode(int keycode) {
65 // Does not provide all key codes, and does not handle all keys.
66 switch (keycode) {
67 case AKEYCODE_DEL:
68 return VKEY_BACK;
69 case AKEYCODE_TAB:
70 return VKEY_TAB;
71 case AKEYCODE_CLEAR:
72 return VKEY_CLEAR;
73 case AKEYCODE_DPAD_CENTER:
74 case AKEYCODE_ENTER:
75 return VKEY_RETURN;
76 case AKEYCODE_SHIFT_LEFT:
77 return VKEY_LSHIFT;
78 case AKEYCODE_SHIFT_RIGHT:
79 return VKEY_RSHIFT;
80 case AKEYCODE_BACK:
81 return VKEY_BROWSER_BACK;
82 case AKEYCODE_FORWARD:
83 return VKEY_BROWSER_FORWARD;
84 case AKEYCODE_SPACE:
85 return VKEY_SPACE;
86 case AKEYCODE_MOVE_HOME:
87 return VKEY_HOME;
88 case AKEYCODE_DPAD_LEFT:
89 return VKEY_LEFT;
90 case AKEYCODE_DPAD_UP:
91 return VKEY_UP;
92 case AKEYCODE_DPAD_RIGHT:
93 return VKEY_RIGHT;
94 case AKEYCODE_DPAD_DOWN:
95 return VKEY_DOWN;
96 case AKEYCODE_0:
97 return VKEY_0;
98 case AKEYCODE_1:
99 return VKEY_1;
100 case AKEYCODE_2:
101 return VKEY_2;
102 case AKEYCODE_3:
103 return VKEY_3;
104 case AKEYCODE_4:
105 return VKEY_4;
106 case AKEYCODE_5:
107 return VKEY_5;
108 case AKEYCODE_6:
109 return VKEY_6;
110 case AKEYCODE_7:
111 return VKEY_7;
112 case AKEYCODE_8:
113 return VKEY_8;
114 case AKEYCODE_9:
115 return VKEY_9;
116 case AKEYCODE_A:
117 return VKEY_A;
118 case AKEYCODE_B:
119 return VKEY_B;
120 case AKEYCODE_C:
121 return VKEY_C;
122 case AKEYCODE_D:
123 return VKEY_D;
124 case AKEYCODE_E:
125 return VKEY_E;
126 case AKEYCODE_F:
127 return VKEY_F;
128 case AKEYCODE_G:
129 return VKEY_G;
130 case AKEYCODE_H:
131 return VKEY_H;
132 case AKEYCODE_I:
133 return VKEY_I;
134 case AKEYCODE_J:
135 return VKEY_J;
136 case AKEYCODE_K:
137 return VKEY_K;
138 case AKEYCODE_L:
139 return VKEY_L;
140 case AKEYCODE_M:
141 return VKEY_M;
142 case AKEYCODE_N:
143 return VKEY_N;
144 case AKEYCODE_O:
145 return VKEY_O;
146 case AKEYCODE_P:
147 return VKEY_P;
148 case AKEYCODE_Q:
149 return VKEY_Q;
150 case AKEYCODE_R:
151 return VKEY_R;
152 case AKEYCODE_S:
153 return VKEY_S;
154 case AKEYCODE_T:
155 return VKEY_T;
156 case AKEYCODE_U:
157 return VKEY_U;
158 case AKEYCODE_V:
159 return VKEY_V;
160 case AKEYCODE_W:
161 return VKEY_W;
162 case AKEYCODE_X:
163 return VKEY_X;
164 case AKEYCODE_Y:
165 return VKEY_Y;
166 case AKEYCODE_Z:
167 return VKEY_Z;
168 case AKEYCODE_VOLUME_DOWN:
169 return VKEY_VOLUME_DOWN;
170 case AKEYCODE_VOLUME_UP:
171 return VKEY_VOLUME_UP;
172 case AKEYCODE_MEDIA_NEXT:
173 return VKEY_MEDIA_NEXT_TRACK;
174 case AKEYCODE_MEDIA_PREVIOUS:
175 return VKEY_MEDIA_PREV_TRACK;
176 case AKEYCODE_MEDIA_STOP:
177 return VKEY_MEDIA_STOP;
178 case AKEYCODE_MEDIA_PAUSE:
179 return VKEY_MEDIA_PLAY_PAUSE;
180 // Colon key.
181 case AKEYCODE_SEMICOLON:
182 return VKEY_OEM_1;
183 case AKEYCODE_COMMA:
184 return VKEY_OEM_COMMA;
185 case AKEYCODE_MINUS:
186 return VKEY_OEM_MINUS;
187 case AKEYCODE_EQUALS:
188 return VKEY_OEM_PLUS;
189 case AKEYCODE_PERIOD:
190 return VKEY_OEM_PERIOD;
191 case AKEYCODE_SLASH:
192 return VKEY_OEM_2;
193 case AKEYCODE_LEFT_BRACKET:
194 return VKEY_OEM_4;
195 case AKEYCODE_BACKSLASH:
196 return VKEY_OEM_5;
197 case AKEYCODE_RIGHT_BRACKET:
198 return VKEY_OEM_6;
199 case AKEYCODE_MUTE:
200 case AKEYCODE_VOLUME_MUTE:
201 return VKEY_VOLUME_MUTE;
202 case AKEYCODE_ESCAPE:
203 return VKEY_ESCAPE;
204 case AKEYCODE_MEDIA_PLAY:
205 case AKEYCODE_MEDIA_PLAY_PAUSE:
206 return VKEY_MEDIA_PLAY_PAUSE;
207 case AKEYCODE_MOVE_END:
208 return VKEY_END;
209 case AKEYCODE_ALT_LEFT:
210 return VKEY_LMENU;
211 case AKEYCODE_ALT_RIGHT:
212 return VKEY_RMENU;
213 case AKEYCODE_GRAVE:
214 return VKEY_OEM_3;
215 case AKEYCODE_APOSTROPHE:
216 return VKEY_OEM_3;
217 case AKEYCODE_MEDIA_REWIND:
218 return VKEY_OEM_103;
219 case AKEYCODE_MEDIA_FAST_FORWARD:
220 return VKEY_OEM_104;
221 case AKEYCODE_PAGE_UP:
222 return VKEY_PRIOR;
223 case AKEYCODE_PAGE_DOWN:
224 return VKEY_NEXT;
225 case AKEYCODE_FORWARD_DEL:
226 return VKEY_DELETE;
227 case AKEYCODE_CTRL_LEFT:
228 return VKEY_LCONTROL;
229 case AKEYCODE_CTRL_RIGHT:
230 return VKEY_RCONTROL;
231 case AKEYCODE_CAPS_LOCK:
232 return VKEY_CAPITAL;
233 case AKEYCODE_SCROLL_LOCK:
234 return VKEY_SCROLL;
235 case AKEYCODE_META_LEFT:
236 return VKEY_LWIN;
237 case AKEYCODE_META_RIGHT:
238 return VKEY_RWIN;
239 case AKEYCODE_BREAK:
240 return VKEY_PAUSE;
241 case AKEYCODE_INSERT:
242 return VKEY_INSERT;
243 case AKEYCODE_F1:
244 return VKEY_F1;
245 case AKEYCODE_F2:
246 return VKEY_F2;
247 case AKEYCODE_F3:
248 return VKEY_F3;
249 case AKEYCODE_F4:
250 return VKEY_F4;
251 case AKEYCODE_F5:
252 return VKEY_F5;
253 case AKEYCODE_F6:
254 return VKEY_F6;
255 case AKEYCODE_F7:
256 return VKEY_F7;
257 case AKEYCODE_F8:
258 return VKEY_F8;
259 case AKEYCODE_F9:
260 return VKEY_F9;
261 case AKEYCODE_F10:
262 return VKEY_F10;
263 case AKEYCODE_F11:
264 return VKEY_F11;
265 case AKEYCODE_F12:
266 return VKEY_F12;
267 case AKEYCODE_NUM_LOCK:
268 return VKEY_NUMLOCK;
269 case AKEYCODE_NUMPAD_0:
270 return VKEY_NUMPAD0;
271 case AKEYCODE_NUMPAD_1:
272 return VKEY_NUMPAD1;
273 case AKEYCODE_NUMPAD_2:
274 return VKEY_NUMPAD2;
275 case AKEYCODE_NUMPAD_3:
276 return VKEY_NUMPAD3;
277 case AKEYCODE_NUMPAD_4:
278 return VKEY_NUMPAD4;
279 case AKEYCODE_NUMPAD_5:
280 return VKEY_NUMPAD5;
281 case AKEYCODE_NUMPAD_6:
282 return VKEY_NUMPAD6;
283 case AKEYCODE_NUMPAD_7:
284 return VKEY_NUMPAD7;
285 case AKEYCODE_NUMPAD_8:
286 return VKEY_NUMPAD8;
287 case AKEYCODE_NUMPAD_9:
288 return VKEY_NUMPAD9;
289 case AKEYCODE_NUMPAD_DIVIDE:
290 return VKEY_DIVIDE;
291 case AKEYCODE_NUMPAD_MULTIPLY:
292 return VKEY_MULTIPLY;
293 case AKEYCODE_NUMPAD_SUBTRACT:
294 return VKEY_SUBTRACT;
295 case AKEYCODE_NUMPAD_ADD:
296 return VKEY_ADD;
297 case AKEYCODE_NUMPAD_DOT:
298 return VKEY_DECIMAL;
299 case AKEYCODE_CHANNEL_UP:
300 return VKEY_PRIOR;
301 case AKEYCODE_CHANNEL_DOWN:
302 return VKEY_NEXT;
303 default:
304 return VKEY_UNKNOWN;
308 } // namespace ui