[PATCH 0/5] MR10514: dinput/tests: Misc fixes and extra tests.
From: Connor McAdams <cmcadams@codeweavers.com> Signed-off-by: Connor McAdams <cmcadams@codeweavers.com> --- dlls/dinput/tests/joystick8.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dlls/dinput/tests/joystick8.c b/dlls/dinput/tests/joystick8.c index eab4a7ff7e8..d267aff724f 100644 --- a/dlls/dinput/tests/joystick8.c +++ b/dlls/dinput/tests/joystick8.c @@ -5319,6 +5319,7 @@ static void test_game_input(void) HMODULE gameinput = LoadLibraryW( L"gameinput.dll" ); HRESULT (WINAPI *pGameInputCreate)( v0_IGameInput **out ); v0_IGameInput *gi0; + HRESULT hr; if (!gameinput || !(pGameInputCreate = (void *)GetProcAddress( gameinput, "GameInputCreate" ))) { @@ -5327,8 +5328,9 @@ static void test_game_input(void) } gi0 = (void *)0xdeadbeef; - todo_wine ok_hr( S_OK, pGameInputCreate( &gi0 ) ); - if (gi0 != (void *)0xdeadbeef) ok_ret( 0, v0_IGameInput_Release( gi0 ) ); + hr = pGameInputCreate( &gi0 ); + todo_wine ok( hr == S_OK || broken(hr == E_NOTIMPL), "Unexpected hr %#lx.\n", hr ); + if (gi0 && gi0 != (void *)0xdeadbeef) ok_ret( 0, v0_IGameInput_Release( gi0 ) ); } static HANDLE rawinput_device_added, rawinput_device_removed, rawinput_event; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10514
From: Connor McAdams <cmcadams@codeweavers.com> Signed-off-by: Connor McAdams <cmcadams@codeweavers.com> --- dlls/dinput/tests/driver_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/dinput/tests/driver_bus.c b/dlls/dinput/tests/driver_bus.c index e8338e49711..788ac5cebd7 100644 --- a/dlls/dinput/tests/driver_bus.c +++ b/dlls/dinput/tests/driver_bus.c @@ -563,7 +563,7 @@ static NTSTATUS remove_child_device( struct func_device *impl, DEVICE_OBJECT *de for (i = 0; i < impl->devices->Count; ++i) if (impl->devices->Objects[i] == device) break; if (i == impl->devices->Count) status = STATUS_NOT_FOUND; - else impl->devices->Objects[i] = impl->devices->Objects[impl->devices->Count--]; + else impl->devices->Objects[i] = impl->devices->Objects[--impl->devices->Count]; KeReleaseSpinLock( &impl->base.lock, irql ); return status; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10514
From: Connor McAdams <cmcadams@codeweavers.com> Signed-off-by: Connor McAdams <cmcadams@codeweavers.com> --- include/ddk/hidport.h | 8 ++++++++ include/ddk/hidtypes.h | 3 --- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/ddk/hidport.h b/include/ddk/hidport.h index bd3ddb3f2a5..6574aba75bb 100644 --- a/include/ddk/hidport.h +++ b/include/ddk/hidport.h @@ -68,6 +68,14 @@ typedef struct _HID_DESCRIPTOR #define HID_HID_DESCRIPTOR_TYPE 0x21 #define HID_REPORT_DESCRIPTOR_TYPE 0x22 +/* + * String IDs used with IOCTL_HID_GET_STRING. + * These values match the string field offsets in chapter 9 of the USB spec. + */ +#define HID_STRING_ID_IMANUFACTURER 14 +#define HID_STRING_ID_IPRODUCT 15 +#define HID_STRING_ID_ISERIALNUMBER 16 + #define IOCTL_HID_GET_DEVICE_DESCRIPTOR HID_CTL_CODE(0) #define IOCTL_HID_GET_REPORT_DESCRIPTOR HID_CTL_CODE(1) #define IOCTL_HID_READ_REPORT HID_CTL_CODE(2) diff --git a/include/ddk/hidtypes.h b/include/ddk/hidtypes.h index dfd1061de18..8e6f76955e9 100644 --- a/include/ddk/hidtypes.h +++ b/include/ddk/hidtypes.h @@ -20,9 +20,6 @@ typedef enum _HID_STRING_TYPE { HID_STRING_INDEXED = 0, - HID_STRING_ID_IMANUFACTURER, - HID_STRING_ID_IPRODUCT, - HID_STRING_ID_ISERIALNUMBER, HID_STRING_MAX } HID_STRING_TYPE; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10514
From: Connor McAdams <cmcadams@codeweavers.com> Signed-off-by: Connor McAdams <cmcadams@codeweavers.com> --- dlls/dinput/tests/driver_bus.c | 48 +++++++++++++++++++++++++++++++--- dlls/dinput/tests/driver_hid.h | 3 +++ dlls/dinput/tests/hid.c | 21 ++++++++++++--- 3 files changed, 64 insertions(+), 8 deletions(-) diff --git a/dlls/dinput/tests/driver_bus.c b/dlls/dinput/tests/driver_bus.c index 788ac5cebd7..5bc6332a63c 100644 --- a/dlls/dinput/tests/driver_bus.c +++ b/dlls/dinput/tests/driver_bus.c @@ -505,6 +505,10 @@ struct phys_device struct device base; struct func_device *fdo; /* parent FDO */ + WCHAR vendor_str[64]; + WCHAR product_str[64]; + WCHAR serial_str[64]; + WCHAR instance_id[MAX_PATH]; WCHAR device_id[MAX_PATH]; IRP *pending_remove; @@ -903,11 +907,16 @@ static NTSTATUS create_child_pdo( DEVICE_OBJECT *device, struct hid_device_desc impl = pdo_from_DEVICE_OBJECT( child ); KeInitializeSpinLock( &impl->base.lock ); + + wcscpy( impl->vendor_str, *desc->vendor_str ? desc->vendor_str : L"WineTest" ); + wcscpy( impl->product_str, *desc->product_str ? desc->product_str : L"Wine Test" ); + wcscpy( impl->serial_str, *desc->serial_str ? desc->serial_str : L"0&0000&0" ); + swprintf( impl->device_id, MAX_PATH, L"WINETEST\\VID_%04X&PID_%04X", desc->attributes.VendorID, desc->attributes.ProductID ); /* use a different device ID so that driver cache select the polled driver */ if (desc->is_polled) wcscat( impl->device_id, L"&POLL" ); - swprintf( impl->instance_id, MAX_PATH, L"0&0000&0" ); + swprintf( impl->instance_id, MAX_PATH, L"%s", impl->serial_str ); impl->base.is_phys = TRUE; impl->fdo = fdo; @@ -1238,10 +1247,41 @@ static NTSTATUS pdo_internal_ioctl( DEVICE_OBJECT *device, IRP *irp ) } case IOCTL_HID_GET_STRING: - memcpy( irp->UserBuffer, L"Wine Test", sizeof(L"Wine Test") ); - irp->IoStatus.Information = sizeof(L"Wine Test"); - status = STATUS_SUCCESS; + { + UINT index = (UINT_PTR)stack->Parameters.DeviceIoControl.Type3InputBuffer & 0xffff; + UINT lcid = ((UINT_PTR)stack->Parameters.DeviceIoControl.Type3InputBuffer) >> 16; + + todo_wine ok( lcid, "Unexpected LCID %#x.\n", lcid ); + if (winetest_debug > 1) + trace( "%s: device %p, code %#lx %s, lcid %#x, idx %#x.\n", __func__, device, code, debugstr_ioctl(code), + lcid, index ); + switch (index) + { + case HID_STRING_ID_IMANUFACTURER: + irp->IoStatus.Information = (wcslen( impl->vendor_str ) + 1) * sizeof(WCHAR); + memcpy( irp->UserBuffer, impl->vendor_str, irp->IoStatus.Information ); + status = STATUS_SUCCESS; + break; + + case HID_STRING_ID_IPRODUCT: + irp->IoStatus.Information = (wcslen( impl->product_str ) + 1) * sizeof(WCHAR); + memcpy( irp->UserBuffer, impl->product_str, irp->IoStatus.Information ); + status = STATUS_SUCCESS; + break; + + case HID_STRING_ID_ISERIALNUMBER: + irp->IoStatus.Information = (wcslen(impl->serial_str) + 1) * sizeof(WCHAR); + memcpy( irp->UserBuffer, impl->serial_str, irp->IoStatus.Information ); + status = STATUS_SUCCESS; + break; + + default: + ok(0, "Unknown string type %#x.\n", index); + status = STATUS_NOT_IMPLEMENTED; + break; + } break; + } case IOCTL_GET_PHYSICAL_DESCRIPTOR: irp->IoStatus.Information = 0; diff --git a/dlls/dinput/tests/driver_hid.h b/dlls/dinput/tests/driver_hid.h index 8ba01d14b1e..1ae8fd90e43 100644 --- a/dlls/dinput/tests/driver_hid.h +++ b/dlls/dinput/tests/driver_hid.h @@ -85,6 +85,9 @@ struct hid_device_desc HIDP_CAPS caps; HID_DEVICE_ATTRIBUTES attributes; + WCHAR vendor_str[64]; + WCHAR product_str[64]; + WCHAR serial_str[64]; ULONG input_size; struct hid_expect input[64]; diff --git a/dlls/dinput/tests/hid.c b/dlls/dinput/tests/hid.c index c9cdb649f26..273e94e82bb 100644 --- a/dlls/dinput/tests/hid.c +++ b/dlls/dinput/tests/hid.c @@ -2713,10 +2713,10 @@ static void test_hidp( HANDLE file, HANDLE async_file, int report_id, BOOL polle HidD_FreePreparsedData( preparsed_data ); } -static void test_hid_device( DWORD report_id, DWORD polled, const HIDP_CAPS *expect_caps, WORD vid, WORD pid ) +static void test_hid_device( DWORD report_id, DWORD polled, const HIDP_CAPS *expect_caps, struct hid_device_desc *desc ) { + WCHAR device_path[MAX_PATH], buffer[1024]; ULONG count, poll_freq, out_len; - WCHAR device_path[MAX_PATH]; HANDLE file, async_file; DWORD ret; @@ -2730,7 +2730,7 @@ static void test_hid_device( DWORD report_id, DWORD polled, const HIDP_CAPS *exp ok( !ret, "WaitForSingleObject returned %#lx\n", ret ); } - swprintf( device_path, MAX_PATH, L"\\\\?\\hid#vid_%04x&pid_%04x", vid, pid ); + swprintf( device_path, MAX_PATH, L"\\\\?\\hid#vid_%04x&pid_%04x", desc->attributes.VendorID, desc->attributes.ProductID ); ret = find_hid_device_path( device_path ); ok( ret, "Failed to find HID device matching %s\n", debugstr_w( device_path ) ); @@ -2738,6 +2738,16 @@ static void test_hid_device( DWORD report_id, DWORD polled, const HIDP_CAPS *exp FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL ); ok( file != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError() ); + ret = HidD_GetManufacturerString( file, buffer, ARRAY_SIZE(buffer) ); + ok( ret, "HidD_GetManufacturerString failed last error %lu\n", GetLastError() ); + ok( !wcscmp( desc->vendor_str, buffer ), "HidD_GetManufacturerString returned %s\n", debugstr_w(buffer) ); + ret = HidD_GetProductString( file, buffer, ARRAY_SIZE(buffer) ); + ok( ret, "HidD_GetProductString failed last error %lu\n", GetLastError() ); + ok( !wcscmp( desc->product_str, buffer ), "HidD_GetProductString returned %s\n", debugstr_w(buffer) ); + ret = HidD_GetSerialNumberString( file, buffer, ARRAY_SIZE(buffer) ); + ok( ret, "HidD_GetSerialNumberString failed last error %lu\n", GetLastError() ); + ok( !wcscmp( desc->serial_str, buffer ), "HidD_GetSerialNumberString returned %s\n", debugstr_w(buffer) ); + count = 0xdeadbeef; SetLastError( 0xdeadbeef ); ret = HidD_GetNumInputBuffers( file, &count ); @@ -3150,6 +3160,9 @@ static void test_hid_driver( DWORD report_id, DWORD polled ) .use_report_id = report_id, .caps = caps, .attributes = default_attributes, + .vendor_str = L"Wine", + .product_str = L"Test Device", + .serial_str = L"0&1234&5", }; desc.report_descriptor_len = sizeof(report_desc); @@ -3158,7 +3171,7 @@ static void test_hid_driver( DWORD report_id, DWORD polled ) memcpy( desc.input, &expect_in, sizeof(expect_in) ); fill_context( desc.context, ARRAY_SIZE(desc.context) ); - if (hid_device_start( &desc, 1 )) test_hid_device( report_id, polled, &caps, desc.attributes.VendorID, desc.attributes.ProductID ); + if (hid_device_start( &desc, 1 )) test_hid_device( report_id, polled, &caps, &desc ); hid_device_stop( &desc, 1 ); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10514
From: Connor McAdams <cmcadams@codeweavers.com> Signed-off-by: Connor McAdams <cmcadams@codeweavers.com> --- dlls/dinput/tests/driver_bus.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dlls/dinput/tests/driver_bus.c b/dlls/dinput/tests/driver_bus.c index 5bc6332a63c..5a78df986f3 100644 --- a/dlls/dinput/tests/driver_bus.c +++ b/dlls/dinput/tests/driver_bus.c @@ -604,11 +604,12 @@ static DEVICE_OBJECT *find_child_device( struct func_device *impl, struct hid_de KeAcquireSpinLock( &impl->base.lock, &irql ); devices = impl->devices->Objects; - for (i = 0; i < impl->devices->Count; ++i) + for (i = 0; !device && i < impl->devices->Count; ++i) { - struct phys_device *phys = pdo_from_DEVICE_OBJECT( (device = devices[i]) ); - if (!wcscmp( phys->device_id, device_id )) break; - else device = NULL; + struct phys_device *phys = pdo_from_DEVICE_OBJECT( devices[i] ); + if (wcscmp( phys->device_id, device_id )) continue; + if (*desc->serial_str && wcscmp( phys->serial_str, desc->serial_str )) continue; + device = devices[i]; } KeReleaseSpinLock( &impl->base.lock, irql ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10514
This merge request was approved by Rémi Bernon. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10514
participants (2)
-
Connor McAdams -
Rémi Bernon (@rbernon)