USB: check that HidD_GetPreparsedData succeeded

This commit is contained in:
jackun 2020-11-24 17:33:49 +02:00
parent 5927cef89f
commit 52d88a7282
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3
1 changed files with 9 additions and 2 deletions

View File

@ -301,14 +301,21 @@ namespace usb_pad
if (usbHandle == INVALID_HANDLE_VALUE) if (usbHandle == INVALID_HANDLE_VALUE)
{ {
Console.Warning("Could not open device %i\n", i); Console.Warning("Could not open device %i", i);
free(didData); free(didData);
i++; i++;
continue; continue;
} }
HidD_GetAttributes(usbHandle, &attr); HidD_GetAttributes(usbHandle, &attr);
HidD_GetPreparsedData(usbHandle, &pPreparsedData); if (!HidD_GetPreparsedData(usbHandle, &pPreparsedData))
{
Console.Warning("Could not get preparsed data from %04x:%04x", attr.VendorID, attr.ProductID);
free(didData);
i++;
continue;
}
HidP_GetCaps(pPreparsedData, &caps); HidP_GetCaps(pPreparsedData, &caps);
if (caps.UsagePage == HID_USAGE_PAGE_GENERIC && if (caps.UsagePage == HID_USAGE_PAGE_GENERIC &&