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.
This commit is contained in:
Jef Driesen 2017-07-11 11:16:15 +02:00
parent b82d5fcfff
commit c9ed92d3f5

View File

@ -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: