HidSharp
HidSharp copied to clipboard
Problem when using the precompiled dll that doesn't happen when compiling from sources
Hi, thanks for your work. I'm developing a usb device (gaming pedals), and I have a strange bug when adding vendor defined fields in the descriptor. When using the dll from the nuget package the lib is failing retrieving the descriptor, but when I compile the dll from the source I have no problem.
I'm not sure if it's the cause, but it happens only when the report size field of the last vendor ID declaration is 4 bits. When I set it to 8 bits it works. In all case the size is a multiple of 8 bits as report count is 4.
The descriptor is the following byte array : uint8_t descriptor[] ={0x05,0x01,0x09,0x4,0xA1,0x1,0x85,0x1,0x05,0x01,0x16,0x0,0x80,0x36,0x0,0x80,0x26,0xFF,0x7F,0x46,0xFF,0x7F,0x09,0x30,0x09,0x31,0x09,0x32,0x75,0x10,0x95,0x3,0x81,0x2,0x06,0,0xFF,0x75,0x10,0x09,0x10,0x95,0x1,0x81,0x2,0x06,0,0xFF,0x75,4,0x09,0x20,0x95,0x4,0x81,0x2,0xC0,0x05,0x01,0x09,0x3A,0xA1,0x1,0x85,0xFF,0x05,0x01,0x09,0x3B,0x15,0x0,0x26,0xFF,0x0,0x35,0x0,0x46,0xFF,0x0,0x75,0x8,0x95,63,0x81,0x2,0x06,0,0xFF,0x09,0x01,0x95,63,0x91,0x2,0xC0};
The nuget package was published by the original author, who is not affiliated with this fork. There are many known problems with the library’s parser (see other open tickets), a few of which have been remedied here. I’d honestly suggest trying out libusb/hidapi instead - as it’s a lot better maintained - and writing a C# wrapper on top.
Oh ok, sorry I thought you were at the origin of the package. I don't have much time nor the knowledge yet for writing a libusb/hidapi c# wrapper, but thanks for the advice (there seems to be a few available out there). I've found how to avoid the bug for now, by keeping 8 bits in report sizes (which is not very satisfying of course, as I know a few devices that may not work). I'll probably consider your option later.