user32: Support Japanese keyboard type in GetKeyboardType.

Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Akihiro Sagawa 2018-08-17 17:14:49 +09:00 committed by Alexandre Julliard
parent 8743188f5d
commit c6d28c9399
1 changed files with 32 additions and 10 deletions

View File

@ -917,18 +917,40 @@ DWORD WINAPI OemKeyScan( WORD oem )
INT WINAPI GetKeyboardType(INT nTypeFlag) INT WINAPI GetKeyboardType(INT nTypeFlag)
{ {
TRACE_(keyboard)("(%d)\n", nTypeFlag); TRACE_(keyboard)("(%d)\n", nTypeFlag);
switch(nTypeFlag) if (LOWORD(GetKeyboardLayout(0)) == MAKELANGID(LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN))
{ {
case 0: /* Keyboard type */ /* scan code for `_', the key left of r-shift, in Japanese 106 keyboard */
return 4; /* AT-101 */ const UINT JP106_VSC_USCORE = 0x73;
case 1: /* Keyboard Subtype */
return 0; /* There are no defined subtypes */ switch(nTypeFlag)
case 2: /* Number of F-keys */ {
return 12; /* We're doing an 101 for now, so return 12 F-keys */ case 0: /* Keyboard type */
default: return 7; /* Japanese keyboard */
WARN_(keyboard)("Unknown type\n"); case 1: /* Keyboard Subtype */
return 0; /* The book says 0 here, so 0 */ /* Test keyboard mappings to detect Japanese keyboard */
if (MapVirtualKeyW(VK_OEM_102, MAPVK_VK_TO_VSC) == JP106_VSC_USCORE
&& MapVirtualKeyW(JP106_VSC_USCORE, MAPVK_VSC_TO_VK) == VK_OEM_102)
return 2; /* Japanese 106 */
else
return 0; /* AT-101 */
case 2: /* Number of F-keys */
return 12; /* It has 12 F-keys */
}
} }
else
{
switch(nTypeFlag)
{
case 0: /* Keyboard type */
return 4; /* AT-101 */
case 1: /* Keyboard Subtype */
return 0; /* There are no defined subtypes */
case 2: /* Number of F-keys */
return 12; /* We're doing an 101 for now, so return 12 F-keys */
}
}
WARN_(keyboard)("Unknown type\n");
return 0; /* The book says 0 here, so 0 */
} }
/****************************************************************************** /******************************************************************************