mirror of https://github.com/nirenjan/libx52.git
Automatically close open handle when no device detected
Prior to this change, libx52_vendor_command would leave the device handle untouched, even if the joystick was disconnected. This change will force applications to reconnect to the joystick after they encounter such a failure.pull/22/head
parent
cdd5e773e2
commit
0cf977b751
|
@ -89,6 +89,14 @@ int libx52_vendor_command(libx52_device *x52, uint16_t index, uint16_t value)
|
|||
}
|
||||
}
|
||||
|
||||
/* Handle device removal */
|
||||
if (rc == LIBUSB_ERROR_NO_DEVICE) {
|
||||
/* Physical device has likely been disconnected, disconnect the virtual
|
||||
* handle, and report the failure.
|
||||
*/
|
||||
(void)libx52_disconnect(x52);
|
||||
}
|
||||
|
||||
return _x52_translate_libusb_error(rc);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue