[PATCH 2/6] dinput8/tests: Add some HID joystick IDirectInput8_CreateDevice tests.
Rémi Bernon
rbernon at codeweavers.com
Thu Sep 16 03:20:39 CDT 2021
Creating a device with the instance guid may get the wrong one if a
true controller is plugged in.
This is because driver_hid.dll runs in a different process from
winehid.sys, and so gets another set of rawinput handles.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/dinput8/tests/hid.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c
index 5e0cd51b3c4..abda594d90f 100644
--- a/dlls/dinput8/tests/hid.c
+++ b/dlls/dinput8/tests/hid.c
@@ -3451,6 +3451,26 @@ static void test_simple_joystick(void)
check_member( devinst, expect_devinst, "%04x", wUsagePage );
check_member( devinst, expect_devinst, "%04x", wUsage );
+ hr = IDirectInput8_CreateDevice( di, &devinst.guidInstance, NULL, NULL );
+ ok( hr == E_POINTER, "IDirectInput8_CreateDevice returned %#x\n", hr );
+ hr = IDirectInput8_CreateDevice( di, NULL, &device, NULL );
+ ok( hr == E_POINTER, "IDirectInput8_CreateDevice returned %#x\n", hr );
+ hr = IDirectInput8_CreateDevice( di, &GUID_NULL, &device, NULL );
+ ok( hr == DIERR_DEVICENOTREG, "IDirectInput8_CreateDevice returned %#x\n", hr );
+ hr = IDirectInput8_CreateDevice( di, &devinst.guidInstance, &device, NULL );
+ ok( hr == DI_OK, "IDirectInput8_CreateDevice returned %#x\n", hr );
+
+ prop_dword.dwData = 0xdeadbeef;
+ hr = IDirectInputDevice8_GetProperty( device, DIPROP_VIDPID, &prop_dword.diph );
+ ok( hr == DI_OK, "IDirectInputDevice8_GetProperty DIPROP_VIDPID returned %#x\n", hr );
+ /* Wine may get the wrong device here, because the test driver creates another instance of
+ hidclass.sys, and gets duplicate rawinput handles, which we use in the guidInstance */
+ todo_wine_if( prop_dword.dwData != EXPECT_VIDPID )
+ ok( prop_dword.dwData == EXPECT_VIDPID, "got %#x expected %#x\n", prop_dword.dwData, EXPECT_VIDPID );
+
+ ref = IDirectInputDevice8_Release( device );
+ ok( ref == 0, "IDirectInputDeviceW_Release returned %d\n", ref );
+
hr = IDirectInput8_CreateDevice( di, &expect_guid_product, &device, NULL );
ok( hr == DI_OK, "IDirectInput8_CreateDevice returned %#x\n", hr );
--
2.33.0
More information about the wine-devel
mailing list