From: Zhiyi Zhang zzhang@codeweavers.com
The high word of the keyboard layout in CJK locale on Vista+ is the same as the low word, even when IME is on according to tests in user32 and manual tests on Windows 10.
Fix Super Robo Wars 30 (SteamID: 898750) crash on start when CJK locales are used. --- dlls/user32/tests/input.c | 1 - dlls/win32u/input.c | 15 ++++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 5f68f34443a..7c1de6e6ccb 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -5433,7 +5433,6 @@ static void test_GetKeyboardLayout(void) if (is_cjk && LOBYTE(LOWORD(GetVersion())) > 5) { hkl = GetKeyboardLayout(0); - todo_wine ok(HIWORD(hkl) == LOWORD(hkl), "Got unexpected hkl %p.\n", hkl); } } diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c index 3ee46f0bfcf..9894636ef82 100644 --- a/dlls/win32u/input.c +++ b/dlls/win32u/input.c @@ -927,18 +927,23 @@ static HKL get_locale_kbd_layout(void) */
NtQueryDefaultLocale( TRUE, &layout ); + layout = MAKELONG( layout, layout );
/* * Microsoft Office expects this value to be something specific * for Japanese and Korean Windows with an IME the value is 0xe001 * We should probably check to see if an IME exists and if so then * set this word properly. + * + * On Vista+, the high word is always layout, not 0xe00* even when IME is on. + * Super Robo Wars 30 (SteamID: 898750) depends on it. */ - langid = PRIMARYLANGID( LANGIDFROMLCID( layout ) ); - if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN) - layout = MAKELONG( layout, 0xe001 ); /* IME */ - else - layout = MAKELONG( layout, layout ); + if (NtCurrentTeb()->Peb->OSMajorVersion <= 5) + { + langid = PRIMARYLANGID( LANGIDFROMLCID( layout ) ); + if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN) + layout = MAKELONG( layout, 0xe001 ); /* IME */ + }
return ULongToHandle( layout ); }