Capture USB mouse raw data using libusb

2.4k views Asked by At

I want to capture raw data from a USB mouse using libusb library by C#.

I can read data with the UsbEndpointReader class, but there is a problem.

When I try to read data it seems that Windows tries to read too, and I can't read all data and the OS can't either, because mouse movements have some steps. I want to read all data and let the OS read those data too (I mean without problem in moving the cursor).

Another problem that I have is that I don't know how can I get HID descriptor. I know it's possible by calling GetDescriptor method, but how can I do it?

1

There are 1 answers

0
Ben Voigt On BEST ANSWER

To prevent conflict with Windows reading from the mouse, you should disable the associated mouse instance in Device Manager.

If you want shared access to mouse data, use a low-level mouse hook, not libusb. If you really want it in USB HID message format, you can use a filter driver to get a copy of every request and response Windows gets from the device.