I have thought a bit more about it and IMHO it would be nice if dead
keys at least produced SDL_KEYUP/DOWN events when SDL_TEXTINPUT is disabled.
Attached are a patch which implements that for X11 and a small
test-program that prints current SDL_KEYUP/DOWN and SDL_TEXTINPUT events
and toggles SDL_TEXTINPUT when clicking into the window.
What’s the behavior for dead keys on other platforms (Windows, OSX, …)
(with SDL_TEXTINPUT enabled/disabled?)?
Do they produce SDL_KEY* events or not?
BTW, I find it strange that SDL_TEXTINPUT is enabled by default on some
platforms (those without a screen keyboard?) and not on others, that
feels inconsistent (code in SDL_VideoInit()). There’s even a comment
which questions this behavior: “Actually, come to think of it, you
needed to call SDL_EnableUNICODE(1) in SDL 1.2 before you got text input
events.” …
Cheers,
DanielAm 17.08.2013 03:47, schrieb Daniel Gibson:
Hi,
I found out some things… basically XFilterEvent() returns True if the
event is the first keypress of a dead key, thus X11_DispatchEvent()
returns (about line 276 and following).
When calling XFilterEvent() on new events:
The first KeyPress event then contains:
- X11 KeyCode 49 (which seems to belong to my ^ key, => ok).
- X11 KeySym 0xFE52 (dead_circumflex)
The second KeyPress event (after ^ pressing again) contains:
- X11 KeyCode 0
- X11 KeySym 0
- Text “^”
- the keysym returned from Xutf8LookupString() is 0x5E (asciicircum)
- the keysym is also asciicircum when typing ^ a for ? btw
- and here you also get this “The key you just pressed is not
recognized…” message
The KeyRelease event is “X11 KeyCode 49, X11 KeySym 0xFE52
(dead_circumflex)” both times.
When not calling XFilterEvent() on new KeyPress/Release events and
pressing ^ twice:
Both KeyPress and KeyRelease events contain:
- X11 KeyCode 49
- X11 KeySym 0xFE52 (dead_circumflex).
Both KeyPress events contain:
- Text: “^”
- the keysym returned from Xutf8LookupString() is 0x5E
(dead_circumflex)
So it first looks like not calling XFilterEvent() on KeyPress/Release
events could do the trick… however that would certainly screw up dead
keys in textinput (e.g. ^+a for ?) and I don’t know what other
implications it may have.
I’m not very familiar with the SDL2 textediting stuff, in the
documentation it kinda looks like one should call SDL_StartTextInput()
before expecting SDL_TEXTINPUT events, but it looks like those events
are fired all the time (when a keypress event has a non-empty text from
Xutf8LookupString).
If one is really expected to call SDL_StartTextInput() then that (and
SDL_StopTextInput()) could be used to disable/re-enable calling
XFilterEvent().
If SDL_TEXTINPUT events should be coming in without calling
SDL_StartTextInput() first this probably is no option.
Maybe there are other clever tricks, maybe with XPeekEvent() or something?
Cheers,
Daniel
Am 17.08.2013 02:53, schrieb Sam Lantinga:
It looks like the X server eats the first keypress for composition and
then outputs a 0 keysym for the second press. We can never do anything
useful with that, so I disabled the message. If you find out more
information and/or a smarter way to deal with that, then by all means,
let me know! 
-------------- next part --------------
A non-text attachment was scrubbed…
Name: sdl2_dk_test.c
Type: text/x-csrc
Size: 1461 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130819/7bda0be1/attachment.c
-------------- next part --------------
A non-text attachment was scrubbed…
Name: sdl2_x11_no_deadkeys_wo_textinput.patch
Type: text/x-patch
Size: 1035 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130819/7bda0be1/attachment.bin