We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4716 - Mac: SDL_GetModState reports incorrect Caps Lock state
Summary: Mac: SDL_GetModState reports incorrect Caps Lock state
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 2.0.10
Hardware: All macOS 10.14
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-10 22:47 UTC by Tim McDaniel
Modified: 2019-07-11 05:15 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim McDaniel 2019-07-10 22:47:06 UTC
I have tested this on macOS 10.14 & 10.15(beta), neither are available in the Bugzilla OS field.

SDL_GetModState appears to be reporting incorrect Caps Lock modifier state.  Below is output from the checkkeys test app.  Each of the 4 event lines represents pressing and releasing the physical Caps Lock key.

INFO: Initial state: modifiers: (none)
INFO: Key pressed :  scancode 57 = CapsLock, keycode 0x40000039 = CapsLock  modifiers: CAPS
INFO: Key released:  scancode 57 = CapsLock, keycode 0x40000039 = CapsLock  modifiers: CAPS
INFO: Key pressed :  scancode 57 = CapsLock, keycode 0x40000039 = CapsLock  modifiers: (none)
INFO: Key released:  scancode 57 = CapsLock, keycode 0x40000039 = CapsLock  modifiers: (none)

The event type (key pressed or released) matches the logical Caps Lock toggle state (i.e. matches the LED on the Caps Lock key: pressed = LED on, released = LED off).  However, the modifier state is wrong.  The sequence should be CAPS, (none), CAPS, (none).
Comment 1 Tim McDaniel 2019-07-10 22:59:16 UTC
Also related:

With change 12907, the key events for Caps Lock no longer match the physical Caps Lock key state.  I realize this was done to avoid a permissions popup warning on macOS 10.15.  I don't have a workaround for this at the moment.  I doubt there is one.  However, it's worth noting here that this behavior does not match SDL's behavior on Windows.

bug 2157 is the related issue that led to the pre-12907 IOKit based Caps Lock tracking.
Comment 2 Ryan C. Gordon 2019-07-11 05:15:03 UTC
(In reply to Tim McDaniel from comment #0)
> I have tested this on macOS 10.14 & 10.15(beta), neither are available in
> the Bugzilla OS field.

This is fixed in Bugzilla now, sorry!

> SDL_GetModState appears to be reporting incorrect Caps Lock modifier state. 
> Below is output from the checkkeys test app.  Each of the 4 event lines
> represents pressing and releasing the physical Caps Lock key.

This is now fixed in https://hg.libsdl.org/SDL/rev/41528cbd80ab ... it should report the CapsLock modifier correctly now, thanks!

I don't have a better workaround for keypress events at the moment, but I'll think on it more, even if we have to give up eventually. Let's track that over on Bug #2157 and close this one, though.

--ryan.