Mercurial > sdl-ios-xcode
comparison src/video/windx5/SDL_dx5events.c @ 4170:092c0bc69155 SDL-1.2
Fixed bug #618
Description From Tim Angus 2008-08-30 12:23:56 (-) [reply]
As we all know SDL 1.2 doesn't handle dead keys well since one key press
potentially equals two (or more) characters. For example, on many layouts,
keying <backquote>,<space> results in <no character>,<backquote><space>. Since
the unicode member of the SDL_keysym struct only has room for one character,
only one can be returned.
On Linux, the first character is returned. On Windows however, unless the exact
number of characters generated by the keypress is 1, nothing is returned. The
following patch addresses this inconsistency.
Updated patch which includes a further fix to the handling of the numpad when
numlock is on. This further fix is courtesy Amanieu d'Antras.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 13 Apr 2009 08:42:09 +0000 |
parents | a6f635e5eaa6 |
children | 3012f1c37361 |
comparison
equal
deleted
inserted
replaced
4169:27c0db0fbfad | 4170:092c0bc69155 |
---|---|
910 #ifdef NO_GETKEYBOARDSTATE | 910 #ifdef NO_GETKEYBOARDSTATE |
911 /* Uh oh, better hope the vkey is close enough.. */ | 911 /* Uh oh, better hope the vkey is close enough.. */ |
912 keysym->unicode = vkey; | 912 keysym->unicode = vkey; |
913 #else | 913 #else |
914 GetKeyboardState(keystate); | 914 GetKeyboardState(keystate); |
915 if (SDL_ToUnicode(vkey, scancode, keystate, wchars, sizeof(wchars)/sizeof(wchars[0]), 0) == 1) | 915 /* Numlock isn't taken into account in ToUnicode, |
916 * so we handle it as a special case here */ | |
917 if ((keystate[VK_NUMLOCK] & 1) && vkey >= VK_NUMPAD0 && vkey <= VK_NUMPAD9) | |
918 { | |
919 keysym->unicode = vkey - VK_NUMPAD0 + '0'; | |
920 } | |
921 else if (SDL_ToUnicode(vkey, scancode, keystate, wchars, sizeof(wchars)/sizeof(wchars[0]), 0) > 0) | |
916 { | 922 { |
917 keysym->unicode = wchars[0]; | 923 keysym->unicode = wchars[0]; |
918 } | 924 } |
919 #endif /* NO_GETKEYBOARDSTATE */ | 925 #endif /* NO_GETKEYBOARDSTATE */ |
920 } | 926 } |