Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libobs: Always explicitly check modifiers in macOS hotkey event handler #11100

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
libobs: Always explicitly check modifiers in macOS hotkey event handler
jcm93 committed Aug 8, 2024
commit 9fb85360e1957304edc1808690f11270971fd3e4
15 changes: 7 additions & 8 deletions libobs/obs-cocoa.m
Original file line number Diff line number Diff line change
@@ -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);
}
}