| Summary: | SDL_GetModState does not track Caps lock properly | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Kutta Srinivasan <kutta.s> |
| Component: | events | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | icculus, iryont, philipp.wiesemann |
| Version: | 2.0.3 | ||
| Hardware: | x86_64 | ||
| OS: | Windows 7 | ||
|
Description
Kutta Srinivasan
2015-09-17 17:55:41 UTC
Yep, sounds like 2736 is the same bug - SDL probably doesn't ask (on any platform) for the current toggle state of the num / caps lock keys on startup or after regaining focus, so it's easy for it to get out of sync. Hello I believe it might be worth to bring this bug up. It's quite frustrating. Capslock (numlock, scrolllock) having wrong values at startup is now fixed on Windows by https://hg.libsdl.org/SDL/rev/be3d04927338 ... https://hg.libsdl.org/SDL/rev/75871b5e0bc6 fixes this on Mac OS X. Our X11 code seems to handle this correctly, but I don't if that was true when this bug report was opened. I haven't fixed this state getting out of sync on focus change on Windows (it's possible the Mac-specific code already handles this, though). --ryan. (In reply to Ryan C. Gordon from comment #4) > Our X11 code seems to handle this correctly, but I don't if that was true > when this bug report was opened. This was fixed for X11 in https://hg.libsdl.org/SDL/rev/7099e2df7b29, which is what Bug #2736 was dealing with. --ryan. (In reply to Ryan C. Gordon from comment #4) > Capslock (numlock, scrolllock) having wrong values at startup is now fixed > on Windows by https://hg.libsdl.org/SDL/rev/be3d04927338 ... > > https://hg.libsdl.org/SDL/rev/75871b5e0bc6 fixes this on Mac OS X. > > Our X11 code seems to handle this correctly, but I don't if that was true > when this bug report was opened. > > I haven't fixed this state getting out of sync on focus change on Windows > (it's possible the Mac-specific code already handles this, though). Okay, as of the latest in revision control: - You _don't_ get a key event if caps/numlock is toggled on at startup, but SDL_GetModState(), etc, will properly report them as toggled. - You _don't_ get a key event if caps/numlock is toggled while your app is not in the foreground, but SDL will update its internal state when it regains focus, and then SDL_GetModState(), etc, will properly report them as toggled. - You _will_ get a key event if these keys are toggled on or off by the user pressing them while your SDL app has focus. You'll get a KEYDOWN followed immediately by a KEYUP, regardless of whether the key is toggling on or off. This is how SDL2 has always worked, so I kept this behavior. This has been fixed and tested on Windows, Mac OS X, and X11, using the checkkeys program in the test directory. Relevant changesets are: https://hg.libsdl.org/SDL/rev/75871b5e0bc6 https://hg.libsdl.org/SDL/rev/be3d04927338 https://hg.libsdl.org/SDL/rev/734c90ea9990 https://hg.libsdl.org/SDL/rev/4d8a561cf978 https://hg.libsdl.org/SDL/rev/05770dc93c95 https://hg.libsdl.org/SDL/rev/bb853b9549d0 I'm marking this resolved. Thanks! --ryan. |