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