FreeRDP
Loading...
Searching...
No Matches
KeyboardMapper.java
1/*
2 Android Keyboard Mapping
3
4 Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
6 This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7 If a copy of the MPL was not distributed with this file, You can obtain one at
8 http://mozilla.org/MPL/2.0/.
9*/
10
11package com.freerdp.freerdpcore.utils;
12
13import android.content.Context;
14import android.view.KeyCharacterMap;
15import android.view.KeyEvent;
16
17import com.freerdp.freerdpcore.R;
18import com.freerdp.freerdpcore.services.LibFreeRDP;
19
20public class KeyboardMapper
21{
22 public static final int KEYBOARD_TYPE_FUNCTIONKEYS = 1;
23 public static final int KEYBOARD_TYPE_NUMPAD = 2;
24
25 // defines key states for modifier keys - locked means on and no auto-release if an other key is
26 // pressed
27 public static final int KEYSTATE_ON = 1;
28 public static final int KEYSTATE_LOCKED = 2;
29 public static final int KEYSTATE_OFF = 3;
30 final static int VK_LBUTTON = 0x01;
31 final static int VK_RBUTTON = 0x02;
32 final static int VK_CANCEL = 0x03;
33 final static int VK_MBUTTON = 0x04;
34 final static int VK_XBUTTON1 = 0x05;
35 final static int VK_XBUTTON2 = 0x06;
36 final static int VK_BACK = 0x08;
37 final static int VK_TAB = 0x09;
38 final static int VK_CLEAR = 0x0C;
39 final static int VK_RETURN = 0x0D;
40 final static int VK_SHIFT = 0x10;
41 final static int VK_CONTROL = 0x11;
42 final static int VK_MENU = 0x12;
43 final static int VK_PAUSE = 0x13;
44 final static int VK_CAPITAL = 0x14;
45 final static int VK_KANA = 0x15;
46 final static int VK_HANGUEL = 0x15;
47 final static int VK_HANGUL = 0x15;
48 final static int VK_JUNJA = 0x17;
49 final static int VK_FINAL = 0x18;
50 final static int VK_HANJA = 0x19;
51 final static int VK_KANJI = 0x19;
52 final static int VK_ESCAPE = 0x1B;
53 final static int VK_CONVERT = 0x1C;
54 final static int VK_NONCONVERT = 0x1D;
55 final static int VK_ACCEPT = 0x1E;
56 final static int VK_MODECHANGE = 0x1F;
57 final static int VK_SPACE = 0x20;
58 final static int VK_PRIOR = 0x21;
59 final static int VK_NEXT = 0x22;
60 final static int VK_END = 0x23;
61 final static int VK_HOME = 0x24;
62 final static int VK_LEFT = 0x25;
63 final static int VK_UP = 0x26;
64 final static int VK_RIGHT = 0x27;
65 final static int VK_DOWN = 0x28;
66 final static int VK_SELECT = 0x29;
67 final static int VK_PRINT = 0x2A;
68 final static int VK_EXECUTE = 0x2B;
69 final static int VK_SNAPSHOT = 0x2C;
70 final static int VK_INSERT = 0x2D;
71 final static int VK_DELETE = 0x2E;
72 final static int VK_HELP = 0x2F;
73 final static int VK_KEY_0 = 0x30;
74 final static int VK_KEY_1 = 0x31;
75 final static int VK_KEY_2 = 0x32;
76 final static int VK_KEY_3 = 0x33;
77 final static int VK_KEY_4 = 0x34;
78 final static int VK_KEY_5 = 0x35;
79 final static int VK_KEY_6 = 0x36;
80 final static int VK_KEY_7 = 0x37;
81 final static int VK_KEY_8 = 0x38;
82 final static int VK_KEY_9 = 0x39;
83 final static int VK_KEY_A = 0x41;
84 final static int VK_KEY_B = 0x42;
85 final static int VK_KEY_C = 0x43;
86 final static int VK_KEY_D = 0x44;
87 final static int VK_KEY_E = 0x45;
88 final static int VK_KEY_F = 0x46;
89 final static int VK_KEY_G = 0x47;
90 final static int VK_KEY_H = 0x48;
91 final static int VK_KEY_I = 0x49;
92 final static int VK_KEY_J = 0x4A;
93 final static int VK_KEY_K = 0x4B;
94 final static int VK_KEY_L = 0x4C;
95 final static int VK_KEY_M = 0x4D;
96 final static int VK_KEY_N = 0x4E;
97 final static int VK_KEY_O = 0x4F;
98 final static int VK_KEY_P = 0x50;
99 final static int VK_KEY_Q = 0x51;
100 final static int VK_KEY_R = 0x52;
101 final static int VK_KEY_S = 0x53;
102 final static int VK_KEY_T = 0x54;
103 final static int VK_KEY_U = 0x55;
104 final static int VK_KEY_V = 0x56;
105 final static int VK_KEY_W = 0x57;
106 final static int VK_KEY_X = 0x58;
107 final static int VK_KEY_Y = 0x59;
108 final static int VK_KEY_Z = 0x5A;
109 final static int VK_LWIN = 0x5B;
110 final static int VK_RWIN = 0x5C;
111 final static int VK_APPS = 0x5D;
112 final static int VK_SLEEP = 0x5F;
113 final static int VK_NUMPAD0 = 0x60;
114 final static int VK_NUMPAD1 = 0x61;
115 final static int VK_NUMPAD2 = 0x62;
116 final static int VK_NUMPAD3 = 0x63;
117 final static int VK_NUMPAD4 = 0x64;
118 final static int VK_NUMPAD5 = 0x65;
119 final static int VK_NUMPAD6 = 0x66;
120 final static int VK_NUMPAD7 = 0x67;
121 final static int VK_NUMPAD8 = 0x68;
122 final static int VK_NUMPAD9 = 0x69;
123 final static int VK_MULTIPLY = 0x6A;
124 final static int VK_ADD = 0x6B;
125 final static int VK_SEPARATOR = 0x6C;
126 final static int VK_SUBTRACT = 0x6D;
127 final static int VK_DECIMAL = 0x6E;
128 final static int VK_DIVIDE = 0x6F;
129 final static int VK_F1 = 0x70;
130 final static int VK_F2 = 0x71;
131 final static int VK_F3 = 0x72;
132 final static int VK_F4 = 0x73;
133 final static int VK_F5 = 0x74;
134 final static int VK_F6 = 0x75;
135 final static int VK_F7 = 0x76;
136 final static int VK_F8 = 0x77;
137 final static int VK_F9 = 0x78;
138 final static int VK_F10 = 0x79;
139 final static int VK_F11 = 0x7A;
140 final static int VK_F12 = 0x7B;
141 final static int VK_F13 = 0x7C;
142 final static int VK_F14 = 0x7D;
143 final static int VK_F15 = 0x7E;
144 final static int VK_F16 = 0x7F;
145 final static int VK_F17 = 0x80;
146 final static int VK_F18 = 0x81;
147 final static int VK_F19 = 0x82;
148 final static int VK_F20 = 0x83;
149 final static int VK_F21 = 0x84;
150 final static int VK_F22 = 0x85;
151 final static int VK_F23 = 0x86;
152 final static int VK_F24 = 0x87;
153 final static int VK_NUMLOCK = 0x90;
154 final static int VK_SCROLL = 0x91;
155 final static int VK_LSHIFT = 0xA0;
156 final static int VK_RSHIFT = 0xA1;
157 final static int VK_LCONTROL = 0xA2;
158 final static int VK_RCONTROL = 0xA3;
159 final static int VK_LMENU = 0xA4;
160 final static int VK_RMENU = 0xA5;
161 final static int VK_BROWSER_BACK = 0xA6;
162 final static int VK_BROWSER_FORWARD = 0xA7;
163 final static int VK_BROWSER_REFRESH = 0xA8;
164 final static int VK_BROWSER_STOP = 0xA9;
165 final static int VK_BROWSER_SEARCH = 0xAA;
166 final static int VK_BROWSER_FAVORITES = 0xAB;
167 final static int VK_BROWSER_HOME = 0xAC;
168 final static int VK_VOLUME_MUTE = 0xAD;
169 final static int VK_VOLUME_DOWN = 0xAE;
170 final static int VK_VOLUME_UP = 0xAF;
171 final static int VK_MEDIA_NEXT_TRACK = 0xB0;
172 final static int VK_MEDIA_PREV_TRACK = 0xB1;
173 final static int VK_MEDIA_STOP = 0xB2;
174 final static int VK_MEDIA_PLAY_PAUSE = 0xB3;
175 final static int VK_LAUNCH_MAIL = 0xB4;
176 final static int VK_LAUNCH_MEDIA_SELECT = 0xB5;
177 final static int VK_LAUNCH_APP1 = 0xB6;
178 final static int VK_LAUNCH_APP2 = 0xB7;
179 final static int VK_OEM_1 = 0xBA;
180 final static int VK_OEM_PLUS = 0xBB;
181 final static int VK_OEM_COMMA = 0xBC;
182 final static int VK_OEM_MINUS = 0xBD;
183 final static int VK_OEM_PERIOD = 0xBE;
184 final static int VK_OEM_2 = 0xBF;
185 final static int VK_OEM_3 = 0xC0;
186 final static int VK_ABNT_C1 = 0xC1;
187 final static int VK_ABNT_C2 = 0xC2;
188 final static int VK_OEM_4 = 0xDB;
189 final static int VK_OEM_5 = 0xDC;
190 final static int VK_OEM_6 = 0xDD;
191 final static int VK_OEM_7 = 0xDE;
192 final static int VK_OEM_8 = 0xDF;
193 final static int VK_OEM_102 = 0xE2;
194 final static int VK_PROCESSKEY = 0xE5;
195 final static int VK_PACKET = 0xE7;
196 final static int VK_ATTN = 0xF6;
197 final static int VK_CRSEL = 0xF7;
198 final static int VK_EXSEL = 0xF8;
199 final static int VK_EREOF = 0xF9;
200 final static int VK_PLAY = 0xFA;
201 final static int VK_ZOOM = 0xFB;
202 final static int VK_NONAME = 0xFC;
203 final static int VK_PA1 = 0xFD;
204 final static int VK_OEM_CLEAR = 0xFE;
205 final static int VK_UNICODE = 0x80000000;
206 final static int VK_EXT_KEY = 0x00000100;
207 // key codes to switch between custom keyboard
208 private final static int EXTKEY_KBFUNCTIONKEYS = 0x1100;
209 private final static int EXTKEY_KBNUMPAD = 0x1101;
210 // this flag indicates if we got a VK or a unicode character in our translation map
211 private static final int KEY_FLAG_UNICODE = 0x80000000;
212 // this flag indicates if the key is a toggle key (remains down when pressed and goes up if
213 // pressed again)
214 private static final int KEY_FLAG_TOGGLE = 0x40000000;
215 private static int[] keymapAndroid;
216 private static int[] keymapExt;
217 private static boolean initialized = false;
218 private KeyProcessingListener listener = null;
219 private boolean shiftPressed = false;
220 private boolean ctrlPressed = false;
221 private boolean altPressed = false;
222 private boolean winPressed = false;
223 private boolean isShiftLocked = false;
224 private boolean isCtrlLocked = false;
225 private boolean isAltLocked = false;
226 private boolean isWinLocked = false;
227 private boolean isWinKeyDown = false;
228 private boolean isWinComboUsed = false;
229 private boolean physicalKeyboardDeviceLayout = false;
230 // Accent of a dead key waiting for the next character, and the virtual key that typed it.
231 private int pendingAccent = 0;
232 private int pendingAccentVk = 0;
233
234 public void init(Context context)
235 {
236 if (initialized)
237 return;
238
239 keymapAndroid = new int[256];
240
241 keymapAndroid[KeyEvent.KEYCODE_0] = VK_KEY_0;
242 keymapAndroid[KeyEvent.KEYCODE_1] = VK_KEY_1;
243 keymapAndroid[KeyEvent.KEYCODE_2] = VK_KEY_2;
244 keymapAndroid[KeyEvent.KEYCODE_3] = VK_KEY_3;
245 keymapAndroid[KeyEvent.KEYCODE_4] = VK_KEY_4;
246 keymapAndroid[KeyEvent.KEYCODE_5] = VK_KEY_5;
247 keymapAndroid[KeyEvent.KEYCODE_6] = VK_KEY_6;
248 keymapAndroid[KeyEvent.KEYCODE_7] = VK_KEY_7;
249 keymapAndroid[KeyEvent.KEYCODE_8] = VK_KEY_8;
250 keymapAndroid[KeyEvent.KEYCODE_9] = VK_KEY_9;
251
252 keymapAndroid[KeyEvent.KEYCODE_A] = VK_KEY_A;
253 keymapAndroid[KeyEvent.KEYCODE_B] = VK_KEY_B;
254 keymapAndroid[KeyEvent.KEYCODE_C] = VK_KEY_C;
255 keymapAndroid[KeyEvent.KEYCODE_D] = VK_KEY_D;
256 keymapAndroid[KeyEvent.KEYCODE_E] = VK_KEY_E;
257 keymapAndroid[KeyEvent.KEYCODE_F] = VK_KEY_F;
258 keymapAndroid[KeyEvent.KEYCODE_G] = VK_KEY_G;
259 keymapAndroid[KeyEvent.KEYCODE_H] = VK_KEY_H;
260 keymapAndroid[KeyEvent.KEYCODE_I] = VK_KEY_I;
261 keymapAndroid[KeyEvent.KEYCODE_J] = VK_KEY_J;
262 keymapAndroid[KeyEvent.KEYCODE_K] = VK_KEY_K;
263 keymapAndroid[KeyEvent.KEYCODE_L] = VK_KEY_L;
264 keymapAndroid[KeyEvent.KEYCODE_M] = VK_KEY_M;
265 keymapAndroid[KeyEvent.KEYCODE_N] = VK_KEY_N;
266 keymapAndroid[KeyEvent.KEYCODE_O] = VK_KEY_O;
267 keymapAndroid[KeyEvent.KEYCODE_P] = VK_KEY_P;
268 keymapAndroid[KeyEvent.KEYCODE_Q] = VK_KEY_Q;
269 keymapAndroid[KeyEvent.KEYCODE_R] = VK_KEY_R;
270 keymapAndroid[KeyEvent.KEYCODE_S] = VK_KEY_S;
271 keymapAndroid[KeyEvent.KEYCODE_T] = VK_KEY_T;
272 keymapAndroid[KeyEvent.KEYCODE_U] = VK_KEY_U;
273 keymapAndroid[KeyEvent.KEYCODE_V] = VK_KEY_V;
274 keymapAndroid[KeyEvent.KEYCODE_W] = VK_KEY_W;
275 keymapAndroid[KeyEvent.KEYCODE_X] = VK_KEY_X;
276 keymapAndroid[KeyEvent.KEYCODE_Y] = VK_KEY_Y;
277 keymapAndroid[KeyEvent.KEYCODE_Z] = VK_KEY_Z;
278
279 keymapAndroid[KeyEvent.KEYCODE_DEL] = VK_BACK;
280 keymapAndroid[KeyEvent.KEYCODE_ENTER] = VK_RETURN;
281 keymapAndroid[KeyEvent.KEYCODE_SPACE] = VK_SPACE;
282 keymapAndroid[KeyEvent.KEYCODE_TAB] = VK_TAB;
283 keymapAndroid[KeyEvent.KEYCODE_ESCAPE] = VK_ESCAPE;
284 keymapAndroid[KeyEvent.KEYCODE_CAPS_LOCK] = VK_CAPITAL;
285 // keymapAndroid[KeyEvent.KEYCODE_SHIFT_LEFT] = VK_LSHIFT;
286 // keymapAndroid[KeyEvent.KEYCODE_SHIFT_RIGHT] = VK_RSHIFT;
287
288 keymapAndroid[KeyEvent.KEYCODE_DPAD_DOWN] = VK_DOWN | VK_EXT_KEY;
289 keymapAndroid[KeyEvent.KEYCODE_DPAD_LEFT] = VK_LEFT | VK_EXT_KEY;
290 keymapAndroid[KeyEvent.KEYCODE_DPAD_RIGHT] = VK_RIGHT | VK_EXT_KEY;
291 keymapAndroid[KeyEvent.KEYCODE_DPAD_UP] = VK_UP | VK_EXT_KEY;
292 keymapAndroid[KeyEvent.KEYCODE_MOVE_HOME] = VK_HOME | VK_EXT_KEY;
293 keymapAndroid[KeyEvent.KEYCODE_MOVE_END] = VK_END | VK_EXT_KEY;
294 keymapAndroid[KeyEvent.KEYCODE_PAGE_UP] = VK_PRIOR | VK_EXT_KEY;
295 keymapAndroid[KeyEvent.KEYCODE_PAGE_DOWN] = VK_NEXT | VK_EXT_KEY;
296 keymapAndroid[KeyEvent.KEYCODE_FORWARD_DEL] = VK_DELETE | VK_EXT_KEY;
297 keymapAndroid[KeyEvent.KEYCODE_INSERT] = VK_INSERT | VK_EXT_KEY;
298
299 keymapAndroid[KeyEvent.KEYCODE_MINUS] = VK_OEM_MINUS;
300 keymapAndroid[KeyEvent.KEYCODE_EQUALS] = VK_OEM_PLUS;
301 keymapAndroid[KeyEvent.KEYCODE_LEFT_BRACKET] = VK_OEM_4;
302 keymapAndroid[KeyEvent.KEYCODE_RIGHT_BRACKET] = VK_OEM_6;
303 keymapAndroid[KeyEvent.KEYCODE_BACKSLASH] = VK_OEM_5;
304 keymapAndroid[KeyEvent.KEYCODE_SEMICOLON] = VK_OEM_1;
305 keymapAndroid[KeyEvent.KEYCODE_APOSTROPHE] = VK_OEM_7;
306 keymapAndroid[KeyEvent.KEYCODE_GRAVE] = VK_OEM_3;
307 keymapAndroid[KeyEvent.KEYCODE_COMMA] = VK_OEM_COMMA;
308 keymapAndroid[KeyEvent.KEYCODE_PERIOD] = VK_OEM_PERIOD;
309 keymapAndroid[KeyEvent.KEYCODE_SLASH] = VK_OEM_2;
310
311 keymapAndroid[KeyEvent.KEYCODE_F1] = VK_F1;
312 keymapAndroid[KeyEvent.KEYCODE_F2] = VK_F2;
313 keymapAndroid[KeyEvent.KEYCODE_F3] = VK_F3;
314 keymapAndroid[KeyEvent.KEYCODE_F4] = VK_F4;
315 keymapAndroid[KeyEvent.KEYCODE_F5] = VK_F5;
316 keymapAndroid[KeyEvent.KEYCODE_F6] = VK_F6;
317 keymapAndroid[KeyEvent.KEYCODE_F7] = VK_F7;
318 keymapAndroid[KeyEvent.KEYCODE_F8] = VK_F8;
319 keymapAndroid[KeyEvent.KEYCODE_F9] = VK_F9;
320 keymapAndroid[KeyEvent.KEYCODE_F10] = VK_F10;
321 keymapAndroid[KeyEvent.KEYCODE_F11] = VK_F11;
322 keymapAndroid[KeyEvent.KEYCODE_F12] = VK_F12;
323
324 keymapAndroid[KeyEvent.KEYCODE_NUM_LOCK] = VK_NUMLOCK;
325 keymapAndroid[KeyEvent.KEYCODE_SCROLL_LOCK] = VK_SCROLL;
326 keymapAndroid[KeyEvent.KEYCODE_SYSRQ] = VK_SNAPSHOT | VK_EXT_KEY;
327 keymapAndroid[KeyEvent.KEYCODE_BREAK] = VK_PAUSE;
328
329 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_0] = VK_NUMPAD0;
330 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_1] = VK_NUMPAD1;
331 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_2] = VK_NUMPAD2;
332 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_3] = VK_NUMPAD3;
333 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_4] = VK_NUMPAD4;
334 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_5] = VK_NUMPAD5;
335 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_6] = VK_NUMPAD6;
336 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_7] = VK_NUMPAD7;
337 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_8] = VK_NUMPAD8;
338 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_9] = VK_NUMPAD9;
339 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_DIVIDE] = VK_DIVIDE | VK_EXT_KEY;
340 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_MULTIPLY] = VK_MULTIPLY;
341 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_SUBTRACT] = VK_SUBTRACT;
342 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_ADD] = VK_ADD;
343 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_DOT] = VK_DECIMAL;
344 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_COMMA] = VK_DECIMAL;
345 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_ENTER] = VK_RETURN | VK_EXT_KEY;
346 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_EQUALS] = KEY_FLAG_UNICODE | 61;
347 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_LEFT_PAREN] = KEY_FLAG_UNICODE | 40;
348 keymapAndroid[KeyEvent.KEYCODE_NUMPAD_RIGHT_PAREN] = KEY_FLAG_UNICODE | 41;
349
350 // special keys mapping
351 keymapExt = new int[256];
352 keymapExt[context.getResources().getInteger(R.integer.keycode_F1)] = VK_F1;
353 keymapExt[context.getResources().getInteger(R.integer.keycode_F2)] = VK_F2;
354 keymapExt[context.getResources().getInteger(R.integer.keycode_F3)] = VK_F3;
355 keymapExt[context.getResources().getInteger(R.integer.keycode_F4)] = VK_F4;
356 keymapExt[context.getResources().getInteger(R.integer.keycode_F5)] = VK_F5;
357 keymapExt[context.getResources().getInteger(R.integer.keycode_F6)] = VK_F6;
358 keymapExt[context.getResources().getInteger(R.integer.keycode_F7)] = VK_F7;
359 keymapExt[context.getResources().getInteger(R.integer.keycode_F8)] = VK_F8;
360 keymapExt[context.getResources().getInteger(R.integer.keycode_F9)] = VK_F9;
361 keymapExt[context.getResources().getInteger(R.integer.keycode_F10)] = VK_F10;
362 keymapExt[context.getResources().getInteger(R.integer.keycode_F11)] = VK_F11;
363 keymapExt[context.getResources().getInteger(R.integer.keycode_F12)] = VK_F12;
364 keymapExt[context.getResources().getInteger(R.integer.keycode_tab)] = VK_TAB;
365 keymapExt[context.getResources().getInteger(R.integer.keycode_print)] = VK_PRINT;
366 keymapExt[context.getResources().getInteger(R.integer.keycode_insert)] =
367 VK_INSERT | VK_EXT_KEY;
368 keymapExt[context.getResources().getInteger(R.integer.keycode_delete)] =
369 VK_DELETE | VK_EXT_KEY;
370 keymapExt[context.getResources().getInteger(R.integer.keycode_home)] = VK_HOME | VK_EXT_KEY;
371 keymapExt[context.getResources().getInteger(R.integer.keycode_end)] = VK_END | VK_EXT_KEY;
372 keymapExt[context.getResources().getInteger(R.integer.keycode_pgup)] =
373 VK_PRIOR | VK_EXT_KEY;
374 keymapExt[context.getResources().getInteger(R.integer.keycode_pgdn)] = VK_NEXT | VK_EXT_KEY;
375
376 // numpad mapping
377 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_0)] = VK_NUMPAD0;
378 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_1)] = VK_NUMPAD1;
379 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_2)] = VK_NUMPAD2;
380 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_3)] = VK_NUMPAD3;
381 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_4)] = VK_NUMPAD4;
382 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_5)] = VK_NUMPAD5;
383 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_6)] = VK_NUMPAD6;
384 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_7)] = VK_NUMPAD7;
385 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_8)] = VK_NUMPAD8;
386 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_9)] = VK_NUMPAD9;
387 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_numlock)] = VK_NUMLOCK;
388 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_add)] = VK_ADD;
389 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_comma)] = VK_DECIMAL;
390 keymapExt[context.getResources().getInteger(R.integer.keycode_comma)] = VK_OEM_COMMA;
391 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_divide)] =
392 VK_DIVIDE | VK_EXT_KEY;
393 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_enter)] =
394 VK_RETURN | VK_EXT_KEY;
395 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_multiply)] =
396 VK_MULTIPLY;
397 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_subtract)] =
398 VK_SUBTRACT;
399 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_equals)] =
400 (KEY_FLAG_UNICODE | 61);
401 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_left_paren)] =
402 (KEY_FLAG_UNICODE | 40);
403 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_right_paren)] =
404 (KEY_FLAG_UNICODE | 41);
405
406 // cursor key codes
407 keymapExt[context.getResources().getInteger(R.integer.keycode_up)] = VK_UP | VK_EXT_KEY;
408 keymapExt[context.getResources().getInteger(R.integer.keycode_down)] = VK_DOWN | VK_EXT_KEY;
409 keymapExt[context.getResources().getInteger(R.integer.keycode_left)] = VK_LEFT | VK_EXT_KEY;
410 keymapExt[context.getResources().getInteger(R.integer.keycode_right)] =
411 VK_RIGHT | VK_EXT_KEY;
412 keymapExt[context.getResources().getInteger(R.integer.keycode_enter)] =
413 VK_RETURN | VK_EXT_KEY;
414 keymapExt[context.getResources().getInteger(R.integer.keycode_backspace)] = VK_BACK;
415
416 // shared keys
417 keymapExt[context.getResources().getInteger(R.integer.keycode_win)] = VK_LWIN | VK_EXT_KEY;
418 keymapExt[context.getResources().getInteger(R.integer.keycode_menu)] = VK_APPS | VK_EXT_KEY;
419 keymapExt[context.getResources().getInteger(R.integer.keycode_esc)] = VK_ESCAPE;
420
421 /* keymapExt[context.getResources().getInteger(R.integer.keycode_modifier_ctrl)] =
422 VK_LCONTROL; keymapExt[context.getResources().getInteger(R.integer.keycode_modifier_alt)]
423 = VK_LMENU;
424 keymapExt[context.getResources().getInteger(R.integer.keycode_modifier_shift)] =
425 VK_LSHIFT;
426 */
427 // get custom keyboard key codes
428 keymapExt[context.getResources().getInteger(R.integer.keycode_specialkeys_keyboard)] =
429 EXTKEY_KBFUNCTIONKEYS;
430 keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_keyboard)] =
431 EXTKEY_KBNUMPAD;
432
433 keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_shift)] =
434 (KEY_FLAG_TOGGLE | VK_LSHIFT);
435 keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_ctrl)] =
436 (KEY_FLAG_TOGGLE | VK_LCONTROL);
437 keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_alt)] =
438 (KEY_FLAG_TOGGLE | VK_LMENU);
439 keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_win)] =
440 (KEY_FLAG_TOGGLE | VK_LWIN);
441
442 initialized = true;
443 }
444
445 public void reset(KeyProcessingListener listener)
446 {
447 shiftPressed = false;
448 ctrlPressed = false;
449 altPressed = false;
450 winPressed = false;
451 isWinKeyDown = false;
452 isWinComboUsed = false;
453 pendingAccent = 0;
454 setKeyProcessingListener(listener);
455 }
456
457 // Whether physical keyboards follow this device's layout rather than the server's.
458 public void setPhysicalKeyboardDeviceLayout(boolean enabled)
459 {
460 physicalKeyboardDeviceLayout = enabled;
461 }
462
463 public void setKeyProcessingListener(KeyProcessingListener listener)
464 {
465 this.listener = listener;
466 }
467
468 public boolean processAndroidKeyEvent(KeyEvent event)
469 {
470 switch (event.getAction())
471 {
472 // we only process down events
473 case KeyEvent.ACTION_UP:
474 {
475 if (event.getKeyCode() == KeyEvent.KEYCODE_META_LEFT ||
476 event.getKeyCode() == KeyEvent.KEYCODE_META_RIGHT)
477 {
478 if (!isWinKeyDown)
479 return false;
480 isWinKeyDown = false;
481 if (!isWinComboUsed)
482 {
483 listener.processVirtualKey(VK_LWIN | VK_EXT_KEY, true);
484 listener.processVirtualKey(VK_LWIN | VK_EXT_KEY, false);
485 }
486 isWinComboUsed = false;
487 return true;
488 }
489 return false;
490 }
491
492 case KeyEvent.ACTION_DOWN:
493 {
494 /* Physical Win key: buffer until release to distinguish tap vs combo. */
495 if (event.getKeyCode() == KeyEvent.KEYCODE_META_LEFT ||
496 event.getKeyCode() == KeyEvent.KEYCODE_META_RIGHT)
497 {
498 isWinKeyDown = true;
499 isWinComboUsed = false;
500 return true;
501 }
502
503 if (isWinKeyDown)
504 isWinComboUsed = true;
505
506 boolean modifierActive = isModifierPressed();
507
508 // The library chooses between the character and the key's scancode
509 // (freerdp_client_send_key_as_unicode). Key combinations keep the virtual-key
510 // path below: aFreeRDP's toggles mean the user is building one on the server, and
511 // Ctrl, Alt, Meta or Win held on the Android side have not reached the server, so
512 // that path wraps the key in them. Shift alone is wrapped here, so Shift+Space or
513 // Shift+Tab keep it. A server without unicode input keeps the virtual-key path,
514 // since the library would drop the character.
515 if (sendsKeyAsUnicode(event) && !modifierActive && !isWinKeyDown)
516 {
517 int vk = getVirtualKeyCode(event.getKeyCode());
518 int unicode = event.getUnicodeChar();
519 boolean deadKey = (unicode & KeyCharacterMap.COMBINING_ACCENT) != 0;
520 if (unicode < 0x20 || (unicode >= 0x7F && unicode < 0xA0))
521 unicode = 0;
522 // Right Alt that yields a character is AltGr, part of the layout: send the
523 // character.
524 int meta = event.getMetaState();
525 boolean altGr = (unicode != 0 || deadKey) &&
526 (meta & KeyEvent.META_ALT_RIGHT_ON) != 0 &&
527 (meta & KeyEvent.META_ALT_LEFT_ON) == 0;
528 boolean combination =
529 (meta & (KeyEvent.META_CTRL_ON | KeyEvent.META_META_ON)) != 0 ||
530 ((meta & KeyEvent.META_ALT_ON) != 0 && !altGr);
531 if (vk > 0 && (vk & KEY_FLAG_UNICODE) == 0 && !combination &&
532 (unicode == 0 || listener.isUnicodeInputSupported()))
533 {
534 boolean shift = event.isShiftPressed();
535 if (shift)
536 listener.processVirtualKey(VK_LSHIFT, true);
537 // AltGr produced the character, so it is not a modifier the server should
538 // see: with it in the mask the library would send the scancode. The generic
539 // Alt bit goes too, or it would count as the left Alt.
540 int altGrBits = KeyEvent.META_ALT_RIGHT_ON | KeyEvent.META_ALT_ON;
541 int modmask = getKeyboardModifiers(altGr ? meta & ~altGrBits : meta);
542 if (deadKey && listener.isUnicodeInputSupported())
543 processDeadKey(event, vk, modmask);
544 else if (pendingAccent != 0 && unicode != 0)
545 processAccentedKey(vk, unicode, modmask);
546 else
547 {
548 if (!KeyEvent.isModifierKey(event.getKeyCode()))
549 pendingAccent = 0;
550 listener.processKeyAsUnicode(vk, unicode, modmask);
551 }
552 if (shift)
553 listener.processVirtualKey(VK_LSHIFT, false);
554 return true;
555 }
556 }
557
558 if (!KeyEvent.isModifierKey(event.getKeyCode()))
559 pendingAccent = 0;
560
561 // if a modifier is pressed we will send a VK event (if possible) so that key
562 // combinations will be recognized correctly. Otherwise we will send the unicode
563 // key. At the end we will reset all modifiers and notify our listener.
564 int vkcode = getVirtualKeyCode(event.getKeyCode());
565 if ((vkcode & KEY_FLAG_UNICODE) != 0)
566 listener.processUnicodeKey(vkcode & (~KEY_FLAG_UNICODE));
567 // if we got a valid vkcode send it - except for letters/numbers if a modifier is
568 // active
569 else if (vkcode > 0 && !event.isSymPressed())
570 {
571 boolean sendCtrl = !ctrlPressed && event.isCtrlPressed();
572 boolean sendAlt = !altPressed && event.isAltPressed();
573 boolean sendWin = !winPressed && isWinKeyDown;
574 boolean sendShift = !shiftPressed && event.isShiftPressed();
575
576 if (sendCtrl)
577 listener.processVirtualKey(VK_LCONTROL, true);
578 if (sendAlt)
579 listener.processVirtualKey(VK_LMENU, true);
580 if (sendWin)
581 listener.processVirtualKey(VK_LWIN | VK_EXT_KEY, true);
582 if (sendShift)
583 listener.processVirtualKey(VK_LSHIFT, true);
584
585 listener.processVirtualKey(vkcode, true);
586 listener.processVirtualKey(vkcode, false);
587
588 if (sendShift)
589 listener.processVirtualKey(VK_LSHIFT, false);
590 if (sendWin)
591 listener.processVirtualKey(VK_LWIN | VK_EXT_KEY, false);
592 if (sendAlt)
593 listener.processVirtualKey(VK_LMENU, false);
594 if (sendCtrl)
595 listener.processVirtualKey(VK_LCONTROL, false);
596 }
597 else if (event.getUnicodeChar() != 0)
598 listener.processUnicodeKey(event.getUnicodeChar());
599 else
600 return false;
601
602 // reset any pending toggle states if a modifier was pressed
603 if (modifierActive)
604 resetModifierKeysAfterInput(false);
605 return true;
606 }
607
608 case KeyEvent.ACTION_MULTIPLE:
609 {
610 String str = event.getCharacters();
611 if (str != null)
612 {
613 for (int i = 0; i < str.length(); i++)
614 listener.processUnicodeKey(str.charAt(i));
615 }
616 return true;
617 }
618
619 default:
620 break;
621 }
622 return false;
623 }
624
625 public void processCustomKeyEvent(int keycode)
626 {
627 int extCode = getExtendedKeyCode(keycode);
628 if (extCode == 0)
629 return;
630
631 // toggle button pressed?
632 if ((extCode & KEY_FLAG_TOGGLE) != 0)
633 {
634 processToggleButton(extCode & (~KEY_FLAG_TOGGLE), false);
635 return;
636 }
637
638 // keyboard switch button pressed?
639 if (extCode == EXTKEY_KBFUNCTIONKEYS || extCode == EXTKEY_KBNUMPAD)
640 {
641 switchKeyboard(extCode);
642 return;
643 }
644
645 // nope - see if we got a unicode or vk
646 if ((extCode & KEY_FLAG_UNICODE) != 0)
647 listener.processUnicodeKey(extCode & (~KEY_FLAG_UNICODE));
648 else
649 {
650 listener.processVirtualKey(extCode, true);
651 listener.processVirtualKey(extCode, false);
652 }
653
654 resetModifierKeysAfterInput(false);
655 }
656
657 // Locks a sticky modifier down. Returns false if the keycode is not a modifier.
658 public boolean processCustomKeyLock(int keycode)
659 {
660 int extCode = getExtendedKeyCode(keycode);
661 if ((extCode & KEY_FLAG_TOGGLE) == 0)
662 return false;
663
664 processToggleButton(extCode & (~KEY_FLAG_TOGGLE), true);
665 return true;
666 }
667
668 public void processUnicodeFallback(int unicodeKey)
669 {
670 KeyCharacterMap kcm = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
671 KeyEvent[] events = kcm.getEvents(new char[] { (char)unicodeKey });
672 if (events == null)
673 return;
674 for (KeyEvent event : events)
675 {
676 int vkcode = fallbackVkcode(event.getKeyCode());
677 if (vkcode > 0)
678 listener.processVirtualKey(vkcode, event.getAction() == KeyEvent.ACTION_DOWN);
679 }
680 }
681
682 private int fallbackVkcode(int keycode)
683 {
684 switch (keycode)
685 {
686 case KeyEvent.KEYCODE_SHIFT_LEFT:
687 case KeyEvent.KEYCODE_SHIFT_RIGHT:
688 return VK_LSHIFT;
689 case KeyEvent.KEYCODE_ALT_LEFT:
690 case KeyEvent.KEYCODE_ALT_RIGHT:
691 return VK_LMENU;
692 case KeyEvent.KEYCODE_CTRL_LEFT:
693 case KeyEvent.KEYCODE_CTRL_RIGHT:
694 return VK_LCONTROL;
695 default:
696 return getVirtualKeyCode(keycode);
697 }
698 }
699
700 public void sendAltF4()
701 {
702 listener.processVirtualKey(VK_LMENU, true);
703 listener.processVirtualKey(VK_F4, true);
704 listener.processVirtualKey(VK_F4, false);
705 listener.processVirtualKey(VK_LMENU, false);
706 }
707
708 // Text from the on-screen keyboard reaches us as key events Android builds from its virtual
709 // key character map, so their key codes encode US key positions, not what the user typed.
710 // A physical keyboard's positions are what the server's layout is meant to read, unless the
711 // user chose this device's layout for it.
712 private boolean sendsKeyAsUnicode(KeyEvent event)
713 {
714 return physicalKeyboardDeviceLayout ||
715 event.getDeviceId() == KeyCharacterMap.VIRTUAL_KEYBOARD;
716 }
717
718 // Android reports a dead key as its accent, flagged COMBINING_ACCENT, and leaves composing it
719 // with the next character to the text field. Compose it here, as Android's own text fields
720 // do, so the server receives the accented character instead of reading the dead key's
721 // position in its own layout. Composed characters go with the dead key's virtual key: the
722 // library sends some keys, Space among them, as scancodes whatever their character.
723 private void processDeadKey(KeyEvent event, int vk, int modmask)
724 {
725 if (event.getRepeatCount() > 0)
726 return;
727 int accent = event.getUnicodeChar() & KeyCharacterMap.COMBINING_ACCENT_MASK;
728 if (pendingAccent != 0)
729 {
730 // The same dead key twice types the accent; two different ones, the first accent.
731 listener.processKeyAsUnicode(pendingAccentVk, pendingAccent, modmask);
732 boolean same = accent == pendingAccent;
733 pendingAccent = 0;
734 if (same)
735 return;
736 }
737 pendingAccent = accent;
738 pendingAccentVk = vk;
739 }
740
741 // A character after a dead key: the composed character, or the accent and then the character
742 // when they do not compose. Space types the accent itself: getDeadChar returned an apostrophe
743 // for the acute accent and Space on a Pixel 9 Pro running Android 17.
744 private void processAccentedKey(int vk, int unicode, int modmask)
745 {
746 int composed =
747 unicode == ' ' ? pendingAccent : KeyEvent.getDeadChar(pendingAccent, unicode);
748 if (composed != 0)
749 listener.processKeyAsUnicode(pendingAccentVk, composed, modmask);
750 else
751 {
752 listener.processKeyAsUnicode(pendingAccentVk, pendingAccent, modmask);
753 listener.processKeyAsUnicode(vk, unicode, modmask);
754 }
755 pendingAccent = 0;
756 }
757
758 // The modifiers Android reports for the event, as the library's FREERDP_CLIENT_KBD_MOD mask.
759 // Meta is the closest Android has to the Windows key. An event may carry only the generic bit
760 // (META_CTRL_ON without a side), which counts as the left key.
761 private static int getKeyboardModifiers(int metaState)
762 {
763 if ((metaState & KeyEvent.META_SHIFT_ON) != 0 &&
764 (metaState & (KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_RIGHT_ON)) == 0)
765 metaState |= KeyEvent.META_SHIFT_LEFT_ON;
766 if ((metaState & KeyEvent.META_ALT_ON) != 0 &&
767 (metaState & (KeyEvent.META_ALT_LEFT_ON | KeyEvent.META_ALT_RIGHT_ON)) == 0)
768 metaState |= KeyEvent.META_ALT_LEFT_ON;
769 if ((metaState & KeyEvent.META_CTRL_ON) != 0 &&
770 (metaState & (KeyEvent.META_CTRL_LEFT_ON | KeyEvent.META_CTRL_RIGHT_ON)) == 0)
771 metaState |= KeyEvent.META_CTRL_LEFT_ON;
772 if ((metaState & KeyEvent.META_META_ON) != 0 &&
773 (metaState & (KeyEvent.META_META_LEFT_ON | KeyEvent.META_META_RIGHT_ON)) == 0)
774 metaState |= KeyEvent.META_META_LEFT_ON;
775
776 int modmask = 0;
777 if ((metaState & KeyEvent.META_SHIFT_LEFT_ON) != 0)
778 modmask |= LibFreeRDP.KBD_MOD_LSHIFT;
779 if ((metaState & KeyEvent.META_SHIFT_RIGHT_ON) != 0)
780 modmask |= LibFreeRDP.KBD_MOD_RSHIFT;
781 if ((metaState & KeyEvent.META_ALT_LEFT_ON) != 0)
782 modmask |= LibFreeRDP.KBD_MOD_LMENU;
783 if ((metaState & KeyEvent.META_ALT_RIGHT_ON) != 0)
784 modmask |= LibFreeRDP.KBD_MOD_RMENU;
785 if ((metaState & KeyEvent.META_CTRL_LEFT_ON) != 0)
786 modmask |= LibFreeRDP.KBD_MOD_LCONTROL;
787 if ((metaState & KeyEvent.META_CTRL_RIGHT_ON) != 0)
788 modmask |= LibFreeRDP.KBD_MOD_RCONTROL;
789 if ((metaState & KeyEvent.META_META_LEFT_ON) != 0)
790 modmask |= LibFreeRDP.KBD_MOD_LWIN;
791 if ((metaState & KeyEvent.META_META_RIGHT_ON) != 0)
792 modmask |= LibFreeRDP.KBD_MOD_RWIN;
793 return modmask;
794 }
795
796 private boolean isModifierPressed()
797 {
798 return (shiftPressed || ctrlPressed || altPressed || winPressed);
799 }
800
801 public int getModifierState(int keycode)
802 {
803 int modifierCode = getExtendedKeyCode(keycode);
804
805 // check and get real modifier keycode
806 if ((modifierCode & KEY_FLAG_TOGGLE) == 0)
807 return -1;
808 modifierCode = modifierCode & (~KEY_FLAG_TOGGLE);
809
810 switch (modifierCode)
811 {
812 case VK_LSHIFT:
813 {
814 return (shiftPressed ? (isShiftLocked ? KEYSTATE_LOCKED : KEYSTATE_ON)
815 : KEYSTATE_OFF);
816 }
817 case VK_LCONTROL:
818 {
819 return (ctrlPressed ? (isCtrlLocked ? KEYSTATE_LOCKED : KEYSTATE_ON)
820 : KEYSTATE_OFF);
821 }
822 case VK_LMENU:
823 {
824 return (altPressed ? (isAltLocked ? KEYSTATE_LOCKED : KEYSTATE_ON) : KEYSTATE_OFF);
825 }
826 case VK_LWIN:
827 {
828 return (winPressed ? (isWinLocked ? KEYSTATE_LOCKED : KEYSTATE_ON) : KEYSTATE_OFF);
829 }
830 }
831
832 return -1;
833 }
834
835 private int getVirtualKeyCode(int keycode)
836 {
837 if (keycode >= 0 && keycode <= 0xFF)
838 return keymapAndroid[keycode];
839 return 0;
840 }
841
842 private int getExtendedKeyCode(int keycode)
843 {
844 if (keycode >= 0 && keycode <= 0xFF)
845 return keymapExt[keycode];
846 return 0;
847 }
848
849 // A tap arms the modifier for the next key only; a long press latches it until pressed again.
850 private void processToggleButton(int keycode, boolean lock)
851 {
852 switch (keycode)
853 {
854 case VK_LSHIFT:
855 {
856 isShiftLocked = lock && !isShiftLocked;
857 shiftPressed = applyModifier(VK_LSHIFT, shiftPressed, isShiftLocked, lock);
858 break;
859 }
860 case VK_LCONTROL:
861 {
862 isCtrlLocked = lock && !isCtrlLocked;
863 ctrlPressed = applyModifier(VK_LCONTROL, ctrlPressed, isCtrlLocked, lock);
864 break;
865 }
866 case VK_LMENU:
867 {
868 isAltLocked = lock && !isAltLocked;
869 altPressed = applyModifier(VK_LMENU, altPressed, isAltLocked, lock);
870 break;
871 }
872 case VK_LWIN:
873 {
874 isWinLocked = lock && !isWinLocked;
875 winPressed = applyModifier(VK_LWIN | VK_EXT_KEY, winPressed, isWinLocked, lock);
876 break;
877 }
878 }
879 listener.modifiersChanged();
880 }
881
882 // Reports the new pressed state only on a real change, so long pressing an already armed
883 // modifier does not send a second key down.
884 private boolean applyModifier(int vk, boolean pressed, boolean locked, boolean lock)
885 {
886 boolean target = lock ? locked : !pressed;
887 if (target != pressed)
888 listener.processVirtualKey(vk, target);
889 return target;
890 }
891
892 public void clearlAllModifiers()
893 {
894 resetModifierKeysAfterInput(true);
895 }
896
897 private void resetModifierKeysAfterInput(boolean force)
898 {
899 if (shiftPressed && (!isShiftLocked || force))
900 {
901 listener.processVirtualKey(VK_LSHIFT, false);
902 shiftPressed = false;
903 }
904 if (ctrlPressed && (!isCtrlLocked || force))
905 {
906 listener.processVirtualKey(VK_LCONTROL, false);
907 ctrlPressed = false;
908 }
909 if (altPressed && (!isAltLocked || force))
910 {
911 listener.processVirtualKey(VK_LMENU, false);
912 altPressed = false;
913 }
914 if (winPressed && (!isWinLocked || force))
915 {
916 listener.processVirtualKey(VK_LWIN | VK_EXT_KEY, false);
917 winPressed = false;
918 }
919
920 // drop the locks too, a stale lock flag would swallow the next long press
921 if (force)
922 isShiftLocked = isCtrlLocked = isAltLocked = isWinLocked = false;
923
924 if (listener != null)
925 listener.modifiersChanged();
926 }
927
928 private void switchKeyboard(int keycode)
929 {
930 switch (keycode)
931 {
932 case EXTKEY_KBFUNCTIONKEYS:
933 {
934 listener.switchKeyboard(KEYBOARD_TYPE_FUNCTIONKEYS);
935 break;
936 }
937
938 case EXTKEY_KBNUMPAD:
939 {
940 listener.switchKeyboard(KEYBOARD_TYPE_NUMPAD);
941 break;
942 }
943
944 default:
945 break;
946 }
947 }
948
949 // interface that gets called for input handling
950 public interface KeyProcessingListener {
951 void processVirtualKey(int virtualKeyCode, boolean down);
952
953 void processUnicodeKey(int unicodeKey);
954
955 boolean isUnicodeInputSupported();
956
957 void processKeyAsUnicode(int virtualKeyCode, int unicodeKey, int modmask);
958
959 void switchKeyboard(int keyboardType);
960
961 void modifiersChanged();
962 }
963}