We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3332 - [patch] Win32: reset deadkeys in StartTextInput/StopTextInput
Summary: [patch] Win32: reset deadkeys in StartTextInput/StopTextInput
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 2.1
Hardware: x86_64 Windows (All)
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-11 07:00 UTC by Eric Wasylishen
Modified: 2016-10-01 19:19 UTC (History)
1 user (show)

See Also:


Attachments
patch to test program to demonstrate the bug (713 bytes, patch)
2016-05-11 07:00 UTC, Eric Wasylishen
Details | Diff
proposed fix (1.42 KB, patch)
2016-05-11 07:02 UTC, Eric Wasylishen
Details | Diff
patch for SDL 1.2 (1.79 KB, patch)
2016-05-24 21:39 UTC, Eric Wasylishen
Details | Diff
Updated sdl2 patch (2.24 KB, patch)
2016-05-25 22:32 UTC, Eric Wasylishen
Details | Diff
Updated sdl1.2 patch (1.90 KB, patch)
2016-05-25 22:33 UTC, Eric Wasylishen
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Wasylishen 2016-05-11 07:00:20 UTC
Created attachment 2451 [details]
patch to test program to demonstrate the bug

The bug here is that a dead keys pressed before calling SDL_StartTextInput() carries over into future text input, so the next key pressed will have the deadkey applied to it.

This in undesirable, imho, and doesn't occur on OS X (haven't check Linux or elsewhere). It's causing a problem for Quakespasm on German keyboard layouts, where we use the ^ deadkey to toggle the console (which enables/disables text input), and ^ characters are showing up in the TEXTINPUT events.



Attaching a patch. Unfortunately there's no clean API to reset the dead key state, the only way appears to be using ToUnicode.

Also attached a patch to the checkkeys sample so you can reproduce this; it makes clicking the mouse toggle SDL_StartTextInput() and SDL_StopTextInput().

Steps to reproduce with the patched 'checkkeys':
1. switch to a keyboard layout with deadkeys, e.g. German
2. launch "checkkeys", click the mouse to disable text input
3. press the a deadkey, e.g. ^ below Escape on the German layout
4. click the mouse again to cause a SDL_StartTextInput() call
5. press "a" key. 
expected: the TEXTINPUT event in the log should just be a regular "a"
observed: the "a" has an accent
Comment 1 Eric Wasylishen 2016-05-11 07:02:02 UTC
Created attachment 2452 [details]
proposed fix
Comment 2 Eric Wasylishen 2016-05-24 21:39:18 UTC
Created attachment 2462 [details]
patch for SDL 1.2
Comment 3 Eric Wasylishen 2016-05-25 22:32:27 UTC
Created attachment 2463 [details]
Updated sdl2 patch

Updated SDL2 patch from Ozkan:
-make C89
-call WIN_ResetDeadKeys() from SDL_KeyboardQuit so dead keys pressed just before exiting don't carry over to other applications
Comment 4 Eric Wasylishen 2016-05-25 22:33:28 UTC
Created attachment 2464 [details]
Updated sdl1.2 patch

Updated SDL1.2 patch from Ozkan, same changes as for SDL2
Comment 5 Sam Lantinga 2016-10-01 19:19:08 UTC
Fixed, thanks!
I used a slightly different way of resetting dead keys on exit that also covers alt-tab away from the SDL window.

https://hg.libsdl.org/SDL/rev/e9dd9ecf3fe5
https://hg.libsdl.org/SDL/rev/9012ec687429