Skip to content

Commit

Permalink
Mac: make sure SDL keyboard state reflects system capslock state at s…
Browse files Browse the repository at this point in the history
…tartup.
  • Loading branch information
icculus committed Dec 27, 2015
1 parent 1446faf commit faed058
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/video/cocoa/SDL_cocoakeyboard.m
Expand Up @@ -497,6 +497,15 @@ - (NSArray *)validAttributesForMarkedText
SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Command");
SDL_SetScancodeName(SDL_SCANCODE_RALT, "Right Option");
SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Command");

/* On pre-10.6, you might have the initial capslock key state wrong. */
if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_6) {
data->modifierFlags = [NSEvent modifierFlags];
if (data->modifierFlags & NSAlphaShiftKeyMask) {
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
}
}
}

void
Expand Down

0 comments on commit faed058

Please sign in to comment.