Akihiro Sagawa : dinput: Fix DIK code mappings on Japanese 106 keyboard.

Alexandre Julliard julliard at winehq.org
Fri Aug 17 12:33:09 CDT 2018


Module: wine
Branch: master
Commit: 6be7d14fb95734528a57abe885c60f200d6a071e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=6be7d14fb95734528a57abe885c60f200d6a071e

Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date:   Fri Aug 17 17:15:02 2018 +0900

dinput: Fix DIK code mappings on Japanese 106 keyboard.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45475
Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dinput/keyboard.c       | 37 +++++++++++++++++++++++++++++++++----
 dlls/dinput/tests/keyboard.c |  2 +-
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c
index c11cd59..c810515 100644
--- a/dlls/dinput/keyboard.c
+++ b/dlls/dinput/keyboard.c
@@ -68,11 +68,38 @@ static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(SysKeyboardIm
     return &This->base.IDirectInputDevice8W_iface;
 }
 
-static BYTE map_dik_code(DWORD scanCode, DWORD vkCode)
+static BYTE map_dik_code(DWORD scanCode, DWORD vkCode, DWORD subType)
 {
     if (!scanCode)
         scanCode = MapVirtualKeyW(vkCode, MAPVK_VK_TO_VSC);
 
+    if (subType == DIDEVTYPEKEYBOARD_JAPAN106)
+    {
+        switch (scanCode)
+        {
+        case 0x0d: /* ^ */
+            scanCode = DIK_CIRCUMFLEX;
+            break;
+        case 0x1a: /* @ */
+            scanCode = DIK_AT;
+            break;
+        case 0x1b: /* [ */
+            scanCode = DIK_LBRACKET;
+            break;
+        case 0x28: /* : */
+            scanCode = DIK_COLON;
+            break;
+        case 0x29: /* Hankaku/Zenkaku */
+            scanCode = DIK_KANJI;
+            break;
+        case 0x2b: /* ] */
+            scanCode = DIK_RBRACKET;
+            break;
+        case 0x73: /* \ */
+            scanCode = DIK_BACKSLASH;
+            break;
+        }
+    }
     return scanCode;
 }
 
@@ -98,7 +125,7 @@ static int KeyboardCallback( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM
         case VK_NUMLOCK : dik_code = DIK_NUMLOCK; break;
         case VK_SUBTRACT: dik_code = DIK_SUBTRACT; break;
         default:
-            dik_code = map_dik_code(hook->scanCode & 0xff, hook->vkCode);
+            dik_code = map_dik_code(hook->scanCode & 0xff, hook->vkCode, This->subtype);
             if (hook->flags & LLKHF_EXTENDED) dik_code |= 0x80;
     }
     new_diks = hook->flags & LLKHF_UP ? 0 : 0x80;
@@ -248,12 +275,14 @@ static SysKeyboardImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput)
     for (i = 0; i < df->dwNumObjs; i++)
     {
         char buf[MAX_PATH];
+        BYTE dik_code;
 
         if (!GetKeyNameTextA(((i & 0x7f) << 16) | ((i & 0x80) << 17), buf, sizeof(buf)))
             continue;
 
-        memcpy(&df->rgodf[idx], &c_dfDIKeyboard.rgodf[i], df->dwObjSize);
-        df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_PSHBUTTON;
+        dik_code = map_dik_code(i, 0, newDevice->subtype);
+        memcpy(&df->rgodf[idx], &c_dfDIKeyboard.rgodf[dik_code], df->dwObjSize);
+        df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(dik_code) | DIDFT_PSHBUTTON;
     }
     df->dwNumObjs = idx;
 
diff --git a/dlls/dinput/tests/keyboard.c b/dlls/dinput/tests/keyboard.c
index 0a7c647..8ee22fa 100644
--- a/dlls/dinput/tests/keyboard.c
+++ b/dlls/dinput/tests/keyboard.c
@@ -318,7 +318,7 @@ static void test_dik_codes(IDirectInputA *dI, HWND hwnd, LANGID langid)
     key2dik_ja[] =
     {
         {'Q',DIK_Q}, {'W',DIK_W}, {'E',DIK_E}, {'R',DIK_R}, {'T',DIK_T}, {'Y',DIK_Y},
-        {'@',DIK_AT,2}, {']',DIK_RBRACKET,2}, {'.',DIK_PERIOD}
+        {'@',DIK_AT}, {']',DIK_RBRACKET}, {'.',DIK_PERIOD}
     };
     static const struct
     {




More information about the wine-cvs mailing list