diff -r e49caa693be5 src/events/SDL_keyboard.c --- a/src/events/SDL_keyboard.c Mon May 23 15:27:30 2016 -0300 +++ b/src/events/SDL_keyboard.c Tue May 24 21:55:30 2016 +0300 @@ -354,6 +354,10 @@ SDL_KeyRepeat.timestamp = 0; } +#ifdef _WIN32 +extern void WIN_ResetDeadKeys(void); +#endif + int SDL_EnableUNICODE(int enable) { int old_mode; @@ -362,6 +366,11 @@ int SDL_EnableUNICODE(int enable) if ( enable >= 0 ) { SDL_TranslateUNICODE = enable; } +#ifdef _WIN32 + if (enable != old_mode) { + WIN_ResetDeadKeys(); + } +#endif return(old_mode); } diff -r e49caa693be5 src/video/windib/SDL_dibevents.c --- a/src/video/windib/SDL_dibevents.c Mon May 23 15:27:30 2016 -0300 +++ b/src/video/windib/SDL_dibevents.c Tue May 24 21:55:30 2016 +0300 @@ -583,6 +583,43 @@ return mvke?mvke:vkey; } +#ifndef MAPVK_VK_TO_VSC +#define MAPVK_VK_TO_VSC 0 +#endif +void +WIN_ResetDeadKeys(void) +{ + /* + 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; + } + } +} + static SDL_keysym *TranslateKey(WPARAM vkey, UINT scancode, SDL_keysym *keysym, int pressed) { /* Set the keysym information */