560{
561 const UINT32 rdp_scancode = scancode_to_rdp(ev.scancode);
562 const SDL_Keymod mods = SDL_GetModState();
563
564 if (_hotkeysEnabled && (mods & _hotkeyModmask) == _hotkeyModmask)
565 {
566 if (ev.type == SDL_EVENT_KEY_DOWN)
567 {
568 if (ev.scancode == _hotkeyFullscreen)
569 {
570 WLog_Print(_sdl->getWLog(), WLOG_INFO, "%s+<%s> pressed, toggling fullscreen state",
571 masktostr(_hotkeyModmask).c_str(), sdl_scancode_name(_hotkeyFullscreen));
572 if (!keyboard_sync_state())
573 return false;
574 return _sdl->toggleFullscreen();
575 }
576 if (ev.scancode == _hotkeyResizable)
577 {
578 WLog_Print(_sdl->getWLog(), WLOG_INFO, "%s+<%s> pressed, toggling resizeable state",
579 masktostr(_hotkeyModmask).c_str(), sdl_scancode_name(_hotkeyResizable));
580 if (!keyboard_sync_state())
581 return false;
582 return _sdl->toggleResizeable();
583 }
584
585 if (ev.scancode == _hotkeyGrab)
586 {
587 WLog_Print(_sdl->getWLog(), WLOG_INFO, "%s+<%s> pressed, toggling grab state",
588 masktostr(_hotkeyModmask).c_str(), sdl_scancode_name(_hotkeyGrab));
589 if (!keyboard_sync_state())
590 return false;
591 return keyboard_grab(ev.windowID, !_sdl->grabKeyboard());
592 }
593 if (ev.scancode == _hotkeyDisconnect)
594 {
595 WLog_Print(_sdl->getWLog(), WLOG_INFO, "%s+<%s> pressed, disconnecting RDP session",
596 masktostr(_hotkeyModmask).c_str(), sdl_scancode_name(_hotkeyDisconnect));
597 if (!keyboard_sync_state())
598 return false;
599 freerdp_abort_connect_context(_sdl->context());
600 return true;
601 }
602 if (ev.scancode == _hotkeyMinimize)
603 {
604 WLog_Print(_sdl->getWLog(), WLOG_INFO, "%s+<%s> pressed, minimizing client",
605 masktostr(_hotkeyModmask).c_str(), sdl_scancode_name(_hotkeyMinimize));
606 if (!keyboard_sync_state())
607 return false;
608 return _sdl->setMinimized();
609 }
610 }
611 }
612
613#if defined(WITH_DEBUG_KBD)
614 {
615 const BOOL ex = RDP_SCANCODE_EXTENDED(rdp_scancode);
616 const DWORD sc = RDP_SCANCODE_CODE(rdp_scancode);
617 WLog_Print(_sdl->getWLog(), WLOG_DEBUG,
618 "SDL keycode: %02" PRIX32 " -> rdp code: [%04" PRIx16 "] %02" PRIX8 "%s",
619 ev.scancode, rdp_scancode, sc, ex ? " extended" : "");
620 }
621#endif
622
623 auto scancode = freerdp_keyboard_remap_key(_remapTable, rdp_scancode);
624#if defined(WITH_DEBUG_KBD)
625 {
626 const BOOL ex = RDP_SCANCODE_EXTENDED(scancode);
627 const DWORD sc = RDP_SCANCODE_CODE(scancode);
628 WLog_Print(_sdl->getWLog(), WLOG_DEBUG,
629 "SDL keycode: %02" PRIX32 " -> remapped rdp code: [%04" PRIx16 "] %02" PRIX8
630 "%s",
631 ev.scancode, scancode, sc, ex ? " extended" : "");
632 }
633#endif
634 return freerdp_input_send_keyboard_event_ex(_sdl->context()->input,
635 ev.type == SDL_EVENT_KEY_DOWN, ev.repeat, scancode);
636}