[client,sdl] move parsing of hotkeys to constructor
* implement that for SDL3 just like for SDL2 * rename members to conform to style of file
This commit is contained in:
parent
f8cb7d86f6
commit
cdc8d62108
@ -555,27 +555,27 @@ BOOL sdlInput::keyboard_handle_event(const SDL_KeyboardEvent* ev)
|
||||
const UINT32 rdp_scancode = sdl_scancode_to_rdp(ev->keysym.scancode);
|
||||
const SDL_Keymod mods = SDL_GetModState();
|
||||
|
||||
if ((mods & hotkey_modmask) == hotkey_modmask)
|
||||
if ((mods & _hotkeyModmask) == _hotkeyModmask)
|
||||
{
|
||||
if (ev->type == SDL_KEYDOWN)
|
||||
{
|
||||
if (ev->keysym.scancode == hotkey_fullscreen)
|
||||
if (ev->keysym.scancode == _hotkeyFullscreen)
|
||||
{
|
||||
_sdl->update_fullscreen(!_sdl->fullscreen);
|
||||
return TRUE;
|
||||
}
|
||||
if (ev->keysym.scancode == hotkey_resizable)
|
||||
if (ev->keysym.scancode == _hotkeyResizable)
|
||||
{
|
||||
_sdl->update_resizeable(!_sdl->resizeable);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (ev->keysym.scancode == hotkey_grab)
|
||||
if (ev->keysym.scancode == _hotkeyGrab)
|
||||
{
|
||||
keyboard_grab(ev->windowID, _sdl->grab_kbd ? SDL_FALSE : SDL_TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
if (ev->keysym.scancode == hotkey_disconnect)
|
||||
if (ev->keysym.scancode == _hotkeyDisconnect)
|
||||
{
|
||||
freerdp_abort_connect_context(_sdl->context());
|
||||
return TRUE;
|
||||
@ -622,9 +622,9 @@ BOOL sdlInput::mouse_grab(Uint32 windowID, SDL_bool enable)
|
||||
|
||||
sdlInput::sdlInput(SdlContext* sdl) : _sdl(sdl), _lastWindowID(UINT32_MAX)
|
||||
{
|
||||
hotkey_modmask = prefToMask();
|
||||
hotkey_fullscreen = prefKeyValue("SDL_Fullscreen", SDL_SCANCODE_RETURN);
|
||||
hotkey_resizable = prefKeyValue("SDL_Resizeable", SDL_SCANCODE_R);
|
||||
hotkey_grab = prefKeyValue("SDL_Grab", SDL_SCANCODE_G);
|
||||
hotkey_disconnect = prefKeyValue("SDL_Disconnect", SDL_SCANCODE_D);
|
||||
_hotkeyModmask = prefToMask();
|
||||
_hotkeyFullscreen = prefKeyValue("SDL_Fullscreen", SDL_SCANCODE_RETURN);
|
||||
_hotkeyResizable = prefKeyValue("SDL_Resizeable", SDL_SCANCODE_R);
|
||||
_hotkeyGrab = prefKeyValue("SDL_Grab", SDL_SCANCODE_G);
|
||||
_hotkeyDisconnect = prefKeyValue("SDL_Disconnect", SDL_SCANCODE_D);
|
||||
}
|
||||
|
@ -68,6 +68,9 @@ class sdlInput
|
||||
std::atomic<bool> _remapInitialized = false;
|
||||
|
||||
// hotkey handling
|
||||
uint32_t hotkey_modmask; // modifier keys mask
|
||||
uint32_t hotkey_fullscreen, hotkey_resizable, hotkey_grab, hotkey_disconnect;
|
||||
uint32_t _hotkeyModmask; // modifier keys mask
|
||||
uint32_t _hotkeyFullscreen;
|
||||
uint32_t _hotkeyResizable;
|
||||
uint32_t _hotkeyGrab;
|
||||
uint32_t _hotkeyDisconnect;
|
||||
};
|
||||
|
@ -540,33 +540,28 @@ BOOL sdlInput::keyboard_handle_event(const SDL_KeyboardEvent* ev)
|
||||
WINPR_ASSERT(ev);
|
||||
const UINT32 rdp_scancode = sdl_scancode_to_rdp(ev->keysym.scancode);
|
||||
const SDL_Keymod mods = SDL_GetModState();
|
||||
const auto mask = prefToMask();
|
||||
const auto valFullscreen = prefKeyValue("SDL_Fullscreen", SDL_SCANCODE_RETURN);
|
||||
const auto valResizeable = prefKeyValue("SDL_Resizeable", SDL_SCANCODE_R);
|
||||
const auto valGrab = prefKeyValue("SDL_Grab", SDL_SCANCODE_G);
|
||||
const auto valDisconnect = prefKeyValue("SDL_Disconnect", SDL_SCANCODE_D);
|
||||
|
||||
if ((mods & mask) == mask)
|
||||
if ((mods & _hotkeyModmask) == _hotkeyModmask)
|
||||
{
|
||||
if (ev->type == SDL_EVENT_KEY_DOWN)
|
||||
{
|
||||
if (ev->keysym.scancode == valFullscreen)
|
||||
if (ev->keysym.scancode == _hotkeyFullscreen)
|
||||
{
|
||||
_sdl->update_fullscreen(!_sdl->fullscreen);
|
||||
return TRUE;
|
||||
}
|
||||
if (ev->keysym.scancode == valResizeable)
|
||||
if (ev->keysym.scancode == _hotkeyResizable)
|
||||
{
|
||||
_sdl->update_resizeable(!_sdl->resizeable);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (ev->keysym.scancode == valGrab)
|
||||
if (ev->keysym.scancode == _hotkeyGrab)
|
||||
{
|
||||
keyboard_grab(ev->windowID, _sdl->grab_kbd ? SDL_FALSE : SDL_TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
if (ev->keysym.scancode == valDisconnect)
|
||||
if (ev->keysym.scancode == _hotkeyDisconnect)
|
||||
{
|
||||
freerdp_abort_connect_context(_sdl->context());
|
||||
return TRUE;
|
||||
@ -613,4 +608,9 @@ BOOL sdlInput::mouse_grab(Uint32 windowID, SDL_bool enable)
|
||||
|
||||
sdlInput::sdlInput(SdlContext* sdl) : _sdl(sdl), _lastWindowID(UINT32_MAX)
|
||||
{
|
||||
_hotkeyModmask = prefToMask();
|
||||
_hotkeyFullscreen = prefKeyValue("SDL_Fullscreen", SDL_SCANCODE_RETURN);
|
||||
_hotkeyResizable = prefKeyValue("SDL_Resizeable", SDL_SCANCODE_R);
|
||||
_hotkeyGrab = prefKeyValue("SDL_Grab", SDL_SCANCODE_G);
|
||||
_hotkeyDisconnect = prefKeyValue("SDL_Disconnect", SDL_SCANCODE_D);
|
||||
}
|
||||
|
@ -66,4 +66,11 @@ class sdlInput
|
||||
Uint32 _lastWindowID;
|
||||
std::map<uint32_t, uint32_t> _remapList;
|
||||
std::atomic<bool> _remapInitialized = false;
|
||||
|
||||
// hotkey handling
|
||||
uint32_t _hotkeyModmask; // modifier keys mask
|
||||
uint32_t _hotkeyFullscreen;
|
||||
uint32_t _hotkeyResizable;
|
||||
uint32_t _hotkeyGrab;
|
||||
uint32_t _hotkeyDisconnect;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user