[Scummvm-cvs-logs] scummvm master -> c925e5b35cf87b7e0adb88767fa282ad0d36cf12

lordhoto lordhoto at gmail.com
Sun May 22 13:14:39 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c925e5b35c SDL: Make TEXTINPUT handling more reliable for SDL2.


Commit: c925e5b35cf87b7e0adb88767fa282ad0d36cf12
    https://github.com/scummvm/scummvm/commit/c925e5b35cf87b7e0adb88767fa282ad0d36cf12
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2016-05-22T13:09:24+02:00

Commit Message:
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.

Changed paths:
    backends/events/sdl/sdl-events.cpp



diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp
index 7b56a0a..00e2f25 100644
--- a/backends/events/sdl/sdl-events.cpp
+++ b/backends/events/sdl/sdl-events.cpp
@@ -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.






More information about the Scummvm-git-logs mailing list