diff options
author | Johannes Schickel | 2015-03-05 18:08:17 +0100 |
---|---|---|
committer | Johannes Schickel | 2015-03-05 20:08:34 +0100 |
commit | 26fb7b2c8fa184d02bf9bfc97ec7281dd8fa7cfd (patch) | |
tree | fc025ff98fed31b5cb5f0ef3325256961629fd62 /backends/events/sdl | |
parent | c0fafcf33f374fdf85590108835585a0411a0661 (diff) | |
download | scummvm-rg350-26fb7b2c8fa184d02bf9bfc97ec7281dd8fa7cfd.tar.gz scummvm-rg350-26fb7b2c8fa184d02bf9bfc97ec7281dd8fa7cfd.tar.bz2 scummvm-rg350-26fb7b2c8fa184d02bf9bfc97ec7281dd8fa7cfd.zip |
SDL: Remove TEXTINPUT events we associate with KEYDOWN.
Diffstat (limited to 'backends/events/sdl')
-rw-r--r-- | backends/events/sdl/sdl-events.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index 18fe5453f8..a9f94d9fa9 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -850,10 +850,19 @@ uint32 SdlEventSource::obtainUnicode(const SDL_keysym keySym) { int n = SDL_PeepEvents(events, 2, SDL_PEEKEVENT, SDL_KEYDOWN, SDL_TEXTINPUT); // Make sure that the TEXTINPUT event belongs to this KEYDOWN // event and not another pending one. - if (n > 0 && events[0].type == SDL_TEXTINPUT) { - return convUTF8ToUTF32(events[0].text.text); - } else if (n > 1 && events[0].type != SDL_KEYDOWN && events[1].type == SDL_TEXTINPUT) { - return convUTF8ToUTF32(events[1].text.text); + if ((n > 0 && events[0].type == SDL_TEXTINPUT) + || (n > 1 && events[0].type != SDL_KEYDOWN && events[1].type == SDL_TEXTINPUT)) { + // Remove the text input event we associate with the key press. This + // makes sure we never get any SDL_TEXTINPUT events which do "belong" + // to SDL_KEYDOWN events. + n = SDL_PeepEvents(events, 1, SDL_GETEVENT, SDL_TEXTINPUT, SDL_TEXTINPUT); + // This is basically a paranoia safety check because we know there + // must be a text input event in the queue. + if (n > 0) { + return convUTF8ToUTF32(events[0].text.text); + } else { + return 0; + } } else { return 0; } |