mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-12 12:09:15 +00:00
SDL: Make TEXTINPUT handling more reliable for SDL2.
This reduces the likelihood of entering two characters per keypress in our guy on Windows. In fact, during my brief testing with the filter widget in the launcher I was not able to trigger the former behavior at all anymore.
This commit is contained in:
parent
6581bcad6d
commit
c925e5b35c
@ -872,6 +872,21 @@ uint32 SdlEventSource::obtainUnicode(const SDL_keysym keySym) {
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
SDL_Event events[2];
|
||||
|
||||
// Update the event queue here to give SDL a chance to insert TEXTINPUT
|
||||
// events for KEYDOWN events. Otherwise we have a high chance that on
|
||||
// Windows the TEXTINPUT event is not in the event queue at this point.
|
||||
// In this case we will get two events with ascii values due to mapKey
|
||||
// and dispatchSDLEvent. This results in nasty double input of characters
|
||||
// in the GUI.
|
||||
//
|
||||
// FIXME: This is all a bit fragile because in mapKey we derive the ascii
|
||||
// value from the key code if no unicode value is given. This is legacy
|
||||
// behavior and should be removed anyway. If that is removed, we might not
|
||||
// even need to do this peeking here but instead can rely on the
|
||||
// SDL_TEXTINPUT case in dispatchSDLEvent to introduce keydown/keyup with
|
||||
// proper ASCII values (but with KEYCODE_INVALID as keycode).
|
||||
SDL_PumpEvents();
|
||||
|
||||
// In SDL2, the unicode field has been removed from the keysym struct.
|
||||
// Instead a SDL_TEXTINPUT event is generated on key combinations that
|
||||
// generates unicode.
|
||||
|
Loading…
Reference in New Issue
Block a user