FreeRDP
SDL2/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 <freerdp/locale/keyboard.h>
30 #include <SDL.h>
31 
32 #include "sdl_types.hpp"
33 
34 class sdlInput
35 {
36  public:
37  explicit sdlInput(SdlContext* sdl);
38  sdlInput(const sdlInput& other) = delete;
39  sdlInput(sdlInput&& other) = delete;
40  ~sdlInput();
41 
42  sdlInput& operator=(const sdlInput& other) = delete;
43  sdlInput& operator=(sdlInput&& other) = delete;
44 
45  BOOL keyboard_sync_state();
46  BOOL keyboard_focus_in();
47 
48  BOOL keyboard_handle_event(const SDL_KeyboardEvent* ev);
49 
50  BOOL keyboard_grab(Uint32 windowID, SDL_bool enable);
51  BOOL mouse_focus(Uint32 windowID);
52  BOOL mouse_grab(Uint32 windowID, SDL_bool enable);
53 
54  static BOOL keyboard_set_indicators(rdpContext* context, UINT16 led_flags);
55  static BOOL keyboard_set_ime_status(rdpContext* context, UINT16 imeId, UINT32 imeState,
56  UINT32 imeConvMode);
57 
58  static uint32_t prefToMask();
59  static uint32_t prefKeyValue(const std::string& key, uint32_t fallback = SDL_SCANCODE_UNKNOWN);
60 
61  private:
62  static std::list<std::string> tokenize(const std::string& data,
63  const std::string& delimiter = ",");
64  static bool extract(const std::string& token, uint32_t& key, uint32_t& value);
65 
66  SdlContext* _sdl;
67  Uint32 _lastWindowID;
68 
69  // hotkey handling
70  uint32_t _hotkeyModmask; // modifier keys mask
71  uint32_t _hotkeyFullscreen;
72  uint32_t _hotkeyResizable;
73  uint32_t _hotkeyGrab;
74  uint32_t _hotkeyDisconnect;
75  uint32_t _hotkeyMinimize;
76  FREERDP_REMAP_TABLE* _remapTable;
77 };