Add support for system key capture in windowed mode on macOS

This commit is contained in:
Cameron Gutman
2021-02-26 21:43:47 -06:00
parent 28ecc6bcbf
commit b27ca993aa
6 changed files with 61 additions and 23 deletions
+25
View File
@@ -29,6 +29,25 @@ struct GamepadState {
unsigned char lt, rt;
};
#ifdef Q_OS_DARWIN
#include <CoreGraphics/CGError.h>
extern "C" {
typedef int CGSConnection;
typedef enum {
CGSGlobalHotKeyEnable = 0,
CGSGlobalHotKeyDisable = 1,
} CGSGlobalHotKeyOperatingMode;
extern CGSConnection _CGSDefaultConnection(void);
extern CGError CGSGetGlobalHotKeyOperatingMode(CGSConnection connection,
CGSGlobalHotKeyOperatingMode* mode);
extern CGError CGSSetGlobalHotKeyOperatingMode(CGSConnection connection,
CGSGlobalHotKeyOperatingMode mode);
}
#endif
#define MAX_GAMEPADS 4
#define MAX_FINGERS 2
@@ -79,6 +98,8 @@ public:
void notifyFocusLost();
void notifyFocusGained();
bool isCaptureActive();
bool isSystemKeyCaptureActive();
@@ -167,6 +188,10 @@ private:
bool m_CaptureSystemKeysEnabled;
int m_MouseCursorCapturedVisibilityState;
#ifdef Q_OS_DARWIN
CGSGlobalHotKeyOperatingMode m_OldHotKeyMode;
#endif
struct {
KeyCombo keyCombo;
SDL_Keycode keyCode;