FreeRDP
SDL3/sdl_kbd.hpp
1 
20 #pragma once
21 
22 #include <string>
23 #include <map>
24 #include <list>
25 #include <atomic>
26 
27 #include <winpr/wtypes.h>
28 #include <freerdp/freerdp.h>
29 #include <SDL3/SDL.h>
30 
31 #include "sdl_types.hpp"
32 
33 class sdlInput
34 {
35  public:
36  explicit sdlInput(SdlContext* sdl);
37  sdlInput(const sdlInput& other) = delete;
38  sdlInput(sdlInput&& other) = delete;
39  ~sdlInput() = default;
40 
41  sdlInput& operator=(const sdlInput& other) = delete;
42  sdlInput& operator=(sdlInput&& other) = delete;
43 
44  BOOL keyboard_sync_state();
45  BOOL keyboard_focus_in();
46 
47  BOOL keyboard_handle_event(const SDL_KeyboardEvent* ev);
48 
49  BOOL keyboard_grab(Uint32 windowID, bool enable);
50  BOOL mouse_focus(Uint32 windowID);
51  BOOL mouse_grab(Uint32 windowID, bool enable);
52 
53  static BOOL keyboard_set_indicators(rdpContext* context, UINT16 led_flags);
54  static BOOL keyboard_set_ime_status(rdpContext* context, UINT16 imeId, UINT32 imeState,
55  UINT32 imeConvMode);
56 
57  static uint32_t prefToMask();
58  static uint32_t prefKeyValue(const std::string& key, uint32_t fallback = SDL_SCANCODE_UNKNOWN);
59 
60  private:
61  static std::list<std::string> tokenize(const std::string& data,
62  const std::string& delimiter = ",");
63  static bool extract(const std::string& token, uint32_t& key, uint32_t& value);
64 
65  uint32_t remapScancode(uint32_t scancode);
66  void remapInitialize();
67 
68  SdlContext* _sdl;
69  Uint32 _lastWindowID;
70  std::map<uint32_t, uint32_t> _remapList;
71  std::atomic<bool> _remapInitialized = false;
72 
73  // hotkey handling
74  uint32_t _hotkeyModmask; // modifier keys mask
75  uint32_t _hotkeyFullscreen;
76  uint32_t _hotkeyResizable;
77  uint32_t _hotkeyGrab;
78  uint32_t _hotkeyDisconnect;
79  uint32_t _hotkeyMinimize;
80 };