Java and HID Communication

前端 未结 2 1232
再見小時候
再見小時候 2021-01-07 05:17

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,

相关标签:
2条回答
  • 2021-01-07 06:02

    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.

    0 讨论(0)
  • 2021-01-07 06:06

    I'm a bit late to answer this question, but I've written a library called hid4java that might solve your problem.

    It's based on Java Native Access (JNA) which is a lot simpler than faffing about with complex JNI incantations.

    I had to write it because javahidapi is out of date and the underlying signal11/hidapi code has moved on considerably. The older versions of the hidapi library had problems on OS X with attach/detach events which have now been fixed so an upgrade is necessary.

    Also I found it impossible to claim a USB HID device through usb4java on OS X so I ended up writing this library to solve that problem.

    Hope it helps.

    0 讨论(0)
提交回复
热议问题