Fix Windows HID backend missing byte
authormcuee <xiaofanc@gmail.com>
Fri, 27 Aug 2021 09:49:30 +0000 (17:49 +0800)
committerTormod Volden <debian.tormod@gmail.com>
Thu, 23 Sep 2021 08:49:34 +0000 (10:49 +0200)
When the report id is zero, we should indeed skip the first byte of
transfer_priv->hid_buffer, since it is not part of the actual report.
But the report size should not change.

Thanks to Jonas Malaco who has done the investigation in this issue.
Reference: Jonas Malaco's comments
https://github.com/libusb/libusb/issues/902#issuecomment-810726897

Fixes #902
Fixes #977
Closes #986

libusb/os/windows_winusb.c
libusb/version_nano.h

index 299de16f5678f1a38a32aa3e5c6043e5e79bf3bd..df40773b7f0cb3e8ca786c580e4e02b03f56c668 100644 (file)
@@ -4205,8 +4205,6 @@ static enum libusb_transfer_status hid_copy_transfer_data(int sub_api, struct us
                                }
 
                                if (transfer_priv->hid_buffer[0] == 0) {
-                                       // Discard the 1 byte report ID prefix
-                                       length--;
                                        memcpy(transfer_priv->hid_dest, transfer_priv->hid_buffer + 1, length);
                                } else {
                                        memcpy(transfer_priv->hid_dest, transfer_priv->hid_buffer, length);
index 1a8e712bfeb9dac6aa9c5b4be01c78dc5d0098d6..36ca1a09ce1b530050103fec45b95183a66a4e12 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11650
+#define LIBUSB_NANO 11651