Mac: make sure SDL keyboard state reflects system capslock state at startup.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 27 Dec 2015 16:46:12 -0500
changeset 996775871b5e0bc6
parent 9966 cae9c97fabbd
child 9968 0a420ec24b6a
Mac: make sure SDL keyboard state reflects system capslock state at startup.
src/video/cocoa/SDL_cocoakeyboard.m
     1.1 --- a/src/video/cocoa/SDL_cocoakeyboard.m	Fri Dec 25 13:41:23 2015 +0100
     1.2 +++ b/src/video/cocoa/SDL_cocoakeyboard.m	Sun Dec 27 16:46:12 2015 -0500
     1.3 @@ -497,6 +497,15 @@
     1.4      SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Command");
     1.5      SDL_SetScancodeName(SDL_SCANCODE_RALT, "Right Option");
     1.6      SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Command");
     1.7 +
     1.8 +    /* On pre-10.6, you might have the initial capslock key state wrong. */
     1.9 +    if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_6) {
    1.10 +        data->modifierFlags = [NSEvent modifierFlags];
    1.11 +        if (data->modifierFlags & NSAlphaShiftKeyMask) {
    1.12 +            SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
    1.13 +            SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
    1.14 +        }
    1.15 +    }
    1.16  }
    1.17  
    1.18  void