Skip to content

Commit

Permalink
Mac: Fix keyboard state if capslock was toggled while app wasn't in f…
Browse files Browse the repository at this point in the history
…oreground.
  • Loading branch information
icculus committed Dec 28, 2015
1 parent fa7c15c commit d3b323f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -588,6 +588,17 @@ - (void)windowDidBecomeKey:(NSNotification *)aNotification
if ((isFullscreenSpace) && ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP)) {
[NSMenu setMenuBarVisible:NO];
}

/* On pre-10.6, you might have the capslock key state wrong now. */
if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_6) {
const unsigned int oldflags = _data->videodata->modifierFlags & NSAlphaShiftKeyMask;
const unsigned int newflags = [NSEvent modifierFlags] & NSAlphaShiftKeyMask;
if (oldflags != newflags) {
_data->videodata->modifierFlags = (_data->videodata->modifierFlags & ~NSAlphaShiftKeyMask) | newflags;
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
}
}
}

- (void)windowDidResignKey:(NSNotification *)aNotification
Expand Down

0 comments on commit d3b323f

Please sign in to comment.