Commit d3e7e042 authored by Arkadiusz Hiler's avatar Arkadiusz Hiler Committed by Alexandre Julliard

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: 's avatarArkadiusz Hiler <ahiler@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 773329e3
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment