1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
/* Copyright 2012 Mozilla Foundation and Mozilla contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef GONKKEYMAPPING_H
#define GONKKEYMAPPING_H
#include "libui/android_keycodes.h"
#include "mozilla/EventForwards.h"
namespace mozilla {
namespace widget {
/* See libui/KeycodeLabels.h for the mapping */
static const unsigned long kKeyMapping[] = {
0,
0, // SOFT_LEFT
0, // SOFT_RIGHT
NS_VK_HOME, // HOME
NS_VK_ESCAPE, // BACK
0, // CALL
NS_VK_SLEEP, // ENDCALL
NS_VK_0,
NS_VK_1,
NS_VK_2,
NS_VK_3,
NS_VK_4,
NS_VK_5,
NS_VK_6,
NS_VK_7,
NS_VK_8,
NS_VK_9,
NS_VK_ASTERISK,
NS_VK_HASH,
NS_VK_UP,
NS_VK_DOWN,
NS_VK_LEFT,
NS_VK_RIGHT,
NS_VK_RETURN,
NS_VK_VOLUME_UP,
NS_VK_VOLUME_DOWN,
NS_VK_SLEEP, // POWER
NS_VK_PRINTSCREEN, // CAMERA
NS_VK_CLEAR,
NS_VK_A,
NS_VK_B,
NS_VK_C,
NS_VK_D,
NS_VK_E,
NS_VK_F,
NS_VK_G,
NS_VK_H,
NS_VK_I,
NS_VK_J,
NS_VK_K,
NS_VK_L,
NS_VK_M,
NS_VK_N,
NS_VK_O,
NS_VK_P,
NS_VK_Q,
NS_VK_R,
NS_VK_S,
NS_VK_T,
NS_VK_U,
NS_VK_V,
NS_VK_W,
NS_VK_X,
NS_VK_Y,
NS_VK_Z,
NS_VK_COMMA,
NS_VK_PERIOD,
0,
0,
0,
0,
NS_VK_TAB,
NS_VK_SPACE,
NS_VK_META, // SYM
0, // EXPLORER
0, // ENVELOPE
NS_VK_RETURN, // ENTER
NS_VK_BACK,
NS_VK_BACK_QUOTE, // GRAVE
NS_VK_HYPHEN_MINUS,
NS_VK_EQUALS,
NS_VK_OPEN_BRACKET,
NS_VK_CLOSE_BRACKET,
NS_VK_BACK_SLASH,
NS_VK_SEMICOLON,
NS_VK_QUOTE,
NS_VK_SLASH,
NS_VK_AT,
0, // NUM
NS_VK_F1, // HEADSETHOOK
0, // FOCUS
NS_VK_PLUS,
NS_VK_CONTEXT_MENU,
0, // NOTIFICATION
NS_VK_F5, // SEARCH
0, // MEDIA_PLAY_PAUSE
0, // MEDIA_STOP
0, // MEDIA_NEXT
0, // MEDIA_PREVIOUS
0, // MEDIA_REWIND
0, // MEDIA_FAST_FORWARD
0, // MUTE
NS_VK_PAGE_UP,
NS_VK_PAGE_DOWN,
0, // PICTSYMBOLS
0, // SWITCH_CHARSET
0, // BUTTON_A
0, // BUTTON_B
0, // BUTTON_C
0, // BUTTON_X
0, // BUTTON_Y
0, // BUTTON_Z
0, // BUTTON_L1
0, // BUTTON_R1
0, // BUTTON_L2
0, // BUTTON_R2
0, // BUTTON_THUMBL
0, // BUTTON_THUMBR
0, // BUTTON_START
0, // BUTTON_SELECT
0, // BUTTON_MODE
NS_VK_ESCAPE,
NS_VK_DELETE,
0, // CTRL_LEFT
0, // CTRL_RIGHT
NS_VK_CAPS_LOCK,
NS_VK_SCROLL_LOCK,
0, // META_LEFT
0, // META_RIGHT
0, // FUNCTION
0, // SYSRQ
0, // BREAK
NS_VK_HOME, // MOVE_HOME
NS_VK_END,
NS_VK_INSERT,
0, // FORWARD
0, // MEDIA_PLAY
0, // MEDIA_PAUSE
0, // MEDIA_CLOSE
0, // MEDIA_EJECT
0, // MEDIA_RECORD
NS_VK_F1,
NS_VK_F2,
NS_VK_F3,
NS_VK_F4,
NS_VK_F5,
NS_VK_F6,
NS_VK_F7,
NS_VK_F8,
NS_VK_F9,
NS_VK_F10,
NS_VK_F11,
NS_VK_F12,
NS_VK_NUM_LOCK,
NS_VK_NUMPAD0,
NS_VK_NUMPAD1,
NS_VK_NUMPAD2,
NS_VK_NUMPAD3,
NS_VK_NUMPAD4,
NS_VK_NUMPAD5,
NS_VK_NUMPAD6,
NS_VK_NUMPAD7,
NS_VK_NUMPAD8,
NS_VK_NUMPAD9,
NS_VK_DIVIDE,
NS_VK_MULTIPLY,
NS_VK_SUBTRACT,
NS_VK_ADD,
NS_VK_PERIOD,
NS_VK_COMMA,
NS_VK_RETURN,
NS_VK_EQUALS,
0, // NUMPAD_LEFT_PAREN
0, // NUMPAD_RIGHT_PAREN
NS_VK_VOLUME_MUTE,
// There are more but we don't map them
};
static KeyNameIndex GetKeyNameIndex(int aKeyCode)
{
switch (aKeyCode) {
#define NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, aKeyNameIndex) \
case aNativeKey: return aKeyNameIndex;
#include "NativeKeyToDOMKeyName.h"
#undef NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX
case AKEYCODE_0:
case AKEYCODE_1:
case AKEYCODE_2:
case AKEYCODE_3:
case AKEYCODE_4:
case AKEYCODE_5:
case AKEYCODE_6:
case AKEYCODE_7:
case AKEYCODE_8:
case AKEYCODE_9:
case AKEYCODE_STAR:
case AKEYCODE_POUND:
case AKEYCODE_A:
case AKEYCODE_B:
case AKEYCODE_C:
case AKEYCODE_D:
case AKEYCODE_E:
case AKEYCODE_F:
case AKEYCODE_G:
case AKEYCODE_H:
case AKEYCODE_I:
case AKEYCODE_J:
case AKEYCODE_K:
case AKEYCODE_L:
case AKEYCODE_M:
case AKEYCODE_N:
case AKEYCODE_O:
case AKEYCODE_P:
case AKEYCODE_Q:
case AKEYCODE_R:
case AKEYCODE_S:
case AKEYCODE_T:
case AKEYCODE_U:
case AKEYCODE_V:
case AKEYCODE_W:
case AKEYCODE_X:
case AKEYCODE_Y:
case AKEYCODE_Z:
case AKEYCODE_COMMA:
case AKEYCODE_PERIOD:
case AKEYCODE_SPACE:
case AKEYCODE_GRAVE:
case AKEYCODE_MINUS:
case AKEYCODE_EQUALS:
case AKEYCODE_LEFT_BRACKET:
case AKEYCODE_RIGHT_BRACKET:
case AKEYCODE_BACKSLASH:
case AKEYCODE_SEMICOLON:
case AKEYCODE_APOSTROPHE:
case AKEYCODE_SLASH:
case AKEYCODE_AT:
case AKEYCODE_PLUS:
case AKEYCODE_NUMPAD_0:
case AKEYCODE_NUMPAD_1:
case AKEYCODE_NUMPAD_2:
case AKEYCODE_NUMPAD_3:
case AKEYCODE_NUMPAD_4:
case AKEYCODE_NUMPAD_5:
case AKEYCODE_NUMPAD_6:
case AKEYCODE_NUMPAD_7:
case AKEYCODE_NUMPAD_8:
case AKEYCODE_NUMPAD_9:
case AKEYCODE_NUMPAD_DIVIDE:
case AKEYCODE_NUMPAD_MULTIPLY:
case AKEYCODE_NUMPAD_SUBTRACT:
case AKEYCODE_NUMPAD_ADD:
case AKEYCODE_NUMPAD_DOT:
case AKEYCODE_NUMPAD_COMMA:
case AKEYCODE_NUMPAD_EQUALS:
case AKEYCODE_NUMPAD_LEFT_PAREN:
case AKEYCODE_NUMPAD_RIGHT_PAREN:
return KEY_NAME_INDEX_USE_STRING;
default:
return KEY_NAME_INDEX_Unidentified;
}
}
static CodeNameIndex GetCodeNameIndex(int aScanCode)
{
switch (aScanCode) {
#define NS_NATIVE_KEY_TO_DOM_CODE_NAME_INDEX(aNativeKey, aCodeNameIndex) \
case aNativeKey: return aCodeNameIndex;
#include "NativeKeyToDOMCodeName.h"
#undef NS_NATIVE_KEY_TO_DOM_CODE_NAME_INDEX
default:
return CODE_NAME_INDEX_UNKNOWN;
}
}
} // namespace widget
} // namespace mozilla
#endif /* GONKKEYMAPPING_H */
|