Skip to content

Commit

Permalink
libobs: Always explicitly check modifiers in macOS hotkey event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jcm93 committed Aug 8, 2024
1 parent ff2fa24 commit 9fb8536
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions libobs/obs-cocoa.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 9fb8536

Please sign in to comment.