src/video/windib/SDL_dibevents.c
branchSDL-1.2
changeset 11977 6cf3a08b42dc
parent 11974 b8aca1c1ad6e
     1.1 --- a/src/video/windib/SDL_dibevents.c	Sat Mar 24 23:10:59 2018 +0300
     1.2 +++ b/src/video/windib/SDL_dibevents.c	Sat Mar 24 23:38:50 2018 +0300
     1.3 @@ -583,6 +583,37 @@
     1.4  	return mvke?mvke:vkey;
     1.5  }
     1.6  
     1.7 +#ifndef MAPVK_VK_TO_VSC
     1.8 +#define MAPVK_VK_TO_VSC 0
     1.9 +#endif
    1.10 +void
    1.11 +WIN_ResetDeadKeys(void)
    1.12 +{
    1.13 +    /*
    1.14 +    if a deadkey has been typed, but not the next character (which the deadkey might modify),
    1.15 +    this tries to undo the effect pressing the deadkey.
    1.16 +    see: http://archives.miloush.net/michkap/archive/2006/09/10/748775.html
    1.17 +    */
    1.18 +    BYTE keyboardState[256];
    1.19 +    WCHAR buffer[16];
    1.20 +    UINT keycode, scancode, i;
    1.21 +    int result;
    1.22 +
    1.23 +    GetKeyboardState(keyboardState);
    1.24 +    keycode = VK_SPACE;
    1.25 +    scancode = MapVirtualKey(keycode, MAPVK_VK_TO_VSC);
    1.26 +    if (scancode == 0) {
    1.27 +        return; /* the keyboard doesn't have this key */
    1.28 +    }
    1.29 +
    1.30 +    for (i = 0; i < 5; i++) {
    1.31 +        result = SDL_ToUnicode(keycode, scancode, keyboardState, (LPWSTR)buffer, 16, 0);
    1.32 +        if (result > 0) {
    1.33 +            return; /* success */
    1.34 +        }
    1.35 +    }
    1.36 +}
    1.37 +
    1.38  static SDL_keysym *TranslateKey(WPARAM vkey, UINT scancode, SDL_keysym *keysym, int pressed)
    1.39  {
    1.40  	/* Set the keysym information */