Arkadiusz Hiler : dinput8/tests: Make input helper function more versatile.
Alexandre Julliard
julliard at winehq.org
Wed Mar 10 14:58:47 CST 2021
Module: wine
Branch: master
Commit: d3e7e0426cf5544b0fcec210304cfa6898c06cda
URL: https://source.winehq.org/git/wine.git/?a=commit;h=d3e7e0426cf5544b0fcec210304cfa6898c06cda
Author: Arkadiusz Hiler <ahiler at codeweavers.com>
Date: Mon Mar 8 14:36:08 2021 +0200
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 at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dinput8/tests/device.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/dlls/dinput8/tests/device.c b/dlls/dinput8/tests/device.c
index 2fc04358cc1..02574961ec1 100644
--- a/dlls/dinput8/tests/device.c
+++ b/dlls/dinput8/tests/device.c
@@ -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);
}
More information about the wine-cvs
mailing list