diff -r 7cbfd97f1430 src/events/SDL_keyboard.c --- a/src/events/SDL_keyboard.c Mon May 23 15:29:25 2016 -0300 +++ b/src/events/SDL_keyboard.c Wed May 25 21:55:00 2016 +0300 @@ -813,9 +813,15 @@ return (posted); } +#ifdef _WIN32 +extern void WIN_ResetDeadKeys(); +#endif void SDL_KeyboardQuit(void) { +#ifdef _WIN32 + WIN_ResetDeadKeys(); +#endif } const Uint8 * diff -r 7cbfd97f1430 src/video/windows/SDL_windowskeyboard.c --- a/src/video/windows/SDL_windowskeyboard.c Mon May 23 15:29:25 2016 -0300 +++ b/src/video/windows/SDL_windowskeyboard.c Wed May 25 21:55:00 2016 +0300 @@ -158,10 +158,50 @@ } void +WIN_ResetDeadKeys() +{ + /* + if a deadkey has been typed, but not the next character (which the deadkey might modify), + this tries to undo the effect pressing the deadkey. + see: http://archives.miloush.net/michkap/archive/2006/09/10/748775.html + */ + + BYTE keyboardState[256]; + WCHAR buffer[16]; + int keycode, scancode, result, i; + + GetKeyboardState(keyboardState); + + keycode = VK_SPACE; + scancode = MapVirtualKey(keycode, MAPVK_VK_TO_VSC); + if (scancode == 0) + { + /* the keyboard doesn't have this key */ + return; + } + + for (i = 0; i < 5; i++) + { + result = ToUnicode(keycode, scancode, keyboardState, (LPWSTR)buffer, 16, 0); + if (result > 0) + { + /* success */ + return; + } + } +} + +void WIN_StartTextInput(_THIS) { #ifndef SDL_DISABLE_WINDOWS_IME - SDL_Window *window = SDL_GetKeyboardFocus(); + SDL_Window *window; +#endif + + WIN_ResetDeadKeys(); + +#ifndef SDL_DISABLE_WINDOWS_IME + window = SDL_GetKeyboardFocus(); if (window) { HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; @@ -176,7 +216,13 @@ void WIN_StopTextInput(_THIS) { #ifndef SDL_DISABLE_WINDOWS_IME - SDL_Window *window = SDL_GetKeyboardFocus(); + SDL_Window *window; +#endif + + WIN_ResetDeadKeys(); + +#ifndef SDL_DISABLE_WINDOWS_IME + window = SDL_GetKeyboardFocus(); if (window) { HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;