From ef6c0ae8ef2f6c1d9c386857641680e10be78eec Mon Sep 17 00:00:00 2001 From: Jason Millard Date: Mon, 16 Nov 2026 16:58:30 -0500 Subject: [PATCH] input: tell left and right modifiers apart on macOS --- src/NativeInput_Mac.mm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/NativeInput_Mac.mm b/src/NativeInput_Mac.mm index 2bd715a..103b7bd 100644 --- a/src/NativeInput_Mac.mm +++ b/src/NativeInput_Mac.mm @@ -211,7 +211,25 @@ bool IsCurrentProcessForeground() { } } + bool DeviceModifierMask(CGKeyCode nativeKeyCode, CGEventFlags* mask) { + switch (nativeKeyCode) { + case 59: *mask = 0x00000001; return true; + case 56: *mask = 0x00000002; return true; + case 60: *mask = 0x00000004; return true; + case 55: *mask = 0x00000008; return true; + case 54: *mask = 0x00000010; return true; + case 58: *mask = 0x00000020; return true; + case 61: *mask = 0x00000040; return true; + case 62: *mask = 0x00002000; return true; + default: return false; + } + } + bool IsPressed(CGKeyCode nativeKeyCode) { + CGEventFlags mask; + if (DeviceModifierMask(nativeKeyCode, &mask)) { + return (CGEventSourceFlagsState(kCGEventSourceStateCombinedSessionState) & mask) != 0; + } return CGEventSourceKeyState(kCGEventSourceStateCombinedSessionState, nativeKeyCode); }