win32u: Move NtUserVkKeyScanEx implementation from user32.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-11-16 12:33:53 +01:00 committed by Alexandre Julliard
parent 05db9f63e1
commit 8f52632ca9
9 changed files with 84 additions and 75 deletions

View File

@ -274,11 +274,6 @@ static void CDECL loaderdrv_UnregisterHotKey( HWND hwnd, UINT modifiers, UINT vk
load_driver()->pUnregisterHotKey( hwnd, modifiers, vk ); load_driver()->pUnregisterHotKey( hwnd, modifiers, vk );
} }
static SHORT CDECL loaderdrv_VkKeyScanEx( WCHAR ch, HKL layout )
{
return load_driver()->pVkKeyScanEx( ch, layout );
}
static void CDECL loaderdrv_SetCursor( HCURSOR cursor ) static void CDECL loaderdrv_SetCursor( HCURSOR cursor )
{ {
load_driver()->pSetCursor( cursor ); load_driver()->pSetCursor( cursor );
@ -374,7 +369,7 @@ static struct user_driver_funcs lazy_load_driver =
loaderdrv_RegisterHotKey, loaderdrv_RegisterHotKey,
loaderdrv_ToUnicodeEx, loaderdrv_ToUnicodeEx,
loaderdrv_UnregisterHotKey, loaderdrv_UnregisterHotKey,
loaderdrv_VkKeyScanEx, NULL,
/* cursor/icon functions */ /* cursor/icon functions */
nulldrv_DestroyCursorIcon, nulldrv_DestroyCursorIcon,
loaderdrv_SetCursor, loaderdrv_SetCursor,

View File

@ -625,7 +625,7 @@ SHORT WINAPI VkKeyScanA(CHAR cChar)
*/ */
SHORT WINAPI VkKeyScanW(WCHAR cChar) SHORT WINAPI VkKeyScanW(WCHAR cChar)
{ {
return VkKeyScanExW(cChar, GetKeyboardLayout(0)); return NtUserVkKeyScanEx( cChar, GetKeyboardLayout(0) );
} }
/********************************************************************** /**********************************************************************
@ -638,72 +638,7 @@ WORD WINAPI VkKeyScanExA(CHAR cChar, HKL dwhkl)
if (IsDBCSLeadByte(cChar)) return -1; if (IsDBCSLeadByte(cChar)) return -1;
MultiByteToWideChar(CP_ACP, 0, &cChar, 1, &wChar, 1); MultiByteToWideChar(CP_ACP, 0, &cChar, 1, &wChar, 1);
return VkKeyScanExW(wChar, dwhkl); return NtUserVkKeyScanEx( wChar, dwhkl );
}
/******************************************************************************
* VkKeyScanExW (USER32.@)
*/
WORD WINAPI VkKeyScanExW( WCHAR chr, HKL layout )
{
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;
} }
/********************************************************************** /**********************************************************************

View File

@ -805,7 +805,7 @@
@ stdcall ValidateRgn(long long) @ stdcall ValidateRgn(long long)
@ stdcall VkKeyScanA(long) @ stdcall VkKeyScanA(long)
@ stdcall VkKeyScanExA(long long) @ stdcall VkKeyScanExA(long long)
@ stdcall VkKeyScanExW(long long) @ stdcall VkKeyScanExW(long long) NtUserVkKeyScanEx
@ stdcall VkKeyScanW(long) @ stdcall VkKeyScanW(long)
@ stub WCSToMBEx @ stub WCSToMBEx
@ stdcall WINNLSEnableIME(long long) @ stdcall WINNLSEnableIME(long long)

View File

@ -1003,6 +1003,11 @@ static const struct user_driver_funcs *load_driver(void)
return user_driver; return user_driver;
} }
static SHORT CDECL loaderdrv_VkKeyScanEx( WCHAR ch, HKL layout )
{
return load_driver()->pVkKeyScanEx( ch, layout );
}
static void CDECL loaderdrv_UpdateClipboard(void) static void CDECL loaderdrv_UpdateClipboard(void)
{ {
load_driver()->pUpdateClipboard(); load_driver()->pUpdateClipboard();
@ -1010,6 +1015,7 @@ static void CDECL loaderdrv_UpdateClipboard(void)
static const struct user_driver_funcs lazy_load_driver = static const struct user_driver_funcs lazy_load_driver =
{ {
.pVkKeyScanEx = loaderdrv_VkKeyScanEx,
.pUpdateClipboard = loaderdrv_UpdateClipboard, .pUpdateClipboard = loaderdrv_UpdateClipboard,
}; };

View File

@ -1171,6 +1171,7 @@ static struct unix_funcs unix_funcs =
NtUserGetPriorityClipboardFormat, NtUserGetPriorityClipboardFormat,
NtUserGetUpdatedClipboardFormats, NtUserGetUpdatedClipboardFormats,
NtUserIsClipboardFormatAvailable, NtUserIsClipboardFormatAvailable,
NtUserVkKeyScanEx,
GDIRealizePalette, GDIRealizePalette,
GDISelectPalette, GDISelectPalette,

View File

@ -31,6 +31,7 @@
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(win); WINE_DEFAULT_DEBUG_CHANNEL(win);
WINE_DECLARE_DEBUG_CHANNEL(keyboard);
/********************************************************************** /**********************************************************************
@ -109,3 +110,68 @@ BOOL WINAPI NtUserSetKeyboardState( BYTE *state )
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
} }
/******************************************************************************
* NtUserVkKeyScanEx (win32u.@)
*/
WORD WINAPI NtUserVkKeyScanEx( WCHAR chr, HKL layout )
{
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;
}

View File

@ -1302,7 +1302,7 @@
@ stub NtUserUserHandleGrantAccess @ stub NtUserUserHandleGrantAccess
@ stub NtUserValidateRect @ stub NtUserValidateRect
@ stub NtUserValidateTimerCallback @ stub NtUserValidateTimerCallback
@ stub NtUserVkKeyScanEx @ stdcall NtUserVkKeyScanEx(long long)
@ stub NtUserWOWCleanup @ stub NtUserWOWCleanup
@ stub NtUserWaitAvailableMessageEx @ stub NtUserWaitAvailableMessageEx
@ stub NtUserWaitForInputIdle @ stub NtUserWaitForInputIdle

View File

@ -198,6 +198,7 @@ struct unix_funcs
INT (WINAPI *pNtUserGetPriorityClipboardFormat)( UINT *list, INT count ); INT (WINAPI *pNtUserGetPriorityClipboardFormat)( UINT *list, INT count );
BOOL (WINAPI *pNtUserGetUpdatedClipboardFormats)( UINT *formats, UINT size, UINT *out_size ); BOOL (WINAPI *pNtUserGetUpdatedClipboardFormats)( UINT *formats, UINT size, UINT *out_size );
BOOL (WINAPI *pNtUserIsClipboardFormatAvailable)( UINT format ); BOOL (WINAPI *pNtUserIsClipboardFormatAvailable)( UINT format );
WORD (WINAPI *pNtUserVkKeyScanEx)( WCHAR chr, HKL layout );
/* Wine-specific functions */ /* Wine-specific functions */
UINT (WINAPI *pGDIRealizePalette)( HDC hdc ); UINT (WINAPI *pGDIRealizePalette)( HDC hdc );

View File

@ -616,6 +616,11 @@ BOOL WINAPI NtUserIsClipboardFormatAvailable( UINT format )
return unix_funcs->pNtUserIsClipboardFormatAvailable( format ); return unix_funcs->pNtUserIsClipboardFormatAvailable( format );
} }
WORD WINAPI NtUserVkKeyScanEx( WCHAR chr, HKL layout )
{
return unix_funcs->pNtUserVkKeyScanEx( chr, layout );
}
UINT WINAPI GDIRealizePalette( HDC hdc ) UINT WINAPI GDIRealizePalette( HDC hdc )
{ {
return unix_funcs->pGDIRealizePalette( hdc ); return unix_funcs->pGDIRealizePalette( hdc );