# HG changeset patch # User Cameron Gutman # Date 1590465329 25200 # Mon May 25 20:55:29 2020 -0700 # Branch caps_lock # Node ID ee14f57378d925c2e2d58a5d7282a14d48acf52a # Parent a8f431812db719ff5f6f4f6dbb297ca536b8a363 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. diff -r a8f431812db7 -r ee14f57378d9 src/video/cocoa/SDL_cocoawindow.m --- a/src/video/cocoa/SDL_cocoawindow.m Mon May 25 14:10:51 2020 -0700 +++ b/src/video/cocoa/SDL_cocoawindow.m Mon May 25 20:55:29 2020 -0700 @@ -912,11 +912,9 @@ 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); + if (osenabled ^ sdlenabled) { + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK); SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK); - } else if (osenabled && !sdlenabled) { - SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK); } } - (void)keyDown:(NSEvent *)theEvent