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 1959 - Improper/inconsistent handling of double shift key
Summary: Improper/inconsistent handling of double shift key
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 2.0.0
Hardware: x86 Windows 8
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.0
Depends on:
Blocks:
 
Reported: 2013-07-11 23:20 UTC by Alistair John Strachan
Modified: 2013-08-01 01:52 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 Alistair John Strachan 2013-07-11 23:20:34 UTC
(I used checkkeys to triage the below, but this was first noticed in an SDL2 build of the "MegaZeux" GCS project, so it affects real world applications.)

Holding LSHIFT will trigger a KEYDOWN with repeat for LSHIFT and include LSHIFT in the modifiers list. When you release the key you get a KEYUP and LSHIFT is removed from the modifiers list. The same goes for RSHIFT. So far, so good.

If you hold both LSHIFT *and* RSHIFT, the most recently pressed of the two will be the repeating KEYDOWN, and the modifiers will include both keys. This also seems like reasonable behavior.

BUT, if you release either LSHIFT or RSHIFT (but not both), the modifiers list will not update. It will show that both shift keys are pressed. Furthermore, when you finally release the second shift key, only one of the keys (the most recently released) is removed from the modifier list. The other one persists ad infinitum, or until it goes through a KEYDOWN/KEYUP cycle.

I tried with other modifier keys like ALT and CTRL but could not reproduce this issue.
Comment 1 Ryan C. Gordon 2013-07-12 22:15:45 UTC
(Sorry if you get a lot of copies of this email, we're touching dozens of bug reports right now.)

Tagging a bunch of bugs as target-2.0.0, Priority 2.

This means we're in the final stretch for an official SDL 2.0.0 release! These are the bugs we really want to fix before shipping if humanly possible.

That being said, we don't promise to fix them because of this tag, we just want to make sure we don't forget to deal with them before we bless a final 2.0.0 release, and generally be organized about what we're aiming to ship.

Hopefully you'll hear more about this bug soon. If you have more information (including "this got fixed at some point, nevermind"), we would love to have you come add more information to the bug report when you have a moment.

Thanks!
--ryan.
Comment 2 Ryan C. Gordon 2013-08-01 01:52:59 UTC
This is apparently some evil in win32; it loses the WM_KEYUP event for one of the shift keys, so SDL never gets it. Not sure why. It seems like this shouldn't be a bug in Windows at this point, so it might have a historical reason.

It's not a hardware limitation, the OS can definitely tell them apart, and if you check with GetKeyState(), it knows that you lifted your finger off the first key, even if it didn't send a KEYUP for it.

So this change...

    http://hg.libsdl.org/SDL/rev/65f2b183e2aa

...will now make sure the shift keys are sane at the end of each run through the event loop. This _should_ be lightweight--I hope--because if we check for this in the KEYUP event, it'll fix the problem of the key being stuck forever, but the original key remains stuck until you release the second key, and that's not ideal either.

Marking this fixed. Sam, if doing this in PumpEvents is a bad idea, let me know and we'll do something else.

--ryan.