File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -595,6 +595,17 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
595
595
res = libusb_open (dev , & handle );
596
596
597
597
if (res >= 0 ) {
598
+ #ifdef __ANDROID__
599
+ /* There is (a potential) libusb Android backend, in which
600
+ device descriptor is not accurate up until the device is opened.
601
+ https://github.com/libusb/libusb/pull/874#discussion_r632801373
602
+ A workaround is to re-read the descriptor again.
603
+ Even if it is not going to be accepted into libusb master,
604
+ having it here won't do any harm, since reading the device descriptor
605
+ is as cheap as copy 18 bytes of data. */
606
+ libusb_get_device_descriptor (dev , & desc );
607
+ #endif
608
+
598
609
/* Serial Number */
599
610
if (desc .iSerialNumber > 0 )
600
611
cur_dev -> serial_number =
@@ -927,6 +938,12 @@ hid_device * HID_API_EXPORT hid_open_path(const char *path)
927
938
break ;
928
939
}
929
940
good_open = 1 ;
941
+
942
+ #ifdef __ANDROID__
943
+ /* See remark in hid_enumerate */
944
+ libusb_get_device_descriptor (usb_dev , & desc );
945
+ #endif
946
+
930
947
#ifdef DETACH_KERNEL_DRIVER
931
948
/* Detach the kernel driver, but only if the
932
949
device is managed by the kernel */
You can’t perform that action at this time.
0 commit comments