hidapi/windows: fixed PS4 controllers over Bluetooth on Windows 7 by slouken · Pull Request #578 · libusb/hidapi

@slouken

Youw

static int hid_write_output_report(hid_device *dev, const unsigned char *data, size_t length)
{
BOOL res;
res = HidD_SetOutputReport(dev->device_handle, (void *)data, (ULONG)length);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please see #224
I'm confident we need to do the same thing for HidD_SetOutputReport as well.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slouken It seems, you missed to respond to this question

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like #224 was just pre-allocating the buffer. Were you referring to another change that made sure the buffer size matched feature_report_length? I think, but I'm not sure, that the feature_report_length is the wrong size in this case.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean that the buffer size has to be at least output_report_length bytes in size.
If user passes less data - logically it is not a proble, but WinAPI implementation is known to crash if bufer is too small.
The workaround (as in #224) is to pre-allocate buffer that is large-enough if needed.

@Youw

This looks similar to a problem described in #513.
@DJm00n what do you think?

@mcuee

DJm00n

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good

@slouken

Okay, I've updated the PR with your suggestions.

DJm00n

Youw

@slouken

Signed-off-by: Sam Lantinga <slouken@libsdl.org>

@mcuee

@mcuee

Now that Windows 7 has been out of support for a while, I am not so sure if we still care about Windows 7 or not, if this issue is only specific to Windows 7.

https://learn.microsoft.com/en-us/lifecycle/products/windows-7

Listing Start Date Mainstream End Date Extended End Date
Windows 7 Oct 22, 2009 Jan 13, 2015 Jan 14, 2020

@mcuee