FreeRDP
Loading...
Searching...
No Matches
com.freerdp.freerdpcore.utils.KeyboardMapper Class Reference

Data Structures

interface  KeyProcessingListener

Public Member Functions

void init (Context context)
void reset (KeyProcessingListener listener)
void setPhysicalKeyboardDeviceLayout (boolean enabled)
void setKeyProcessingListener (KeyProcessingListener listener)
boolean processAndroidKeyEvent (KeyEvent event)
void processCustomKeyEvent (int keycode)
boolean processCustomKeyLock (int keycode)
void processUnicodeFallback (int unicodeKey)
void sendAltF4 ()
int getModifierState (int keycode)
void clearlAllModifiers ()

Static Public Attributes

static final int KEYBOARD_TYPE_FUNCTIONKEYS = 1
static final int KEYBOARD_TYPE_NUMPAD = 2
static final int KEYSTATE_ON = 1
static final int KEYSTATE_LOCKED = 2
static final int KEYSTATE_OFF = 3

Detailed Description

Definition at line 20 of file KeyboardMapper.java.

Member Function Documentation

◆ clearlAllModifiers()

void com.freerdp.freerdpcore.utils.KeyboardMapper.clearlAllModifiers ( )
inline

Definition at line 892 of file KeyboardMapper.java.

893 {
894 resetModifierKeysAfterInput(true);
895 }

◆ getModifierState()

int com.freerdp.freerdpcore.utils.KeyboardMapper.getModifierState ( int keycode)
inline

Definition at line 801 of file KeyboardMapper.java.

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 }

◆ init()

void com.freerdp.freerdpcore.utils.KeyboardMapper.init ( Context context)
inline

Definition at line 234 of file KeyboardMapper.java.

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 }

◆ processAndroidKeyEvent()

boolean com.freerdp.freerdpcore.utils.KeyboardMapper.processAndroidKeyEvent ( KeyEvent event)
inline

Definition at line 468 of file KeyboardMapper.java.

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 }

◆ processCustomKeyEvent()

void com.freerdp.freerdpcore.utils.KeyboardMapper.processCustomKeyEvent ( int keycode)
inline

Definition at line 625 of file KeyboardMapper.java.

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 }

◆ processCustomKeyLock()

boolean com.freerdp.freerdpcore.utils.KeyboardMapper.processCustomKeyLock ( int keycode)
inline

Definition at line 658 of file KeyboardMapper.java.

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 }

◆ processUnicodeFallback()

void com.freerdp.freerdpcore.utils.KeyboardMapper.processUnicodeFallback ( int unicodeKey)
inline

Definition at line 668 of file KeyboardMapper.java.

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 }

◆ reset()

void com.freerdp.freerdpcore.utils.KeyboardMapper.reset ( KeyProcessingListener listener)
inline

Definition at line 445 of file KeyboardMapper.java.

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 }

◆ sendAltF4()

void com.freerdp.freerdpcore.utils.KeyboardMapper.sendAltF4 ( )
inline

Definition at line 700 of file KeyboardMapper.java.

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 }

◆ setKeyProcessingListener()

void com.freerdp.freerdpcore.utils.KeyboardMapper.setKeyProcessingListener ( KeyProcessingListener listener)
inline

Definition at line 463 of file KeyboardMapper.java.

464 {
465 this.listener = listener;
466 }

◆ setPhysicalKeyboardDeviceLayout()

void com.freerdp.freerdpcore.utils.KeyboardMapper.setPhysicalKeyboardDeviceLayout ( boolean enabled)
inline

Definition at line 458 of file KeyboardMapper.java.

459 {
460 physicalKeyboardDeviceLayout = enabled;
461 }

Field Documentation

◆ KEYBOARD_TYPE_FUNCTIONKEYS

final int com.freerdp.freerdpcore.utils.KeyboardMapper.KEYBOARD_TYPE_FUNCTIONKEYS = 1
static

Definition at line 22 of file KeyboardMapper.java.

◆ KEYBOARD_TYPE_NUMPAD

final int com.freerdp.freerdpcore.utils.KeyboardMapper.KEYBOARD_TYPE_NUMPAD = 2
static

Definition at line 23 of file KeyboardMapper.java.

◆ KEYSTATE_LOCKED

final int com.freerdp.freerdpcore.utils.KeyboardMapper.KEYSTATE_LOCKED = 2
static

Definition at line 28 of file KeyboardMapper.java.

◆ KEYSTATE_OFF

final int com.freerdp.freerdpcore.utils.KeyboardMapper.KEYSTATE_OFF = 3
static

Definition at line 29 of file KeyboardMapper.java.

◆ KEYSTATE_ON

final int com.freerdp.freerdpcore.utils.KeyboardMapper.KEYSTATE_ON = 1
static

Definition at line 27 of file KeyboardMapper.java.


The documentation for this class was generated from the following file: