Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 709953be8f0..1614f5e8583 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -652,11 +652,11 @@ static HRESULT WINAPI hid_joystick_GetObjectInfo( IDirectInputDevice8W *iface, D instance->dwSize != sizeof(DIDEVICEOBJECTINSTANCEW)) return DIERR_INVALIDPARAM;
- ret = enum_value_objects( impl, &filter, DIDFT_ALL, get_object_info, NULL ); + ret = enum_value_objects( impl, &filter, DIDFT_ALL, get_object_info, instance ); if (ret != DIENUM_CONTINUE) return S_OK; - ret = enum_button_objects( impl, &filter, DIDFT_ALL, get_object_info, NULL ); + ret = enum_button_objects( impl, &filter, DIDFT_ALL, get_object_info, instance ); if (ret != DIENUM_CONTINUE) return S_OK; - enum_collections_objects( impl, &filter, DIDFT_ALL, get_object_info, NULL ); + enum_collections_objects( impl, &filter, DIDFT_ALL, get_object_info, instance );
return S_OK; }
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput8/tests/hid.c | 91 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+)
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index f7b34b3dfc2..767ded8e890 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -3635,6 +3635,7 @@ static void test_simple_joystick(void) }; WCHAR cwd[MAX_PATH], tempdir[MAX_PATH]; DIDEVICEOBJECTDATA objdata[32] = {{0}}; + DIDEVICEOBJECTINSTANCEW objinst = {0}; DIDEVICEINSTANCEW devinst = {0}; DIDATAFORMAT dataformat = {0}; IDirectInputDevice8W *device; @@ -3929,6 +3930,74 @@ static void test_simple_joystick(void) ok( check_objects_params.index >= check_objects_params.expect_count, "missing %u objects\n", check_objects_params.expect_count - check_objects_params.index );
+ hr = IDirectInputDevice8_GetObjectInfo( device, NULL, 0, DIPH_DEVICE ); + ok( hr == E_POINTER, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr ); + hr = IDirectInputDevice8_GetObjectInfo( device, &objinst, 0, DIPH_DEVICE ); + ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr ); + objinst.dwSize = sizeof(DIDEVICEOBJECTINSTANCEW); + hr = IDirectInputDevice8_GetObjectInfo( device, &objinst, 0, DIPH_DEVICE ); + todo_wine + ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr ); + + res = MAKELONG( HID_USAGE_GENERIC_Z, HID_USAGE_PAGE_GENERIC ); + hr = IDirectInputDevice8_GetObjectInfo( device, &objinst, res, DIPH_BYUSAGE ); + todo_wine + ok( hr == DIERR_NOTFOUND, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr ); + res = MAKELONG( HID_USAGE_GENERIC_X, HID_USAGE_PAGE_GENERIC ); + hr = IDirectInputDevice8_GetObjectInfo( device, &objinst, res, DIPH_BYUSAGE ); + ok( hr == DI_OK, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr ); + + check_member( objinst, expect_objects[1], "%u", dwSize ); + todo_wine + check_member_guid( objinst, expect_objects[1], guidType ); + check_member( objinst, expect_objects[1], "%#x", dwOfs ); + check_member( objinst, expect_objects[1], "%#x", dwType ); + check_member( objinst, expect_objects[1], "%#x", dwFlags ); + if (!localized) todo_wine check_member_wstr( objinst, expect_objects[1], tszName ); + check_member( objinst, expect_objects[1], "%u", dwFFMaxForce ); + check_member( objinst, expect_objects[1], "%u", dwFFForceResolution ); + todo_wine + check_member( objinst, expect_objects[1], "%u", wCollectionNumber ); + check_member( objinst, expect_objects[1], "%u", wDesignatorIndex ); + check_member( objinst, expect_objects[1], "%#04x", wUsagePage ); + todo_wine + check_member( objinst, expect_objects[1], "%#04x", wUsage ); + check_member( objinst, expect_objects[1], "%#04x", dwDimension ); + check_member( objinst, expect_objects[1], "%#04x", wExponent ); + check_member( objinst, expect_objects[1], "%u", wReportId ); + + hr = IDirectInputDevice8_GetObjectInfo( device, &objinst, 0x14, DIPH_BYOFFSET ); + todo_wine + ok( hr == DIERR_NOTFOUND, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr ); + hr = IDirectInputDevice8_GetObjectInfo( device, &objinst, 0, DIPH_BYOFFSET ); + todo_wine + ok( hr == DIERR_NOTFOUND, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr ); + res = DIDFT_PSHBUTTON | DIDFT_MAKEINSTANCE( 3 ); + hr = IDirectInputDevice8_GetObjectInfo( device, &objinst, res, DIPH_BYID ); + todo_wine + ok( hr == DIERR_NOTFOUND, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr ); + res = DIDFT_PSHBUTTON | DIDFT_MAKEINSTANCE( 1 ); + hr = IDirectInputDevice8_GetObjectInfo( device, &objinst, res, DIPH_BYID ); + ok( hr == DI_OK, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr ); + + check_member( objinst, expect_objects[4], "%u", dwSize ); + check_member_guid( objinst, expect_objects[4], guidType ); + todo_wine + check_member( objinst, expect_objects[4], "%#x", dwOfs ); + check_member( objinst, expect_objects[4], "%#x", dwType ); + check_member( objinst, expect_objects[4], "%#x", dwFlags ); + if (!localized) todo_wine check_member_wstr( objinst, expect_objects[4], tszName ); + check_member( objinst, expect_objects[4], "%u", dwFFMaxForce ); + check_member( objinst, expect_objects[4], "%u", dwFFForceResolution ); + todo_wine + check_member( objinst, expect_objects[4], "%u", wCollectionNumber ); + check_member( objinst, expect_objects[4], "%u", wDesignatorIndex ); + check_member( objinst, expect_objects[4], "%#04x", wUsagePage ); + check_member( objinst, expect_objects[4], "%#04x", wUsage ); + check_member( objinst, expect_objects[4], "%#04x", dwDimension ); + check_member( objinst, expect_objects[4], "%#04x", wExponent ); + check_member( objinst, expect_objects[4], "%u", wReportId ); + hr = IDirectInputDevice8_SetDataFormat( device, NULL ); ok( hr == E_POINTER, "IDirectInputDevice8_SetDataFormat returned: %#x\n", hr ); hr = IDirectInputDevice8_SetDataFormat( device, &dataformat ); @@ -3943,6 +4012,28 @@ static void test_simple_joystick(void) hr = IDirectInputDevice8_SetDataFormat( device, &c_dfDIJoystick2 ); ok( hr == DI_OK, "IDirectInputDevice8_SetDataFormat returned: %#x\n", hr );
+ hr = IDirectInputDevice8_GetObjectInfo( device, &objinst, DIJOFS_Y, DIPH_BYOFFSET ); + ok( hr == DI_OK, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr ); + + check_member( objinst, expect_objects[0], "%u", dwSize ); + check_member_guid( objinst, expect_objects[0], guidType ); + todo_wine + check_member( objinst, expect_objects[0], "%#x", dwOfs ); + todo_wine + check_member( objinst, expect_objects[0], "%#x", dwType ); + check_member( objinst, expect_objects[0], "%#x", dwFlags ); + if (!localized) todo_wine check_member_wstr( objinst, expect_objects[0], tszName ); + check_member( objinst, expect_objects[0], "%u", dwFFMaxForce ); + check_member( objinst, expect_objects[0], "%u", dwFFForceResolution ); + todo_wine + check_member( objinst, expect_objects[0], "%u", wCollectionNumber ); + check_member( objinst, expect_objects[0], "%u", wDesignatorIndex ); + check_member( objinst, expect_objects[0], "%#04x", wUsagePage ); + check_member( objinst, expect_objects[0], "%#04x", wUsage ); + check_member( objinst, expect_objects[0], "%#04x", dwDimension ); + check_member( objinst, expect_objects[0], "%#04x", wExponent ); + check_member( objinst, expect_objects[0], "%u", wReportId ); + hr = IDirectInputDevice8_SetEventNotification( device, (HANDLE)0xdeadbeef ); todo_wine ok( hr == E_HANDLE, "IDirectInputDevice8_SetEventNotification returned: %#x\n", hr );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput8/tests/hid.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index 767ded8e890..893a933d6cf 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -3646,6 +3646,7 @@ static void test_simple_joystick(void) ULONG i, res, ref; HRESULT hr; WCHAR *tmp; + GUID guid; HWND hwnd;
GetCurrentDirectoryW( ARRAY_SIZE(cwd), cwd ); @@ -3706,6 +3707,31 @@ static void test_simple_joystick(void) hr = IDirectInput8_CreateDevice( di, &expect_guid_product, &device, NULL ); ok( hr == DI_OK, "IDirectInput8_CreateDevice returned %#x\n", hr );
+ hr = IDirectInputDevice8_Initialize( device, instance, 0x0700, &GUID_NULL ); + todo_wine + ok( hr == DIERR_BETADIRECTINPUTVERSION, "IDirectInputDevice8_Initialize returned %#x\n", hr ); + hr = IDirectInputDevice8_Initialize( device, instance, DIRECTINPUT_VERSION, NULL ); + todo_wine + ok( hr == E_POINTER, "IDirectInputDevice8_Initialize returned %#x\n", hr ); + hr = IDirectInputDevice8_Initialize( device, NULL, DIRECTINPUT_VERSION, &GUID_NULL ); + todo_wine + ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_Initialize returned %#x\n", hr ); + hr = IDirectInputDevice8_Initialize( device, instance, DIRECTINPUT_VERSION, &GUID_NULL ); + todo_wine + ok( hr == REGDB_E_CLASSNOTREG, "IDirectInputDevice8_Initialize returned %#x\n", hr ); + + hr = IDirectInputDevice8_Initialize( device, instance, DIRECTINPUT_VERSION, &devinst.guidInstance ); + ok( hr == DI_OK, "IDirectInputDevice8_Initialize returned %#x\n", hr ); + guid = devinst.guidInstance; + memset( &devinst, 0, sizeof(devinst) ); + devinst.dwSize = sizeof(DIDEVICEINSTANCEW); + hr = IDirectInputDevice8_GetDeviceInfo( device, &devinst ); + ok( hr == DI_OK, "IDirectInputDevice8_GetDeviceInfo returned %#x\n", hr ); + ok( IsEqualGUID( &guid, &devinst.guidInstance ), "got %s expected %s\n", debugstr_guid( &guid ), + debugstr_guid( &devinst.guidInstance ) ); + hr = IDirectInputDevice8_Initialize( device, instance, DIRECTINPUT_VERSION, &devinst.guidProduct ); + ok( hr == DI_OK, "IDirectInputDevice8_Initialize returned %#x\n", hr ); + hr = IDirectInputDevice8_GetDeviceInfo( device, NULL ); ok( hr == E_POINTER, "IDirectInputDevice8_GetDeviceInfo returned %#x\n", hr ); devinst.dwSize = sizeof(DIDEVICEINSTANCEW) + 1;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=98317
Your paranoid android.
=== debiant2 (32 bit Hebrew:Israel report) ===
dinput8: hid.c:4222: Test succeeded inside todo block: got dwSequence 0xa, expected 0xa hid.c:4234: Test succeeded inside todo block: objdata[0]: got dwSequence 0xa, expected 0xa hid.c:4234: Test succeeded inside todo block: objdata[1]: got dwSequence 0xa, expected 0xa hid.c:4234: Test succeeded inside todo block: objdata[2]: got dwSequence 0xa, expected 0xa hid.c:4234: Test succeeded inside todo block: objdata[3]: got dwSequence 0xa, expected 0xa
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput8/tests/hid.c | 337 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 337 insertions(+)
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index 893a933d6cf..3f7bc4bfb82 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -4669,6 +4669,342 @@ done: SetCurrentDirectoryW( cwd ); }
+struct device_desc +{ + const BYTE *report_desc_buf; + ULONG report_desc_len; + HIDP_CAPS hid_caps; +}; + +static void test_device_types( void ) +{ +#include "psh_hid_macros.h" + static const unsigned char unknown_desc[] = + { + USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), + USAGE(1, HID_USAGE_GENERIC_JOYSTICK), + COLLECTION(1, Application), + USAGE(1, HID_USAGE_GENERIC_JOYSTICK), + COLLECTION(1, Physical), + USAGE_PAGE(1, HID_USAGE_PAGE_BUTTON), + USAGE_MINIMUM(1, 1), + USAGE_MAXIMUM(1, 6), + LOGICAL_MINIMUM(1, 0), + LOGICAL_MAXIMUM(1, 1), + PHYSICAL_MINIMUM(1, 0), + PHYSICAL_MAXIMUM(1, 1), + REPORT_SIZE(1, 1), + REPORT_COUNT(1, 8), + INPUT(1, Data|Var|Abs), + END_COLLECTION, + END_COLLECTION, + }; + static const unsigned char limited_desc[] = + { + USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), + USAGE(1, HID_USAGE_GENERIC_JOYSTICK), + COLLECTION(1, Application), + USAGE(1, HID_USAGE_GENERIC_JOYSTICK), + COLLECTION(1, Physical), + USAGE(1, HID_USAGE_GENERIC_X), + USAGE(1, HID_USAGE_GENERIC_Y), + LOGICAL_MINIMUM(1, 0), + LOGICAL_MAXIMUM(1, 127), + PHYSICAL_MINIMUM(1, 0), + PHYSICAL_MAXIMUM(1, 127), + REPORT_SIZE(1, 8), + REPORT_COUNT(1, 2), + INPUT(1, Data|Var|Abs), + + USAGE_PAGE(1, HID_USAGE_PAGE_BUTTON), + USAGE_MINIMUM(1, 1), + USAGE_MAXIMUM(1, 6), + LOGICAL_MINIMUM(1, 0), + LOGICAL_MAXIMUM(1, 1), + PHYSICAL_MINIMUM(1, 0), + PHYSICAL_MAXIMUM(1, 1), + REPORT_SIZE(1, 1), + REPORT_COUNT(1, 8), + INPUT(1, Data|Var|Abs), + END_COLLECTION, + END_COLLECTION, + }; + static const unsigned char gamepad_desc[] = + { + USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), + USAGE(1, HID_USAGE_GENERIC_GAMEPAD), + COLLECTION(1, Application), + USAGE(1, HID_USAGE_GENERIC_GAMEPAD), + COLLECTION(1, Physical), + USAGE(1, HID_USAGE_GENERIC_X), + USAGE(1, HID_USAGE_GENERIC_Y), + LOGICAL_MINIMUM(1, 0), + LOGICAL_MAXIMUM(1, 127), + PHYSICAL_MINIMUM(1, 0), + PHYSICAL_MAXIMUM(1, 127), + REPORT_SIZE(1, 8), + REPORT_COUNT(1, 2), + INPUT(1, Data|Var|Abs), + + USAGE_PAGE(1, HID_USAGE_PAGE_BUTTON), + USAGE_MINIMUM(1, 1), + USAGE_MAXIMUM(1, 6), + LOGICAL_MINIMUM(1, 0), + LOGICAL_MAXIMUM(1, 1), + PHYSICAL_MINIMUM(1, 0), + PHYSICAL_MAXIMUM(1, 1), + REPORT_SIZE(1, 1), + REPORT_COUNT(1, 8), + INPUT(1, Data|Var|Abs), + END_COLLECTION, + END_COLLECTION, + }; + static const unsigned char joystick_desc[] = + { + USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), + USAGE(1, HID_USAGE_GENERIC_JOYSTICK), + COLLECTION(1, Application), + USAGE(1, HID_USAGE_GENERIC_JOYSTICK), + COLLECTION(1, Physical), + USAGE(1, HID_USAGE_GENERIC_X), + USAGE(1, HID_USAGE_GENERIC_Y), + USAGE(1, HID_USAGE_GENERIC_Z), + LOGICAL_MINIMUM(1, 0), + LOGICAL_MAXIMUM(1, 127), + PHYSICAL_MINIMUM(1, 0), + PHYSICAL_MAXIMUM(1, 127), + REPORT_SIZE(1, 8), + REPORT_COUNT(1, 3), + INPUT(1, Data|Var|Abs), + + USAGE(1, HID_USAGE_GENERIC_HATSWITCH), + LOGICAL_MINIMUM(1, 1), + LOGICAL_MAXIMUM(1, 8), + PHYSICAL_MINIMUM(1, 0), + PHYSICAL_MAXIMUM(1, 8), + REPORT_SIZE(1, 8), + REPORT_COUNT(1, 1), + INPUT(1, Data|Var|Abs|Null), + + USAGE_PAGE(1, HID_USAGE_PAGE_BUTTON), + USAGE_MINIMUM(1, 1), + USAGE_MAXIMUM(1, 5), + LOGICAL_MINIMUM(1, 0), + LOGICAL_MAXIMUM(1, 1), + PHYSICAL_MINIMUM(1, 0), + PHYSICAL_MAXIMUM(1, 1), + REPORT_SIZE(1, 1), + REPORT_COUNT(1, 8), + INPUT(1, Data|Var|Abs), + END_COLLECTION, + END_COLLECTION, + }; +#include "pop_hid_macros.h" + + static struct device_desc device_desc[] = + { + { + .report_desc_buf = unknown_desc, + .report_desc_len = sizeof(unknown_desc), + .hid_caps = + { + .InputReportByteLength = 1, + }, + }, + { + .report_desc_buf = limited_desc, + .report_desc_len = sizeof(limited_desc), + .hid_caps = + { + .InputReportByteLength = 3, + }, + }, + { + .report_desc_buf = gamepad_desc, + .report_desc_len = sizeof(gamepad_desc), + .hid_caps = + { + .InputReportByteLength = 3, + }, + }, + { + .report_desc_buf = joystick_desc, + .report_desc_len = sizeof(joystick_desc), + .hid_caps = + { + .InputReportByteLength = 5, + }, + }, + }; + static const DIDEVCAPS expect_caps[] = + { + { + .dwSize = sizeof(DIDEVCAPS), + .dwFlags = DIDC_ATTACHED|DIDC_EMULATED, + .dwDevType = DIDEVTYPE_HID|(DI8DEVTYPESUPPLEMENTAL_UNKNOWN << 8)|DI8DEVTYPE_SUPPLEMENTAL, + .dwButtons = 6, + }, + { + .dwSize = sizeof(DIDEVCAPS), + .dwFlags = DIDC_ATTACHED|DIDC_EMULATED, + .dwDevType = DIDEVTYPE_HID|(DI8DEVTYPEJOYSTICK_LIMITED << 8)|DI8DEVTYPE_JOYSTICK, + .dwAxes = 2, + .dwButtons = 6, + }, + { + .dwSize = sizeof(DIDEVCAPS), + .dwFlags = DIDC_ATTACHED|DIDC_EMULATED, + .dwDevType = DIDEVTYPE_HID|(DI8DEVTYPEGAMEPAD_STANDARD << 8)|DI8DEVTYPE_GAMEPAD, + .dwAxes = 2, + .dwButtons = 6, + }, + { + .dwSize = sizeof(DIDEVCAPS), + .dwFlags = DIDC_ATTACHED|DIDC_EMULATED, + .dwDevType = DIDEVTYPE_HID|(DI8DEVTYPEJOYSTICK_STANDARD << 8)|DI8DEVTYPE_JOYSTICK, + .dwAxes = 3, + .dwPOVs = 1, + .dwButtons = 5, + }, + }; + + const DIDEVICEINSTANCEW expect_devinst[] = + { + { + .dwSize = sizeof(DIDEVICEINSTANCEW), + .guidInstance = expect_guid_product, + .guidProduct = expect_guid_product, + .dwDevType = DIDEVTYPE_HID|(DI8DEVTYPESUPPLEMENTAL_UNKNOWN << 8)|DI8DEVTYPE_SUPPLEMENTAL, + .tszInstanceName = L"Wine test root driver", + .tszProductName = L"Wine test root driver", + .guidFFDriver = GUID_NULL, + .wUsagePage = HID_USAGE_PAGE_GENERIC, + .wUsage = HID_USAGE_GENERIC_JOYSTICK, + }, + { + .dwSize = sizeof(DIDEVICEINSTANCEW), + .guidInstance = expect_guid_product, + .guidProduct = expect_guid_product, + .dwDevType = DIDEVTYPE_HID|(DI8DEVTYPEJOYSTICK_LIMITED << 8)|DI8DEVTYPE_JOYSTICK, + .tszInstanceName = L"Wine test root driver", + .tszProductName = L"Wine test root driver", + .guidFFDriver = GUID_NULL, + .wUsagePage = HID_USAGE_PAGE_GENERIC, + .wUsage = HID_USAGE_GENERIC_JOYSTICK, + }, + { + .dwSize = sizeof(DIDEVICEINSTANCEW), + .guidInstance = expect_guid_product, + .guidProduct = expect_guid_product, + .dwDevType = DIDEVTYPE_HID|(DI8DEVTYPEGAMEPAD_STANDARD << 8)|DI8DEVTYPE_GAMEPAD, + .tszInstanceName = L"Wine test root driver", + .tszProductName = L"Wine test root driver", + .guidFFDriver = GUID_NULL, + .wUsagePage = HID_USAGE_PAGE_GENERIC, + .wUsage = HID_USAGE_GENERIC_GAMEPAD, + }, + { + .dwSize = sizeof(DIDEVICEINSTANCEW), + .guidInstance = expect_guid_product, + .guidProduct = expect_guid_product, + .dwDevType = DIDEVTYPE_HID|(DI8DEVTYPEJOYSTICK_STANDARD << 8)|DI8DEVTYPE_JOYSTICK, + .tszInstanceName = L"Wine test root driver", + .tszProductName = L"Wine test root driver", + .guidFFDriver = GUID_NULL, + .wUsagePage = HID_USAGE_PAGE_GENERIC, + .wUsage = HID_USAGE_GENERIC_JOYSTICK, + }, + }; + + DIDEVICEINSTANCEW devinst = {.dwSize = sizeof(DIDEVICEINSTANCEW)}; + DIDEVCAPS caps = {.dwSize = sizeof(DIDEVCAPS)}; + WCHAR cwd[MAX_PATH], tempdir[MAX_PATH]; + IDirectInputDevice8W *device; + IDirectInput8W *di; + ULONG i, ref; + HRESULT hr; + + for (i = 0; i < ARRAY_SIZE(device_desc); ++i) + { + winetest_push_context( "desc[%d]", i ); + GetCurrentDirectoryW( ARRAY_SIZE(cwd), cwd ); + GetTempPathW( ARRAY_SIZE(tempdir), tempdir ); + SetCurrentDirectoryW( tempdir ); + + cleanup_registry_keys(); + if (!dinput_driver_start( device_desc[i].report_desc_buf, device_desc[i].report_desc_len, + &device_desc[i].hid_caps )) + { + i = ARRAY_SIZE(device_desc); + goto done; + } + + hr = DirectInput8Create( instance, DIRECTINPUT_VERSION, &IID_IDirectInput8W, (void **)&di, NULL ); + if (FAILED(hr)) + { + win_skip( "DirectInput8Create returned %#x\n", hr ); + i = ARRAY_SIZE(device_desc); + goto done; + } + + hr = IDirectInput8_EnumDevices( di, DI8DEVCLASS_ALL, find_test_device, &devinst, DIEDFL_ALLDEVICES ); + ok( hr == DI_OK, "IDirectInput8_EnumDevices returned: %#x\n", hr ); + if (!IsEqualGUID( &devinst.guidProduct, &expect_guid_product )) + { + win_skip( "device not found, skipping tests\n" ); + IDirectInput8_Release( di ); + i = ARRAY_SIZE(device_desc); + goto done; + } + + hr = IDirectInput8_CreateDevice( di, &expect_guid_product, &device, NULL ); + ok( hr == DI_OK, "IDirectInput8_CreateDevice returned %#x\n", hr ); + + hr = IDirectInputDevice8_GetDeviceInfo( device, &devinst ); + ok( hr == DI_OK, "IDirectInputDevice8_GetDeviceInfo returned %#x\n", hr ); + check_member( devinst, expect_devinst[i], "%d", dwSize ); + todo_wine + check_member_guid( devinst, expect_devinst[i], guidInstance ); + check_member_guid( devinst, expect_devinst[i], guidProduct ); + todo_wine_if( i < 2 ) + check_member( devinst, expect_devinst[i], "%#x", dwDevType ); + todo_wine + check_member_wstr( devinst, expect_devinst[i], tszInstanceName ); + todo_wine + check_member_wstr( devinst, expect_devinst[i], tszProductName ); + check_member_guid( devinst, expect_devinst[i], guidFFDriver ); + check_member( devinst, expect_devinst[i], "%04x", wUsagePage ); + check_member( devinst, expect_devinst[i], "%04x", wUsage ); + + hr = IDirectInputDevice8_GetCapabilities( device, &caps ); + ok( hr == DI_OK, "IDirectInputDevice8_GetCapabilities returned %#x\n", hr ); + check_member( caps, expect_caps[i], "%d", dwSize ); + check_member( caps, expect_caps[i], "%#x", dwFlags ); + todo_wine_if( i < 2 ) + check_member( caps, expect_caps[i], "%#x", dwDevType ); + check_member( caps, expect_caps[i], "%d", dwAxes ); + check_member( caps, expect_caps[i], "%d", dwButtons ); + check_member( caps, expect_caps[i], "%d", dwPOVs ); + check_member( caps, expect_caps[i], "%d", dwFFSamplePeriod ); + check_member( caps, expect_caps[i], "%d", dwFFMinTimeResolution ); + check_member( caps, expect_caps[i], "%d", dwFirmwareRevision ); + check_member( caps, expect_caps[i], "%d", dwHardwareRevision ); + check_member( caps, expect_caps[i], "%d", dwFFDriverVersion ); + + ref = IDirectInputDevice8_Release( device ); + ok( ref == 0, "IDirectInputDeviceW_Release returned %d\n", ref ); + + ref = IDirectInput8_Release( di ); + ok( ref == 0, "IDirectInput8_Release returned %d\n", ref ); + + done: + pnp_driver_stop(); + cleanup_registry_keys(); + SetCurrentDirectoryW( cwd ); + winetest_pop_context(); + } +} + START_TEST( hid ) { HANDLE mapping; @@ -4709,6 +5045,7 @@ START_TEST( hid ) test_hid_driver( 1, TRUE );
CoInitialize( NULL ); + test_device_types(); test_simple_joystick(); CoUninitialize();
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=98318
Your paranoid android.
=== debiant2 (32 bit report) ===
dinput8: hid.c:4222: Test succeeded inside todo block: got dwSequence 0xa, expected 0xa hid.c:4234: Test succeeded inside todo block: objdata[0]: got dwSequence 0xa, expected 0xa hid.c:4234: Test succeeded inside todo block: objdata[1]: got dwSequence 0xa, expected 0xa hid.c:4234: Test succeeded inside todo block: objdata[2]: got dwSequence 0xa, expected 0xa hid.c:4234: Test succeeded inside todo block: objdata[3]: got dwSequence 0xa, expected 0xa
=== debiant2 (64 bit WoW report) ===
dinput8: hid.c:4222: Test succeeded inside todo block: got dwSequence 0xa, expected 0xa hid.c:4234: Test succeeded inside todo block: objdata[0]: got dwSequence 0xa, expected 0xa hid.c:4234: Test succeeded inside todo block: objdata[1]: got dwSequence 0xa, expected 0xa hid.c:4234: Test succeeded inside todo block: objdata[2]: got dwSequence 0xa, expected 0xa hid.c:4234: Test succeeded inside todo block: objdata[3]: got dwSequence 0xa, expected 0xa
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 91 +++++++++++++++++++++++++++++++++++++- dlls/dinput8/tests/hid.c | 6 --- 2 files changed, 90 insertions(+), 7 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 1614f5e8583..a9ca6fe6cc6 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -919,12 +919,52 @@ static HRESULT hid_joystick_read_state( IDirectInputDevice8W *iface ) return DI_OK; }
+static DWORD device_type_for_version( DWORD type, DWORD version ) +{ + if (version >= 0x0800) return type; + + switch (GET_DIDEVICE_TYPE( type )) + { + case DI8DEVTYPE_JOYSTICK: + if (GET_DIDEVICE_SUBTYPE( type ) == DI8DEVTYPEJOYSTICK_LIMITED) + return DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_UNKNOWN << 8) | DIDEVTYPE_HID; + return DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8) | DIDEVTYPE_HID; + + case DI8DEVTYPE_GAMEPAD: + return DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_GAMEPAD << 8) | DIDEVTYPE_HID; + + case DI8DEVTYPE_DRIVING: + return DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_WHEEL << 8) | DIDEVTYPE_HID; + + case DI8DEVTYPE_FLIGHT: + return DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_FLIGHTSTICK << 8) | DIDEVTYPE_HID; + + case DI8DEVTYPE_SUPPLEMENTAL: + if (GET_DIDEVICE_SUBTYPE( type ) == DI8DEVTYPESUPPLEMENTAL_HEADTRACKER) + return DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_HEADTRACKER << 8) | DIDEVTYPE_HID; + if (GET_DIDEVICE_SUBTYPE( type ) == DI8DEVTYPESUPPLEMENTAL_RUDDERPEDALS) + return DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_RUDDER << 8) | DIDEVTYPE_HID; + return DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_UNKNOWN << 8) | DIDEVTYPE_HID; + + case DI8DEVTYPE_1STPERSON: + return DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_UNKNOWN << 8) | DIDEVTYPE_HID; + + default: + return DIDEVTYPE_DEVICE | DIDEVTYPE_HID; + } +} + static BOOL hid_joystick_device_try_open( UINT32 handle, const WCHAR *path, HANDLE *device, PHIDP_PREPARSED_DATA *preparsed, HIDD_ATTRIBUTES *attrs, HIDP_CAPS *caps, DIDEVICEINSTANCEW *instance, DWORD version ) { PHIDP_PREPARSED_DATA preparsed_data = NULL; + DWORD type = 0, button_count = 0; + HIDP_BUTTON_CAPS buttons[10]; + HIDP_VALUE_CAPS value; HANDLE device_file; + NTSTATUS status; + USHORT count;
device_file = CreateFileW( path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, 0 ); @@ -946,11 +986,60 @@ static BOOL hid_joystick_device_try_open( UINT32 handle, const WCHAR *path, HAND instance->guidInstance.Data1 ^= handle; instance->guidProduct = DInput_PIDVID_Product_GUID; instance->guidProduct.Data1 = MAKELONG( attrs->VendorID, attrs->ProductID ); - instance->dwDevType = get_device_type( version, caps->Usage != HID_USAGE_GENERIC_GAMEPAD ) | DIDEVTYPE_HID; instance->guidFFDriver = GUID_NULL; instance->wUsagePage = caps->UsagePage; instance->wUsage = caps->Usage;
+ count = ARRAY_SIZE(buttons); + status = HidP_GetSpecificButtonCaps( HidP_Input, HID_USAGE_PAGE_BUTTON, 0, 0, buttons, &count, preparsed_data ); + if (status != HIDP_STATUS_SUCCESS) count = button_count = 0; + while (count--) + { + if (!buttons[count].IsRange) button_count += 1; + else button_count += buttons[count].Range.UsageMax - buttons[count].Range.UsageMin + 1; + } + + switch (caps->Usage) + { + case HID_USAGE_GENERIC_GAMEPAD: + type = DI8DEVTYPE_GAMEPAD | DIDEVTYPE_HID; + if (button_count < 6) type |= DI8DEVTYPEGAMEPAD_LIMITED << 8; + else type |= DI8DEVTYPEGAMEPAD_STANDARD << 8; + break; + case HID_USAGE_GENERIC_JOYSTICK: + type = DI8DEVTYPE_JOYSTICK | DIDEVTYPE_HID; + if (button_count < 5) type |= DI8DEVTYPEJOYSTICK_LIMITED << 8; + else type |= DI8DEVTYPEJOYSTICK_STANDARD << 8; + + count = 1; + status = HidP_GetSpecificValueCaps( HidP_Input, HID_USAGE_PAGE_GENERIC, 0, + HID_USAGE_GENERIC_Z, &value, &count, preparsed_data ); + if (status != HIDP_STATUS_SUCCESS || !count) + type = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_LIMITED << 8) | DIDEVTYPE_HID; + + count = 1; + status = HidP_GetSpecificValueCaps( HidP_Input, HID_USAGE_PAGE_GENERIC, 0, + HID_USAGE_GENERIC_HATSWITCH, &value, &count, preparsed_data ); + if (status != HIDP_STATUS_SUCCESS || !count) + type = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_LIMITED << 8) | DIDEVTYPE_HID; + + break; + } + + count = 1; + status = HidP_GetSpecificValueCaps( HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_X, + &value, &count, preparsed_data ); + if (status != HIDP_STATUS_SUCCESS || !count) + type = DI8DEVTYPE_SUPPLEMENTAL | (DI8DEVTYPESUPPLEMENTAL_UNKNOWN << 8) | DIDEVTYPE_HID; + + count = 1; + status = HidP_GetSpecificValueCaps( HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_Y, + &value, &count, preparsed_data ); + if (status != HIDP_STATUS_SUCCESS || !count) + type = DI8DEVTYPE_SUPPLEMENTAL | (DI8DEVTYPESUPPLEMENTAL_UNKNOWN << 8) | DIDEVTYPE_HID; + + instance->dwDevType = device_type_for_version( type, version ); + *device = device_file; *preparsed = preparsed_data; return TRUE; diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index 3f7bc4bfb82..4be7787268b 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -3674,7 +3674,6 @@ static void test_simple_joystick(void)
check_member( devinst, expect_devinst, "%d", dwSize ); check_member_guid( devinst, expect_devinst, guidProduct ); - todo_wine check_member( devinst, expect_devinst, "%#x", dwDevType ); todo_wine check_member_wstr( devinst, expect_devinst, tszInstanceName ); @@ -3744,7 +3743,6 @@ static void test_simple_joystick(void) todo_wine check_member_guid( devinst, expect_devinst, guidInstance ); check_member_guid( devinst, expect_devinst, guidProduct ); - todo_wine check_member( devinst, expect_devinst, "%#x", dwDevType ); todo_wine check_member_wstr( devinst, expect_devinst, tszInstanceName ); @@ -3759,7 +3757,6 @@ static void test_simple_joystick(void) todo_wine check_member_guid( devinst, expect_devinst, guidInstance ); check_member_guid( devinst, expect_devinst, guidProduct ); - todo_wine check_member( devinst, expect_devinst, "%#x", dwDevType ); todo_wine check_member_wstr( devinst, expect_devinst, tszInstanceName ); @@ -3779,7 +3776,6 @@ static void test_simple_joystick(void) ok( hr == DI_OK, "IDirectInputDevice8_GetCapabilities returned %#x\n", hr ); check_member( caps, expect_caps, "%d", dwSize ); check_member( caps, expect_caps, "%#x", dwFlags ); - todo_wine check_member( caps, expect_caps, "%#x", dwDevType ); check_member( caps, expect_caps, "%d", dwAxes ); check_member( caps, expect_caps, "%d", dwButtons ); @@ -4966,7 +4962,6 @@ static void test_device_types( void ) todo_wine check_member_guid( devinst, expect_devinst[i], guidInstance ); check_member_guid( devinst, expect_devinst[i], guidProduct ); - todo_wine_if( i < 2 ) check_member( devinst, expect_devinst[i], "%#x", dwDevType ); todo_wine check_member_wstr( devinst, expect_devinst[i], tszInstanceName ); @@ -4980,7 +4975,6 @@ static void test_device_types( void ) ok( hr == DI_OK, "IDirectInputDevice8_GetCapabilities returned %#x\n", hr ); check_member( caps, expect_caps[i], "%d", dwSize ); check_member( caps, expect_caps[i], "%#x", dwFlags ); - todo_wine_if( i < 2 ) check_member( caps, expect_caps[i], "%#x", dwDevType ); check_member( caps, expect_caps[i], "%d", dwAxes ); check_member( caps, expect_caps[i], "%d", dwButtons );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=98319
Your paranoid android.
=== debiant2 (64 bit WoW report) ===
dinput8: hid.c:4218: Test succeeded inside todo block: got dwSequence 0xa, expected 0xa hid.c:4230: Test succeeded inside todo block: objdata[0]: got dwSequence 0xa, expected 0xa hid.c:4230: Test succeeded inside todo block: objdata[1]: got dwSequence 0xa, expected 0xa hid.c:4230: Test succeeded inside todo block: objdata[2]: got dwSequence 0xa, expected 0xa hid.c:4230: Test succeeded inside todo block: objdata[3]: got dwSequence 0xa, expected 0xa
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=98315
Your paranoid android.
=== debiant2 (32 bit report) ===
dinput8: hid.c:4105: Test succeeded inside todo block: got dwSequence 0xa, expected 0xa hid.c:4117: Test succeeded inside todo block: objdata[0]: got dwSequence 0xa, expected 0xa hid.c:4117: Test succeeded inside todo block: objdata[1]: got dwSequence 0xa, expected 0xa hid.c:4117: Test succeeded inside todo block: objdata[2]: got dwSequence 0xa, expected 0xa hid.c:4117: Test succeeded inside todo block: objdata[3]: got dwSequence 0xa, expected 0xa
=== debiant2 (64 bit WoW report) ===
dinput8: hid.c:4105: Test succeeded inside todo block: got dwSequence 0xa, expected 0xa hid.c:4117: Test succeeded inside todo block: objdata[0]: got dwSequence 0xa, expected 0xa hid.c:4117: Test succeeded inside todo block: objdata[1]: got dwSequence 0xa, expected 0xa hid.c:4117: Test succeeded inside todo block: objdata[2]: got dwSequence 0xa, expected 0xa hid.c:4117: Test succeeded inside todo block: objdata[3]: got dwSequence 0xa, expected 0xa
On 9/20/21 11:03 AM, Marvin wrote:
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=98315
Your paranoid android.
=== debiant2 (32 bit report) ===
dinput8: hid.c:4105: Test succeeded inside todo block: got dwSequence 0xa, expected 0xa hid.c:4117: Test succeeded inside todo block: objdata[0]: got dwSequence 0xa, expected 0xa hid.c:4117: Test succeeded inside todo block: objdata[1]: got dwSequence 0xa, expected 0xa hid.c:4117: Test succeeded inside todo block: objdata[2]: got dwSequence 0xa, expected 0xa hid.c:4117: Test succeeded inside todo block: objdata[3]: got dwSequence 0xa, expected 0xa
=== debiant2 (64 bit WoW report) ===
dinput8: hid.c:4105: Test succeeded inside todo block: got dwSequence 0xa, expected 0xa hid.c:4117: Test succeeded inside todo block: objdata[0]: got dwSequence 0xa, expected 0xa hid.c:4117: Test succeeded inside todo block: objdata[1]: got dwSequence 0xa, expected 0xa hid.c:4117: Test succeeded inside todo block: objdata[2]: got dwSequence 0xa, expected 0xa hid.c:4117: Test succeeded inside todo block: objdata[3]: got dwSequence 0xa, expected 0xa
I should probably just remove these sequence number tests, it's not very useful and it fails from time to time. It's not related to these patches though.