[SDL] break next/current SDL_TEXTINPUT on dead key
ewasylishen at gmail.com
Fri Sep 12 00:19:01 PDT 2014
I just did this in quakespasm, borrowing the idea from ioquake3. The hack is, just ignore any SDL_TEXTINPUT event that arrives between a SDL_KEYDOWN for the key that’s supposed to open the console, and the next SDL_KEYUP (e.g. by setting a flag when you get the SDL_KEYDOWN that opens the console, and clearing it on the next SDL_KEYUP).
It’s a tricky problem, and I couldn’t think of a good solution when first porting quakespasm to SDL2. I’m not sure if you can really do better than this; it seems to me that a more robust solution would have to involve the SDL_TEXTINPUT event telling you that it was generated from a particular SDL_KEYDOWN, so your application code could match up the events and know to ignore the SDL_TEXTINPUT for that character.
Here’s our sdl input code: http://sourceforge.net/p/quakespasm/code/1020/tree//trunk/quakespasm/Quake/in_sdl.c#l522
On Sep 10, 2014, at 8:43 AM, albert <albzey at gmail.com> wrote:
> My use case:
> The user can setup any key as the key to show/hide the ingame drop-down console. A common key is the dead key "^".
> I also use SDL_TEXTINPUT at some places, e.g. the ingame console itself. Now, on certain SDL_KEYDOWN events which I handle (like the console key "^"), I don't want that it gets into any SDL_TEXTINPUT.
> Can I somehow reset any current text input?
> In case it is not a dead key, I also get the SDL_TEXTINPUT event right away and my current solution works fine: Ignore any SDL_TEXTINPUT when I got such SDL_KEYDOWN.
> If it is a dead key, I don't know how I can handle that. The next key should be handled for the text input as if the dead key was not pressed before.
> Earlier in SDL1, when I handled all of this manually in SDL_KEYDOWN, it was not a problem to handle this case.
> Any advice?
> SDL mailing list
> SDL at lists.libsdl.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SDL