This is basically the reverse of ToUnicodeEx.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/driver.c | 9 +------ dlls/user32/input.c | 61 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 10 deletions(-)
diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c index 97733bb9bd3..e3cf41561b5 100644 --- a/dlls/user32/driver.c +++ b/dlls/user32/driver.c @@ -300,14 +300,7 @@ static void CDECL nulldrv_UnregisterHotKey( HWND hwnd, UINT modifiers, UINT vk )
static SHORT CDECL nulldrv_VkKeyScanEx( WCHAR ch, HKL layout ) { - static const short ctrl_vks[] = { - 0x332, 0x241, 0x242, 0x003, 0x244, 0x245, 0x246, 0x247, - 0x008, 0x009, 0x20d, 0x24b, 0x24c, 0x00d, 0x24e, 0x24f, - 0x250, 0x251, 0x252, 0x253, 0x254, 0x255, 0x256, 0x257, - 0x258, 0x259, 0x25a, 0x01b, 0x2dc, 0x2dd, 0x336, 0x3bd - }; - - return ch < ARRAY_SIZE(ctrl_vks) ? ctrl_vks[ch] : -1; + return -256; /* use default implementation */ }
static void CDECL nulldrv_DestroyCursorIcon( HCURSOR cursor ) diff --git a/dlls/user32/input.c b/dlls/user32/input.c index d2e41cd8212..4ecc73c4ad0 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -674,9 +674,66 @@ WORD WINAPI VkKeyScanExA(CHAR cChar, HKL dwhkl) /****************************************************************************** * VkKeyScanExW (USER32.@) */ -WORD WINAPI VkKeyScanExW(WCHAR cChar, HKL dwhkl) +WORD WINAPI VkKeyScanExW( WCHAR chr, HKL layout ) { - return USER_Driver->pVkKeyScanEx(cChar, dwhkl); + WORD shift = 0x100, ctrl = 0x200; + SHORT ret; + + TRACE_(keyboard)( "chr %s, layout %p\n", debugstr_wn(&chr, 1), layout ); + + if ((ret = USER_Driver->pVkKeyScanEx( chr, layout )) != -256) return ret; + + /* FIXME: English keyboard layout specific */ + + if (chr == VK_CANCEL || chr == VK_BACK || chr == VK_TAB || chr == VK_RETURN || + chr == VK_ESCAPE || chr == VK_SPACE) ret = chr; + else if (chr >= '0' && chr <= '9') ret = chr; + else if (chr == ')') ret = shift + '0'; + else if (chr == '!') ret = shift + '1'; + else if (chr == '@') ret = shift + '2'; + else if (chr == '#') ret = shift + '3'; + else if (chr == '$') ret = shift + '4'; + else if (chr == '%') ret = shift + '5'; + else if (chr == '^') ret = shift + '6'; + else if (chr == '&') ret = shift + '7'; + else if (chr == '*') ret = shift + '8'; + else if (chr == '(') ret = shift + '9'; + else if (chr >= 'a' && chr <= 'z') ret = chr - 'a' + 'A'; + else if (chr >= 'A' && chr <= 'Z') ret = shift + chr; + else if (chr == ';') ret = VK_OEM_1; + else if (chr == '=') ret = VK_OEM_PLUS; + else if (chr == ',') ret = VK_OEM_COMMA; + else if (chr == '-') ret = VK_OEM_MINUS; + else if (chr == '.') ret = VK_OEM_PERIOD; + else if (chr == '/') ret = VK_OEM_2; + else if (chr == '`') ret = VK_OEM_3; + else if (chr == '[') ret = VK_OEM_4; + else if (chr == '\') ret = VK_OEM_5; + else if (chr == ']') ret = VK_OEM_6; + else if (chr == ''') ret = VK_OEM_7; + else if (chr == ':') ret = shift + VK_OEM_1; + else if (chr == '+') ret = shift + VK_OEM_PLUS; + else if (chr == '<') ret = shift + VK_OEM_COMMA; + else if (chr == '_') ret = shift + VK_OEM_MINUS; + else if (chr == '>') ret = shift + VK_OEM_PERIOD; + else if (chr == '?') ret = shift + VK_OEM_2; + else if (chr == '~') ret = shift + VK_OEM_3; + else if (chr == '{') ret = shift + VK_OEM_4; + else if (chr == '|') ret = shift + VK_OEM_5; + else if (chr == '}') ret = shift + VK_OEM_6; + else if (chr == '"') ret = shift + VK_OEM_7; + else if (chr == 0x7f) ret = ctrl + VK_BACK; + else if (chr == '\n') ret = ctrl + VK_RETURN; + else if (chr == 0xf000) ret = ctrl + '2'; + else if (chr == 0x0000) ret = ctrl + shift + '2'; + else if (chr >= 0x0001 && chr <= 0x001a) ret = ctrl + 'A' + chr - 1; + else if (chr >= 0x001c && chr <= 0x001d) ret = ctrl + VK_OEM_3 + chr; + else if (chr == 0x001e) ret = ctrl + shift + '6'; + else if (chr == 0x001f) ret = ctrl + shift + VK_OEM_MINUS; + else ret = -1; + + TRACE_(keyboard)( "ret %04x\n", ret ); + return ret; }
/**********************************************************************