From c9ed92d3f55c259931527a27d018eb5791a176dd Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 11 Jul 2017 11:16:15 +0200 Subject: [PATCH] Workaround for a Windows hidapi issue The Windows HID api always expects to receive a fixed size buffer (corresponding to the largest report supported by the device). Therefore the hidapi library internally pads the buffer with zeros to the expected size, but apparently it also returns the size of the padded buffer! As a workaround the number of bytes is limited to the actual size. --- src/usbhid.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/usbhid.c b/src/usbhid.c index 99df918..7894f06 100644 --- a/src/usbhid.c +++ b/src/usbhid.c @@ -426,6 +426,12 @@ dc_usbhid_write (dc_usbhid_t *usbhid, const void *data, size_t size, size_t *act nbytes = 0; goto out; } + +#ifdef _WIN32 + if (nbytes > size) { + nbytes = size; + } +#endif #endif out: