Akihiro Sagawa : dinput: Correct key name mappings on Japanese 106 keyboard.
Alexandre Julliard
julliard at winehq.org
Fri Aug 17 12:33:09 CDT 2018
Module: wine
Branch: master
Commit: 966b3b20de0c060a32c88ba1fce193725310afd7
URL: https://source.winehq.org/git/wine.git/?a=commit;h=966b3b20de0c060a32c88ba1fce193725310afd7
Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date: Fri Aug 17 17:15:03 2018 +0900
dinput: Correct key name mappings on Japanese 106 keyboard.
Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dinput/keyboard.c | 42 ++++++++++++++++++++++++++++++++++++++----
1 file changed, 38 insertions(+), 4 deletions(-)
diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c
index c810515..6c7b535 100644
--- a/dlls/dinput/keyboard.c
+++ b/dlls/dinput/keyboard.c
@@ -433,6 +433,40 @@ static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities(LPDIRECTINPUTDEVICE8A ifa
return SysKeyboardWImpl_GetCapabilities(IDirectInputDevice8W_from_impl(This), lpDIDevCaps);
}
+static DWORD map_dik_to_scan(DWORD dik_code, DWORD subtype)
+{
+ if (dik_code == DIK_PAUSE || dik_code == DIK_NUMLOCK) dik_code ^= 0x80;
+ if (subtype == DIDEVTYPEKEYBOARD_JAPAN106)
+ {
+ switch (dik_code)
+ {
+ case DIK_CIRCUMFLEX:
+ dik_code = 0x0d;
+ break;
+ case DIK_AT:
+ dik_code = 0x1a;
+ break;
+ case DIK_LBRACKET:
+ dik_code = 0x1b;
+ break;
+ case DIK_COLON:
+ dik_code = 0x28;
+ break;
+ case DIK_KANJI:
+ dik_code = 0x29;
+ break;
+ case DIK_RBRACKET:
+ dik_code = 0x2b;
+ break;
+ case DIK_BACKSLASH:
+ dik_code = 0x73;
+ break;
+ }
+ }
+
+ return dik_code;
+}
+
/******************************************************************************
* GetObjectInfo : get information about a device object such as a button
* or axis
@@ -444,14 +478,14 @@ SysKeyboardAImpl_GetObjectInfo(
DWORD dwObj,
DWORD dwHow)
{
+ SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
HRESULT res;
LONG scan;
res = IDirectInputDevice2AImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
if (res != DI_OK) return res;
- scan = DIDFT_GETINSTANCE(pdidoi->dwType);
- if (scan == DIK_PAUSE || scan == DIK_NUMLOCK) scan ^= 0x80;
+ scan = map_dik_to_scan(DIDFT_GETINSTANCE(pdidoi->dwType), This->subtype);
if (!GetKeyNameTextA((scan & 0x80) << 17 | (scan & 0x7f) << 16,
pdidoi->tszName, sizeof(pdidoi->tszName)))
return DIERR_OBJECTNOTFOUND;
@@ -465,14 +499,14 @@ static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface
DWORD dwObj,
DWORD dwHow)
{
+ SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface);
HRESULT res;
LONG scan;
res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
if (res != DI_OK) return res;
- scan = DIDFT_GETINSTANCE(pdidoi->dwType);
- if (scan == DIK_PAUSE || scan == DIK_NUMLOCK) scan ^= 0x80;
+ scan = map_dik_to_scan(DIDFT_GETINSTANCE(pdidoi->dwType), This->subtype);
if (!GetKeyNameTextW((scan & 0x80) << 17 | (scan & 0x7f) << 16,
pdidoi->tszName, sizeof(pdidoi->tszName)/sizeof(pdidoi->tszName[0])))
return DIERR_OBJECTNOTFOUND;
More information about the wine-cvs
mailing list