I'm looking to write a Linux/Windows/Mac Java HID controller for a simple wireless HID interface device. I've tinkered around with the USB4Java LibUsb library to no avail, and I've been steered in the direction of the JavaHIDAPI.
Unfortunately for me, I really have no idea what I'm doing beyond a pretty decent higher level programming skill set (C#/VB.Net), and switching over to this is killing me.
The directions that I found said that I would first need to compile the HIDAPI library found here. It said it would build something called hidapi-jni.dll (which it didn't).
Anyway, I think this is where I need to go since the HID does nothing but simply sends and receives signals to and from a wireless control (and responds to signals received).
Is there any step-by-step tutorial for using the JavaHIDAPI for this? Or is there a better library? (I noticed that this is a bit... dated).
I tried myself with the following:
static{ System.loadLibrary("hidapi"); }
.
.
.
public static void main(string[] Args) throws . . . {
ClassPathLibraryLoader.loadNativeHIDLibrary();
HIDDevice dev = HIDManager.getInstance().openById(VEND_ID, PROD_ID, null);
.
.
.
}
The issue into which I am running is that (besides the fact that the HIDAPI doesnt seem to be building into HIDAPI-jni.dll) is that the HIDManager.openById(. . .) always returns null. Also, I moved the hidapi.dll that was built into the C:...\Java...\bin directory... or something, I'm sure it's right because there wasn't any unsatisfied link error. It's really frustrating because there doesn't seem to be any newbies guide to Java and HID anywhere.
What am I doing wrong here?
So the issue, I discovered, was with native libraries. I was able to get the application to work by copying the .dll from the .jar file and referencing it, but more important, I'm going to rebuild the .java class file responsible for loading the library and add the
System.loadLibrary();
call. When the JavaHidApi
ClassPathLibraryLoader.loadNativeHIDLibrary();
method is called it doesn't load the library upon successfully writing it out to the temp file which is mildly annoying. Doing this will eliminate the necessity for manually loading the library from a static location...
Thank you for pointing me in the correct direction.