Signed-off-by: Andrew Eikum aeikum@codeweavers.com --- dlls/xinput1_3/hid.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/dlls/xinput1_3/hid.c b/dlls/xinput1_3/hid.c index 477d5304cac..5baf3b2b535 100644 --- a/dlls/xinput1_3/hid.c +++ b/dlls/xinput1_3/hid.c @@ -171,19 +171,34 @@ static BOOL VerifyGamepad(PHIDP_PREPARSED_DATA ppd, XINPUT_CAPABILITIES *xinput_ return TRUE; }
-static void build_private(struct hid_platform_private *private, PHIDP_PREPARSED_DATA ppd, HIDP_CAPS *caps, HANDLE device, WCHAR *path) +static BOOL init_controller(xinput_controller *controller, PHIDP_PREPARSED_DATA ppd, HIDP_CAPS *caps, HANDLE device, WCHAR *device_path) { size_t size; + struct hid_platform_private *private = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct hid_platform_private)); + + if (!VerifyGamepad(ppd, &controller->caps, private, caps)) + { + HeapFree(GetProcessHeap(), 0, private); + return FALSE; + } + + TRACE("Found gamepad %s\n", debugstr_w(device_path)); + private->ppd = ppd; private->device = device; private->report_length = caps->InputReportByteLength + 1; private->current_report = 0; private->reports[0] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, private->report_length); private->reports[1] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, private->report_length); - size = (lstrlenW(path) + 1) * sizeof(WCHAR); + size = (lstrlenW(device_path) + 1) * sizeof(WCHAR); private->device_path = HeapAlloc(GetProcessHeap(), 0, size); - memcpy(private->device_path, path, size); + memcpy(private->device_path, device_path, size); private->enabled = TRUE; + + controller->platform_private = private; + controller->connected = TRUE; + + return TRUE; }
void HID_find_gamepads(xinput_controller *devices) @@ -263,19 +278,10 @@ void HID_find_gamepads(xinput_controller *devices) Caps.Usage == HID_USAGE_GENERIC_JOYSTICK || Caps.Usage == 0x8 /* Multi-axis Controller */)) { - struct hid_platform_private *private = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct hid_platform_private)); - if (VerifyGamepad(ppd, &devices[open_device_idx].caps, private, &Caps)) - { - TRACE("Found gamepad %i %s\n", open_device_idx, debugstr_w(data->DevicePath)); - build_private(private, ppd, &Caps, device, data->DevicePath); - devices[open_device_idx].platform_private = private; - devices[open_device_idx].connected = TRUE; - } - else + if(!init_controller(&devices[open_device_idx], ppd, &Caps, device, data->DevicePath)) { CloseHandle(device); HidD_FreePreparsedData(ppd); - HeapFree(GetProcessHeap(), 0, private); } } else
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=58241
Your paranoid android.
=== debian10 (build log) ===
error: patch failed: dlls/xinput1_3/hid.c:47 error: patch failed: dlls/xinput1_3/xinput_main.c:34 error: patch failed: dlls/xinput1_3/xinput_private.h:19 error: patch failed: dlls/xinput1_3/hid.c:171 Task: Patch failed to apply
=== debian10 (build log) ===
error: patch failed: dlls/xinput1_3/hid.c:47 error: patch failed: dlls/xinput1_3/xinput_main.c:34 error: patch failed: dlls/xinput1_3/xinput_private.h:19 error: patch failed: dlls/xinput1_3/hid.c:171 Task: Patch failed to apply