Skip to content

Commit

Permalink
cocoa: Change Caps Lock behavior to toggle instead of locking
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cgutman committed May 26, 2020
1 parent bdfd1b6 commit 77b0dad
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -912,11 +912,9 @@ - (void)flagsChanged:(NSEvent *)theEvent
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
Expand Down

0 comments on commit 77b0dad

Please sign in to comment.