dinput8/tests: Make input helper function more versatile.

test_device_input() now takes properly sized appdata expected value and
can be used to send any keyboard event. It also drains device's queue so
it can be called multiple times on a single device instance.

Signed-off-by: Arkadiusz Hiler <ahiler@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Arkadiusz Hiler 2021-03-08 14:36:08 +02:00 committed by Alexandre Julliard
parent 773329e3bb
commit d3e7e0426c
1 changed files with 11 additions and 3 deletions

View File

@ -80,7 +80,7 @@ static void flush_events(void)
}
}
static void test_device_input(IDirectInputDevice8A *lpdid, DWORD event_type, DWORD event, DWORD expected)
static void test_device_input(IDirectInputDevice8A *lpdid, DWORD event_type, DWORD event, UINT_PTR expected)
{
HRESULT hr;
DIDEVICEOBJECTDATA obj_data;
@ -91,7 +91,7 @@ static void test_device_input(IDirectInputDevice8A *lpdid, DWORD event_type, DWO
ok (SUCCEEDED(hr), "Failed to acquire device hr=%08x\n", hr);
if (event_type == INPUT_KEYBOARD)
keybd_event( event, DIK_SPACE, 0, 0);
keybd_event(event, MapVirtualKeyA(event, MAPVK_VK_TO_VSC), 0, 0);
if (event_type == INPUT_MOUSE)
mouse_event( event, 0, 0, 0, 0);
@ -107,7 +107,7 @@ static void test_device_input(IDirectInputDevice8A *lpdid, DWORD event_type, DWO
return;
}
ok (obj_data.uAppData == expected, "Retrieval of action failed uAppData=%lu expected=%d\n", obj_data.uAppData, expected);
ok (obj_data.uAppData == expected, "Retrieval of action failed uAppData=%lu expected=%lu\n", obj_data.uAppData, expected);
/* Check for buffer overflow */
for (i = 0; i < 17; i++)
@ -132,6 +132,14 @@ static void test_device_input(IDirectInputDevice8A *lpdid, DWORD event_type, DWO
hr = IDirectInputDevice8_GetDeviceData(lpdid, sizeof(obj_data), &obj_data, &data_size, 0);
ok(hr == DI_OK && data_size == 1, "GetDeviceData() failed: %08x cnt:%d\n", hr, data_size);
/* drain device's queue */
while (data_size == 1)
{
hr = IDirectInputDevice8_GetDeviceData(lpdid, sizeof(obj_data), &obj_data, &data_size, 0);
ok(hr == DI_OK, "GetDeviceData() failed: %08x cnt:%d\n", hr, data_size);
if (hr != DI_OK) break;
}
IDirectInputDevice_Unacquire(lpdid);
}