From 9fb85360e1957304edc1808690f11270971fd3e4 Mon Sep 17 00:00:00 2001 From: jcm <6864788+jcm93@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:39:23 -0500 Subject: [PATCH] libobs: Always explicitly check modifiers in macOS hotkey event handler --- libobs/obs-cocoa.m | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libobs/obs-cocoa.m b/libobs/obs-cocoa.m index 6094b12427736b..fc93f8eeca4c88 100644 --- a/libobs/obs-cocoa.m +++ b/libobs/obs-cocoa.m @@ -668,14 +668,13 @@ static bool log_layout_name(TISInputSourceRef tis) static void handle_monitor_event(obs_hotkeys_platform_t *plat, NSEvent *event) { - if (event.type == NSEventTypeFlagsChanged) { - NSEventModifierFlags flags = event.modifierFlags; - plat->is_key_down[OBS_KEY_CAPSLOCK] = !!(flags & NSEventModifierFlagCapsLock); - plat->is_key_down[OBS_KEY_SHIFT] = !!(flags & NSEventModifierFlagShift); - plat->is_key_down[OBS_KEY_ALT] = !!(flags & NSEventModifierFlagOption); - plat->is_key_down[OBS_KEY_META] = !!(flags & NSEventModifierFlagCommand); - plat->is_key_down[OBS_KEY_CONTROL] = !!(flags & NSEventModifierFlagControl); - } else if (event.type == NSEventTypeKeyDown || event.type == NSEventTypeKeyUp) { + NSEventModifierFlags flags = event.modifierFlags; + plat->is_key_down[OBS_KEY_CAPSLOCK] = !!(flags & NSEventModifierFlagCapsLock); + plat->is_key_down[OBS_KEY_SHIFT] = !!(flags & NSEventModifierFlagShift); + plat->is_key_down[OBS_KEY_ALT] = !!(flags & NSEventModifierFlagOption); + plat->is_key_down[OBS_KEY_META] = !!(flags & NSEventModifierFlagCommand); + plat->is_key_down[OBS_KEY_CONTROL] = !!(flags & NSEventModifierFlagControl); + if (event.type == NSEventTypeKeyDown || event.type == NSEventTypeKeyUp) { plat->is_key_down[obs_key_from_virtual_key(event.keyCode)] = (event.type == NSEventTypeKeyDown); } }