mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-02-02 16:01:15 +00:00
Fixed double-copy of the report in BlueZ >= 5.56
This commit is contained in:
parent
7ed7644a26
commit
7d66fa209a
|
@ -843,20 +843,24 @@ int HID_API_EXPORT hid_send_feature_report(hid_device *dev, const unsigned char
|
||||||
int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length)
|
int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
unsigned char report = data[0];
|
||||||
|
|
||||||
/* It looks like HIDIOCGFEATURE() on Bluetooth LE devices doesn't return the report number */
|
res = ioctl(dev->device_handle, HIDIOCGFEATURE(length), data);
|
||||||
if (dev->needs_ble_hack) {
|
if (res < 0)
|
||||||
data[1] = data[0];
|
perror("ioctl (GFEATURE)");
|
||||||
++data;
|
else if (dev->needs_ble_hack) {
|
||||||
--length;
|
/* Versions of BlueZ before 5.56 don't include the report in the data, and versions of BlueZ >= 5.56 include 2 copies of the report.
|
||||||
}
|
* We'll fix it so that there is a single copy of the report in both cases
|
||||||
res = ioctl(dev->device_handle, HIDIOCGFEATURE(length), data);
|
*/
|
||||||
if (res < 0)
|
if (data[0] == report && data[1] == report) {
|
||||||
perror("ioctl (GFEATURE)");
|
memmove(&data[0], &data[1], res);
|
||||||
else if (dev->needs_ble_hack)
|
} else if (data[0] != report) {
|
||||||
++res;
|
memmove(&data[1], &data[0], res);
|
||||||
|
data[0] = report;
|
||||||
return res;
|
++res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue