From 77b0dad271470a458c24c9018bfbdc090f9806c1 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 25 May 2020 20:55:29 -0700 Subject: [PATCH] cocoa: Change Caps Lock behavior to toggle instead of locking It currently behaves like a locking key which is pressed when Caps Lock is enabled and released when disabled. This means that apps that trigger events on Caps Lock key down will only fire these events every other time Caps Lock is pressed. --- src/video/cocoa/SDL_cocoawindow.m | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 585468430..86e151a65 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -912,11 +912,9 @@ SetWindowStyle(SDL_Window * window, NSUInteger style) keypresses; it won't toggle the mod state if you send a keyrelease. */ const SDL_bool osenabled = ([theEvent modifierFlags] & NSEventModifierFlagCapsLock) ? SDL_TRUE : SDL_FALSE; const SDL_bool sdlenabled = (SDL_GetModState() & KMOD_CAPS) ? SDL_TRUE : SDL_FALSE; - if (!osenabled && sdlenabled) { - SDL_ToggleModState(KMOD_CAPS, SDL_FALSE); - SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK); - } else if (osenabled && !sdlenabled) { + if (osenabled ^ sdlenabled) { SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK); + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK); } } - (void)keyDown:(NSEvent *)theEvent