gary-rowe / hid4java

A cross-platform Java Native Access (JNA) wrapper for the libusb/hidapi library. Works out of the box on Windows/Mac/Linux.
MIT License
229 stars 71 forks source link

Returning value is always -1 from getFeatureReport function #98

Closed boraciner closed 4 years ago

boraciner commented 4 years ago

Hi! I'm trying to call getFeatureReport function but it's always returning -1.

hidApiLibrary.hid_get_feature_report(device.ptr(), report, data.length + 1); is also returns -1 . what can be the problem? Thanks.

gary-rowe commented 4 years ago

Hi. If a feature report request is returning -1 then it indicates an error condition. You may find that calling getLastErrorMessage() will provide more information on what has gone wrong.

boraciner commented 4 years ago

it says Incorrect function =( I don't know why. =(

byte[] mybytearray = new byte[512]; int retVal = myJoystick.getFeatureReport(mybytearray, (byte) 0x00); if(retVal == -1) { System.out.println(myJoystick.getLastErrorMessage()); }

for device :

getUsage : 5 getUsagePage : 1 HidDevice [path=\\?\hid#vid_0079&pid_181c#6&8d3fc83&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}, vendorId=0x79, productId=0x181c, serialNumber=null, releaseNumber=0x101, manufacturer=SPEEDLINK COMPETITION PRO, product=Game Controller for Android , usagePage=0x1, usage=0x5, interfaceNumber=-1]

Please take a look at this link : here Is it the same problem?

Thanks

gary-rowe commented 4 years ago

Hi @boraciner. I did a quick bit of digging around to find a data sheet on the Speedlink Competition Pro joystick but it wasn't immediately available. Looking at the controller I'm not convinced that it is sophisticated enough to actually have feature reports which is why you're getting the error message.

I think your next step should be to find the data sheet on the internal USB controller for the device and discover the correct commands to detect its state (button up/down, left/right etc).

Also, you may find this project helpful: https://github.com/spurious/SDL-mirror (there is a lot of low-level HID work going on for a wide range of joysticks).

boraciner commented 4 years ago

Thanks a lot for your quick response, I already extracted meaningful bytes and I'm handling these. I just wanted to have a report in order to use any kind of joystick independently from product vendor-specific implementation :) Have a nice day!