mirror of
https://github.com/RPCS3/hidapi.git
synced 2026-07-19 13:34:37 -04:00
libusb: add support for potential Android JNI backend
This commit is contained in:
@@ -595,6 +595,17 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
|
||||
res = libusb_open(dev, &handle);
|
||||
|
||||
if (res >= 0) {
|
||||
#ifdef __ANDROID__
|
||||
/* There is (a potential) libusb Android backend, in which
|
||||
device descriptor is not accurate up until the device is opened.
|
||||
https://github.com/libusb/libusb/pull/874#discussion_r632801373
|
||||
A workaround is to re-read the descriptor again.
|
||||
Even if it is not going to be accepted into libusb master,
|
||||
having it here won't do any harm, since reading the device descriptor
|
||||
is as cheap as copy 18 bytes of data. */
|
||||
libusb_get_device_descriptor(dev, &desc);
|
||||
#endif
|
||||
|
||||
/* Serial Number */
|
||||
if (desc.iSerialNumber > 0)
|
||||
cur_dev->serial_number =
|
||||
@@ -927,6 +938,12 @@ hid_device * HID_API_EXPORT hid_open_path(const char *path)
|
||||
break;
|
||||
}
|
||||
good_open = 1;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
/* See remark in hid_enumerate */
|
||||
libusb_get_device_descriptor(usb_dev, &desc);
|
||||
#endif
|
||||
|
||||
#ifdef DETACH_KERNEL_DRIVER
|
||||
/* Detach the kernel driver, but only if the
|
||||
device is managed by the kernel */
|
||||
|
||||
Reference in New Issue
Block a user