2 * Copyright 2007, The Android Open Source Project
3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
4 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
5 * Copyright (C) 2007 Holger Hans Peter Freyther
6 * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include "platform/KeyCodeConversion.h"
34 #include "platform/KeyboardCodes.h"
36 #include <android/keycodes.h>
40 // The Android NDK does not provide values for these yet:
42 AKEYCODE_ESCAPE = 111,
43 AKEYCODE_FORWARD_DEL = 112,
44 AKEYCODE_CTRL_LEFT = 113,
45 AKEYCODE_CTRL_RIGHT = 114,
46 AKEYCODE_CAPS_LOCK = 115,
47 AKEYCODE_SCROLL_LOCK = 116,
48 AKEYCODE_META_LEFT = 117,
49 AKEYCODE_META_RIGHT = 118,
51 AKEYCODE_INSERT = 124,
52 AKEYCODE_MEDIA_PLAY = 126,
53 AKEYCODE_MEDIA_PAUSE = 127,
66 AKEYCODE_NUM_LOCK = 143,
67 AKEYCODE_NUMPAD_0 = 144,
68 AKEYCODE_NUMPAD_1 = 145,
69 AKEYCODE_NUMPAD_2 = 146,
70 AKEYCODE_NUMPAD_3 = 147,
71 AKEYCODE_NUMPAD_4 = 148,
72 AKEYCODE_NUMPAD_5 = 149,
73 AKEYCODE_NUMPAD_6 = 150,
74 AKEYCODE_NUMPAD_7 = 151,
75 AKEYCODE_NUMPAD_8 = 152,
76 AKEYCODE_NUMPAD_9 = 153,
77 AKEYCODE_NUMPAD_DIVIDE = 154,
78 AKEYCODE_NUMPAD_MULTIPLY = 155,
79 AKEYCODE_NUMPAD_SUBTRACT = 156,
80 AKEYCODE_NUMPAD_ADD = 157,
81 AKEYCODE_NUMPAD_DOT = 158,
82 AKEYCODE_VOLUME_MUTE = 164,
83 AKEYCODE_CHANNEL_UP = 166,
84 AKEYCODE_CHANNEL_DOWN = 167,
87 int windowsKeyCodeForKeyEvent(unsigned keyCode)
89 // Does not provide all key codes, and does not handle all keys.
97 case AKEYCODE_DPAD_CENTER:
100 case AKEYCODE_SHIFT_LEFT:
102 case AKEYCODE_SHIFT_RIGHT:
104 // Back will serve as escape, although we may not have access to it.
111 case AKEYCODE_DPAD_LEFT:
113 case AKEYCODE_DPAD_UP:
115 case AKEYCODE_DPAD_RIGHT:
117 case AKEYCODE_DPAD_DOWN:
191 case AKEYCODE_VOLUME_DOWN:
192 return VKEY_VOLUME_DOWN;
193 case AKEYCODE_VOLUME_UP:
194 return VKEY_VOLUME_UP;
195 case AKEYCODE_MEDIA_NEXT:
196 return VKEY_MEDIA_NEXT_TRACK;
197 case AKEYCODE_MEDIA_PREVIOUS:
198 return VKEY_MEDIA_PREV_TRACK;
199 case AKEYCODE_MEDIA_STOP:
200 return VKEY_MEDIA_STOP;
201 case AKEYCODE_MEDIA_PAUSE:
202 return VKEY_MEDIA_PLAY_PAUSE;
204 case AKEYCODE_SEMICOLON:
207 return VKEY_OEM_COMMA;
209 return VKEY_OEM_MINUS;
210 case AKEYCODE_EQUALS:
211 return VKEY_OEM_PLUS;
212 case AKEYCODE_PERIOD:
213 return VKEY_OEM_PERIOD;
216 case AKEYCODE_LEFT_BRACKET:
218 case AKEYCODE_BACKSLASH:
220 case AKEYCODE_RIGHT_BRACKET:
223 case AKEYCODE_VOLUME_MUTE:
224 return VKEY_VOLUME_MUTE;
225 case AKEYCODE_ESCAPE:
227 case AKEYCODE_MEDIA_PLAY:
228 case AKEYCODE_MEDIA_PLAY_PAUSE:
229 return VKEY_MEDIA_PLAY_PAUSE;
232 case AKEYCODE_ALT_LEFT:
234 case AKEYCODE_ALT_RIGHT:
238 case AKEYCODE_APOSTROPHE:
240 case AKEYCODE_MEDIA_REWIND:
242 case AKEYCODE_MEDIA_FAST_FORWARD:
244 case AKEYCODE_PAGE_UP:
246 case AKEYCODE_PAGE_DOWN:
248 case AKEYCODE_FORWARD_DEL:
250 case AKEYCODE_CTRL_LEFT:
251 return VKEY_LCONTROL;
252 case AKEYCODE_CTRL_RIGHT:
253 return VKEY_RCONTROL;
254 case AKEYCODE_CAPS_LOCK:
256 case AKEYCODE_SCROLL_LOCK:
258 case AKEYCODE_META_LEFT:
260 case AKEYCODE_META_RIGHT:
264 case AKEYCODE_INSERT:
290 case AKEYCODE_NUM_LOCK:
292 case AKEYCODE_NUMPAD_0:
294 case AKEYCODE_NUMPAD_1:
296 case AKEYCODE_NUMPAD_2:
298 case AKEYCODE_NUMPAD_3:
300 case AKEYCODE_NUMPAD_4:
302 case AKEYCODE_NUMPAD_5:
304 case AKEYCODE_NUMPAD_6:
306 case AKEYCODE_NUMPAD_7:
308 case AKEYCODE_NUMPAD_8:
310 case AKEYCODE_NUMPAD_9:
312 case AKEYCODE_NUMPAD_DIVIDE:
314 case AKEYCODE_NUMPAD_MULTIPLY:
315 return VKEY_MULTIPLY;
316 case AKEYCODE_NUMPAD_SUBTRACT:
317 return VKEY_SUBTRACT;
318 case AKEYCODE_NUMPAD_ADD:
320 case AKEYCODE_NUMPAD_DOT:
322 case AKEYCODE_CHANNEL_UP:
324 case AKEYCODE_CHANNEL_DOWN:
331 } // namespace WebCore