Aric Stewart : dinput: The DIK_ keycode is not the same as the scancode.
Alexandre Julliard
julliard at winehq.org
Wed Aug 20 08:14:05 CDT 2008
Module: wine
Branch: master
Commit: 304ff3c7280a53b7cbadfa83eaeda458ff5959d1
URL: http://source.winehq.org/git/wine.git/?a=commit;h=304ff3c7280a53b7cbadfa83eaeda458ff5959d1
Author: Aric Stewart <aric at codeweavers.com>
Date: Wed Aug 6 08:04:36 2008 -0500
dinput: The DIK_ keycode is not the same as the scancode.
It is mapped with the keyboard mapping to the resulting character so
the key 'A' is DIK_A nomatter what its scancode or vkey would be. This
is relevant to Japanese keymapping where the '@' key is in the '['
location the scancode for both is 0x22 but dinput generates DIK_AT in
japanese and DIK_LBRACKET in us_qwerty.
---
dlls/dinput/keyboard.c | 26 +++++++++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c
index b2c4942..e0f76fa 100644
--- a/dlls/dinput/keyboard.c
+++ b/dlls/dinput/keyboard.c
@@ -50,6 +50,30 @@ struct SysKeyboardImpl
BYTE DInputKeyState[WINE_DINPUT_KEYBOARD_MAX_KEYS];
};
+static BYTE map_dik_code(DWORD scanCode, DWORD vkCode)
+{
+ static const BYTE asciiCodes[] =
+ {/*32*/ DIK_SPACE,0,0,0,0,0,0,DIK_APOSTROPHE, \
+ /*40*/ 0,0,0,0,DIK_COMMA,DIK_MINUS,DIK_PERIOD,DIK_SLASH, \
+ /*48*/ DIK_0,DIK_1,DIK_2,DIK_3,DIK_4,DIK_5,DIK_6,DIK_7, \
+ /*56*/ DIK_8,DIK_9,DIK_COLON,DIK_SEMICOLON,0,DIK_EQUALS,0,0, \
+ /*64*/ DIK_AT,DIK_A,DIK_B,DIK_C,DIK_D,DIK_E,DIK_F,DIK_G, \
+ /*72*/ DIK_H,DIK_I,DIK_J,DIK_K,DIK_L,DIK_M,DIK_N,DIK_O, \
+ /*80*/ DIK_P,DIK_Q,DIK_R,DIK_S,DIK_T,DIK_U,DIK_V,DIK_W, \
+ /*88*/ DIK_X,DIK_Y,DIK_Z,DIK_LBRACKET,0,DIK_RBRACKET,DIK_CIRCUMFLEX,DIK_UNDERLINE} /*95*/ ;
+
+ BYTE out_code = 0;
+ WCHAR c = MapVirtualKeyW(vkCode,MAPVK_VK_TO_CHAR);
+
+ if (c > 31 && c < 96)
+ out_code = asciiCodes[c - 32];
+
+ if (out_code == 0)
+ out_code = scanCode;
+
+ return out_code;
+}
+
static void KeyboardCallback( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam )
{
SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
@@ -63,7 +87,7 @@ static void KeyboardCallback( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM
TRACE("(%p) %ld,%ld\n", iface, wparam, lparam);
- dik_code = hook->scanCode & 0xff;
+ dik_code = map_dik_code(hook->scanCode & 0xff,hook->vkCode);
/* R-Shift is special - it is an extended key with separate scan code */
if (hook->flags & LLKHF_EXTENDED && dik_code != 0x36)
dik_code |= 0x80;
More information about the wine-cvs
mailing list