macOS: Add errno setting in set_report (HID)

IsDeviceUsable in IOhidapi.cpp uses errno to detect if hid_write failed because of an unconnected Wiimote on a Dolphinbar (it expects errno == EPIPE in this case).
macOS’s implementation of hid_write detected this specific error (IOHIDDeviceSetReport returns kUSBHostReturnPipeStalled) but didn’t set errno so the check failed.
This add errno assignment to failure cases of macOS’s hid_write.
This commit is contained in:
Vincent Duvert 2018-01-07 11:14:51 +01:00
parent 8d5810a103
commit 3abc288e02
1 changed files with 10 additions and 3 deletions

View File

@ -773,8 +773,10 @@ static int set_report(hid_device *dev, IOHIDReportType type, const unsigned char
IOReturn res;
/* Return if the device has been disconnected. */
if (dev->disconnected)
if (dev->disconnected) {
errno = ENODEV;
return -1;
}
if (data[0] == 0x0) {
/* Not using numbered Reports.
@ -797,9 +799,14 @@ static int set_report(hid_device *dev, IOHIDReportType type, const unsigned char
if (res == kIOReturnSuccess) {
return length;
}
else
} else if (res == (IOReturn)0xe0005000) {
/* Kernel.framework's IOUSBHostFamily.h defines this error as kUSBHostReturnPipeStalled */
errno = EPIPE;
return -1;
} else {
errno = EBUSY;
return -1;
}
}
return -1;