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