mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-23 09:35:30 +00:00
Fixed bug 3332 - Win32: reset deadkeys in StartTextInput/StopTextInput
Eric Wasylishen The bug here is that a dead keys pressed before calling SDL_StartTextInput() carries over into future text input, so the next key pressed will have the deadkey applied to it. This in undesirable, imho, and doesn't occur on OS X (haven't check Linux or elsewhere). It's causing a problem for Quakespasm on German keyboard layouts, where we use the ^ deadkey to toggle the console (which enables/disables text input), and ^ characters are showing up in the TEXTINPUT events.
This commit is contained in:
parent
708def87f3
commit
1e6e595484
|
@ -157,11 +157,51 @@ WIN_QuitKeyboard(_THIS)
|
|||
#endif
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue