From 5bb094c9a21d078d4fec26ef45529e84f3f73e75 Mon Sep 17 00:00:00 2001 From: Vitaliy Margolen Date: Tue, 8 Nov 2011 10:59:20 -0700 Subject: [PATCH] dinput: Return correct key names for num_lock and pause. Scan codes and DIK codes for num_lock and pause are reversed. --- dlls/dinput/keyboard.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index c23a023c04b..3ca7d97394a 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -410,12 +410,14 @@ SysKeyboardAImpl_GetObjectInfo( DWORD dwHow) { HRESULT res; + LONG scan; res = IDirectInputDevice2AImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow); if (res != DI_OK) return res; - if (!GetKeyNameTextA((DIDFT_GETINSTANCE(pdidoi->dwType) & 0x80) << 17 | - (DIDFT_GETINSTANCE(pdidoi->dwType) & 0x7f) << 16, + scan = DIDFT_GETINSTANCE(pdidoi->dwType); + if (scan == DIK_PAUSE || scan == DIK_NUMLOCK) scan ^= 0x80; + if (!GetKeyNameTextA((scan & 0x80) << 17 | (scan & 0x7f) << 16, pdidoi->tszName, sizeof(pdidoi->tszName))) return DIERR_OBJECTNOTFOUND; @@ -429,14 +431,15 @@ static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface DWORD dwHow) { HRESULT res; + LONG scan; res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow); if (res != DI_OK) return res; - if (!GetKeyNameTextW((DIDFT_GETINSTANCE(pdidoi->dwType) & 0x80) << 17 | - (DIDFT_GETINSTANCE(pdidoi->dwType) & 0x7f) << 16, - pdidoi->tszName, - sizeof(pdidoi->tszName)/sizeof(pdidoi->tszName[0]))) + scan = DIDFT_GETINSTANCE(pdidoi->dwType); + if (scan == DIK_PAUSE || scan == DIK_NUMLOCK) scan ^= 0x80; + if (!GetKeyNameTextW((scan & 0x80) << 17 | (scan & 0x7f) << 16, + pdidoi->tszName, sizeof(pdidoi->tszName))) return DIERR_OBJECTNOTFOUND; _dump_OBJECTINSTANCEW(pdidoi);