windows: Fix product string retrieval on HID composite devices
A HID composite device with three interfaces (e.g. keyboard and touch
screen built into one), with all three interfaces referencing their own
names in the interface descriptor, was reported to have an iProduct
string equal to the name of the last interface instead of the actual
product name (e.g. "TOUCH" repeated twice instead of "PRODUCT" and
"TOUCH").
This behavior differ from what for instance Microsoft USB Device Viewer
will report for the same device. This fix will make them report the same
thing.
Use HidD_GetIndexedString() instead of HidD_GetProductString(), as the
latter would otherwise return the name of the interface instead of the
iProduct string whenever the iInterface member of the
USB_INTERFACE_DESCRIPTOR structure for the interface is nonzero (see
Remarks section in the Microsoft documentation of the HID API routines).
Closes #1091
diff --git a/libusb/os/windows_winusb.c b/libusb/os/windows_winusb.c
index 9e6ccaa..1303707 100644
--- a/libusb/os/windows_winusb.c
+++ b/libusb/os/windows_winusb.c
@@ -3864,7 +3864,10 @@
priv->hid->string_index[1] = dev->device_descriptor.iProduct;
if (priv->hid->string_index[1] != 0)
- HidD_GetProductString(hid_handle, priv->hid->string[1], sizeof(priv->hid->string[1]));
+ // Using HidD_GetIndexedString() instead of HidD_GetProductString(), as the latter would otherwise return the name
+ // of the interface instead of the iProduct string whenever the iInterface member of the USB_INTERFACE_DESCRIPTOR
+ // structure for the interface is nonzero (see Remarks section in the documentation of the HID API routines)
+ HidD_GetIndexedString(hid_handle, priv->hid->string_index[1], priv->hid->string[1], sizeof(priv->hid->string[1]));
else
priv->hid->string[1][0] = 0;
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 346fcb8..4271170 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11710
+#define LIBUSB_NANO 11711