dinput: Fix DInput8 keyboard behavior for injected events with scancode=0.
Grand Theft Auto IV injects VK_F8 and scancode=0, and expects DirectInput not to report that F8 is pressed. Signed-off-by: Brendan Shanks <bshanks@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d5fd3c8a38
commit
f65cfbfe9b
|
@ -68,9 +68,9 @@ static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(SysKeyboardIm
|
||||||
return &This->base.IDirectInputDevice8W_iface;
|
return &This->base.IDirectInputDevice8W_iface;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BYTE map_dik_code(DWORD scanCode, DWORD vkCode, DWORD subType)
|
static BYTE map_dik_code(DWORD scanCode, DWORD vkCode, DWORD subType, DWORD version)
|
||||||
{
|
{
|
||||||
if (!scanCode)
|
if (!scanCode && version < 0x0800)
|
||||||
scanCode = MapVirtualKeyW(vkCode, MAPVK_VK_TO_VSC);
|
scanCode = MapVirtualKeyW(vkCode, MAPVK_VK_TO_VSC);
|
||||||
|
|
||||||
if (subType == DIDEVTYPEKEYBOARD_JAPAN106)
|
if (subType == DIDEVTYPEKEYBOARD_JAPAN106)
|
||||||
|
@ -125,7 +125,7 @@ static int KeyboardCallback( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM
|
||||||
case VK_NUMLOCK : dik_code = DIK_NUMLOCK; break;
|
case VK_NUMLOCK : dik_code = DIK_NUMLOCK; break;
|
||||||
case VK_SUBTRACT: dik_code = DIK_SUBTRACT; break;
|
case VK_SUBTRACT: dik_code = DIK_SUBTRACT; break;
|
||||||
default:
|
default:
|
||||||
dik_code = map_dik_code(hook->scanCode & 0xff, hook->vkCode, This->subtype);
|
dik_code = map_dik_code(hook->scanCode & 0xff, hook->vkCode, This->subtype, This->base.dinput->dwVersion);
|
||||||
if (hook->flags & LLKHF_EXTENDED) dik_code |= 0x80;
|
if (hook->flags & LLKHF_EXTENDED) dik_code |= 0x80;
|
||||||
}
|
}
|
||||||
new_diks = hook->flags & LLKHF_UP ? 0 : 0x80;
|
new_diks = hook->flags & LLKHF_UP ? 0 : 0x80;
|
||||||
|
@ -282,7 +282,7 @@ static SysKeyboardImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput)
|
||||||
if (!GetKeyNameTextA(((i & 0x7f) << 16) | ((i & 0x80) << 17), buf, sizeof(buf)))
|
if (!GetKeyNameTextA(((i & 0x7f) << 16) | ((i & 0x80) << 17), buf, sizeof(buf)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dik_code = map_dik_code(i, 0, newDevice->subtype);
|
dik_code = map_dik_code(i, 0, newDevice->subtype, dinput->dwVersion);
|
||||||
memcpy(&df->rgodf[idx], &c_dfDIKeyboard.rgodf[dik_code], df->dwObjSize);
|
memcpy(&df->rgodf[idx], &c_dfDIKeyboard.rgodf[dik_code], df->dwObjSize);
|
||||||
df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(dik_code) | DIDFT_PSHBUTTON;
|
df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(dik_code) | DIDFT_PSHBUTTON;
|
||||||
}
|
}
|
||||||
|
|
|
@ -820,7 +820,6 @@ static void test_keyboard_events(void)
|
||||||
data_size = ARRAY_SIZE(obj_data);
|
data_size = ARRAY_SIZE(obj_data);
|
||||||
hr = IDirectInputDevice8_GetDeviceData(di_keyboard, sizeof(DIDEVICEOBJECTDATA), obj_data, &data_size, 0);
|
hr = IDirectInputDevice8_GetDeviceData(di_keyboard, sizeof(DIDEVICEOBJECTDATA), obj_data, &data_size, 0);
|
||||||
ok(SUCCEEDED(hr), "Failed to get data hr=%08x\n", hr);
|
ok(SUCCEEDED(hr), "Failed to get data hr=%08x\n", hr);
|
||||||
todo_wine
|
|
||||||
ok(data_size == 0, "Expected 0 elements, received %d\n", data_size);
|
ok(data_size == 0, "Expected 0 elements, received %d\n", data_size);
|
||||||
|
|
||||||
hr = IDirectInputDevice8_GetDeviceState(di_keyboard, sizeof(kbdata), kbdata);
|
hr = IDirectInputDevice8_GetDeviceState(di_keyboard, sizeof(kbdata), kbdata);
|
||||||
|
@ -834,7 +833,6 @@ static void test_keyboard_events(void)
|
||||||
data_size = ARRAY_SIZE(obj_data);
|
data_size = ARRAY_SIZE(obj_data);
|
||||||
hr = IDirectInputDevice8_GetDeviceData(di_keyboard, sizeof(DIDEVICEOBJECTDATA), obj_data, &data_size, 0);
|
hr = IDirectInputDevice8_GetDeviceData(di_keyboard, sizeof(DIDEVICEOBJECTDATA), obj_data, &data_size, 0);
|
||||||
ok(SUCCEEDED(hr), "Failed to get data hr=%08x\n", hr);
|
ok(SUCCEEDED(hr), "Failed to get data hr=%08x\n", hr);
|
||||||
todo_wine
|
|
||||||
ok(data_size == 0, "Expected 0 elements, received %d\n", data_size);
|
ok(data_size == 0, "Expected 0 elements, received %d\n", data_size);
|
||||||
|
|
||||||
hr = IDirectInputDevice8_Unacquire(di_keyboard);
|
hr = IDirectInputDevice8_Unacquire(di_keyboard);
|
||||||
|
|
Loading…
Reference in New Issue