nyholku / purejavahidapi

Other
122 stars 69 forks source link

HID Descriptor #43

Closed SlimerDude closed 7 years ago

SlimerDude commented 7 years ago

Hi, this is more of a question than an issue but wasn't sure where else to ask it...

I've been reading the Tutorial about USB HID Report Descriptors and playing with the official HID Descriptor Tool and I was wondering...

...How can I get hold of the HID Report Descriptor in purejavahidapi?

The purejavahidapi.hidparser.HidParser class looks like just the sort of thing I want to do, but how do I get hold of the raw data to pass into it? I see the HidParserTestData class, but where did these byte arrays come from, and how may I grab them for my own devices?

There is HidDevice.getFeatureReport() but that requires you to know how long the report is before you read it, and my attempts at guessing lengths hasn't heralded any results. (-1 is always returned.) So I'm thinking perhaps it's not this.

Under Planned Functionality you say:

the ability to read raw descriptor still eludes me.

Does this mean you don't understand HID Report Descriptors ('cos they are very complicated!) or does it mean you can't yet get hold of the raw data?

My interest is to just create a generic Gamepad reader without having own and decode input data for all the Gamepad variants. I figure this must have been done plenty of times before, but I'm not able to find any resources on it (my Google foo is weak!) so I thought I look at reading the HID Report Descriptor instead.

Anyway, awesome job on purejavahidapi - it works well! By pressing buttons and seeing what bits and bytes change, I can use my current Gamepad - thanks!

nyholku commented 7 years ago

Hi,

thanks for the comments.

Yes, the thing is, (been a few years since I last attacked this issue so I maybe remembering incorrectly) that I've not found a way to read raw descriptors in all platforms. So that is the essential difficulty.

Parsing the descriptors, while complex, should not really be difficult even if it might involve considerable work and testing.

If your goal is just gamepads then perhaps a library similar in spirit to PureJavaHidApi that would use the native gamepad APIs of each platform would be a better approach. After all every platform. I believe, has an API for that purpose and those support a larger variety of gamepads that just USB/HID. At least I think so cause you can have Bluetooth and other gamepads too and I'm not sure how they fit into the USB/HID concept, if at all.

cheers Kusti

SlimerDude commented 7 years ago

Hi Kusti,

Thanks for the quick reply.

I only recently discovered that console Gamepads could be used recognised and used on a PC (like, WOW!), so this whole concept is still new to me. So I wasn't really aware that there might be a native Gamepad API - but it makes sense. I'll have a sniff around in that direction.

But thanks for your work on PureJavaHidApi, its helped me get up and running with the Gamepads I have! (Which may be good enough for now...)

Cheers.

nuessgens commented 6 years ago

Hi,

I know this issue was closed a while ago (almost one year) but I have a question related to the HID-descriptors mentioned in this issue (/thread)

I encountered the same problem as you. Reading HID descriptors from a device is very annoying. I managed to do it with plain usb4java (/libusb). The problem is that the USB HID-Interface has to be force-claimed to read the descriptor (so the java-process has exclusive access). Furtheremore on Windows 10 I had to install WinUSB drivers so that the OS did not recognize the device as HID anymore (but could be used with libusb)

I'm very interested in your results of research on reading raw HID descriptors. You wrote that you did not manage to read raw descriptors on all platforms. So I assume you found a way on some platforms ;-) Which platforms did you manage to read descriptors on, and how? A solution working just on linux would be sufficient for my purposes.

Thanks in advance.

Kind regards

nyholku commented 6 years ago

Hi IIRC (it's been a while) I was able to read the descriptors on Linux using libusb. Not sure if I was able to do that on Windows, definitely I could not find a way to do that on Mac OS. Would have been nice to offer that but then again, the purpose of the descriptors is that 'standard' HID devices can describe their behaviour but the purpose of PureJavaHidApi is to support 'non-standard' HID devices which typically do not have the HID descriptors in the first place because they are 'misusing' the HID standard for their own purposes.