mirror of https://github.com/encounter/SDL.git
Retry hid_send_feature_report() if the ioctl() fails with EPIPE (e.g. the device stalled)
This commit is contained in:
parent
a3648e26df
commit
911d91c55c
|
@ -826,15 +826,23 @@ int HID_API_EXPORT hid_set_nonblocking(hid_device *dev, int nonblock)
|
||||||
return 0; /* Success */
|
return 0; /* Success */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int HID_API_EXPORT hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length)
|
int HID_API_EXPORT hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length)
|
||||||
{
|
{
|
||||||
|
static const int MAX_RETRIES = 50;
|
||||||
|
int retry;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
for (retry = 0; retry < MAX_RETRIES; ++retry) {
|
||||||
res = ioctl(dev->device_handle, HIDIOCSFEATURE(length), data);
|
res = ioctl(dev->device_handle, HIDIOCSFEATURE(length), data);
|
||||||
|
if (res < 0 && errno == EPIPE) {
|
||||||
|
/* Try again... */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
perror("ioctl (SFEATURE)");
|
perror("ioctl (SFEATURE)");
|
||||||
|
break;
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue