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 2455 - SDL_TEXTINPUT system doesn't handle key sequences correctly on Windows
Summary: SDL_TEXTINPUT system doesn't handle key sequences correctly on Windows
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 2.0.3
Hardware: x86 Windows 8
: P2 major
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-19 21:13 UTC by snake5creator
Modified: 2016-08-30 17:44 UTC (History)
0 users

See Also:


Attachments
test kit for the bug (409.66 KB, application/x-zip-compressed)
2014-03-19 21:29 UTC, snake5creator
Details

Note You need to log in before you can comment on or make changes to this bug.
Description snake5creator 2014-03-19 21:13:01 UTC
SDL_TEXTINPUT system doesn't handle key sequences correctly on Windows due to the usage of both TranslateMessage and ToUnicode to handle WM_KEY* messages.

In my keyboard layout, pressing single quote character ('), followed by certain letters (acegksu..) outputs language-specific variations of those letters (āčēģķšū..). This is the software I use that provides this layout: http://laacz.lv/f/misc/apos/apostrofs-punkts.zip - it can be used to verify the bug and check if it's been fixed.

From what I've seen while experimenting with this code - https://www.dropbox.com/s/ydkrms6zgaxueb8/winchar.c - it works if either TranslateMessage is called or ToUnicode(Ex) is called, but not both.


Quote from http://msdn.microsoft.com/en-us/library/windows/desktop/ms646322(v=vs.85).aspx (ToUnicodeEx page):

As ToUnicodeEx translates the virtual-key code, it also changes the state of the kernel-mode keyboard buffer. This state-change affects dead keys, ligatures, alt+numpad key entry, and so on. It might also cause undesired side-effects if used in conjunction with TranslateMessage (which also changes the state of the kernel-mode keyboard buffer).


So far the solution seems simple. However, it appears there must be a reason for why WM_CHAR messages are not used. The reason for TranslateMessage was given in comments: compatibility with other systems.

For my use case (https://github.com/snake5/sgs-sdl) it would be completely acceptable to include an optional solution in the form of an API function that disables either function call to make it work. For compatibility with other systems, possibly the usage of WM_KEYDOWN/ToUnicode instead of WM_CHAR/TranslateMessage should be reconsidered.
Comment 1 snake5creator 2014-03-19 21:29:43 UTC
Created attachment 1596 [details]
test kit for the bug
Comment 2 snake5creator 2016-08-30 17:44:36 UTC
I just checked 2.0.4 and the bug appears to be fixed there.

P.S. The development archive in the download page (https://www.libsdl.org/release/SDL2-devel-2.0.4-mingw.tar.gz) contains 2.0.2 in root folder and 2.0.4 under i686-w64-mingw32/x86_64-w64-mingw32.