#9617 closed defect (fixed)
Alt+Enter and other hotkeys are too sensitive
Reported by: | salty-horse | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | Port: Linux |
Version: | Keywords: | ||
Cc: | Game: |
Description
This is on Linux. Bug #9563 seems to describe totally different behavior on Windows/OSX.
When I use either the SDL or OpenGL backends, pressing alt+enter will toggle the fullscreen setting several times, instead of just once. As long as alt+enter is held, it will keep toggling it. Even when I release ENTER very quickly, it still manages to toggle it a few times.
This is bad. I would expect that if alt+enter is held, nothing will happen. It should only allow the next toggle after ENTER is released and then pressed again (assuming ALT is held).
While investigating this I noticed that when we change resolutions, SDL sends a KEYUP event for keys that are currently held down.
This means that pressing and holding ALT+ENTER for a moment will override any key delay code we have (where?) and call it several times. It also happens with CTRL+ALT+a which toggles aspect ratio.
It does not happen with CTRL+ALT+f which toggles filtering. If you press that combination for a long time it will only toggle it a single time until you let go of 'F' and press it again.
Why is this happening?
This errant KEYUP event prevents any hacks around this problem. For example, I tried writing a hack to the SDL backend's handling of the fullscreen toggle to only allow it again once the enter key is released and pressed a second time. (See attachment). It works fine when I comment out toggleFullScreen
, but the toggle actually happens, SDL (in SdlEventSource::handleKeyUp
) sends a KEYUP event for ENTER without me having released it.
Besides alt+enter, this behavior should also be implemented to the alt+ctrl+PLUS/MINUS that cycle between the scalers, and arguably for Alt+S which takes a screenshot. I wouldn't want to hold alt+s for a moment too long and take many screenshots. Any other relevant hotkeys I'm missing?
Besides the SDL graphics backend, this should be implemented in the OpenGL backend. Their input-handling code has some similarities. Could they be merged?
A related topic that I hope someone clarifies:
ScummVM's keyboard events implement a 'repeat' flag, called 'synthetic', but it isn't set if I hold alt+enter. I couldn't quite figure out how it works. It seems to trigger only when the event queue is empty - but what prevents SDL from sending repeated KEYDOWN events if a key is continuously pressed?
Attachments (1)
Change History (5)
by , 8 years ago
Attachment: | fullscreen_hack.patch added |
---|
comment:1 by , 8 years ago
I think the KEYUP event is called since window resizing (when going fullscreen or changing scale factor) is implemented by destroying the current window and creating a new one.
If this happens while a key is pressed, SDL sends a KEYUP event with the old windowID, and a KEYDOWN event with the new windowID.
comment:2 by , 8 years ago
I've opened a SDL bug for the duplicate SDL_KEYDOWN event when the window state changes. https://bugzilla.libsdl.org/show_bug.cgi?id=3637
comment:3 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Closing this as it's an SDL bug.
comment:4 by , 6 years ago
Component: | --Unset-- → Port: Linux |
---|
Broken attempt at slowing down alt+enter toggles