summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Hjärtström <mathias.hjartstrom@telia.com>2022-03-17 12:43:18 +0100
committerTormod Volden <debian.tormod@gmail.com>2022-03-20 09:50:38 +0100
commit66d3849974dbc93d8bad418dbf594b37c95416f9 (patch)
treef8bbe81b605a55c93c6d0e1c75b0ce5f94c99b5b
parentf939c8aabaaa42739e294df12cbac9e6a87a708a (diff)
downloadlibusb-66d3849974dbc93d8bad418dbf594b37c95416f9.tar.gz
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
-rw-r--r--libusb/os/windows_winusb.c5
-rw-r--r--libusb/version_nano.h2
2 files changed, 5 insertions, 2 deletions
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 @@ static int hid_open(int sub_api, struct libusb_device_handle *dev_handle)
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