我已经构建了 hid4java Maven 项目并成功地将库放入类库中。
这是我试图打开我正在使用的设备的代码:
public class JR3Controller implements HidServicesListener {
private static JR3Controller Ctor = null;
private JR3Reader Reader = null;
private JR3Writer Writer = null;
private HidDevice dev = null;
private HidServices mgr = null;
/**
* R3 Controller Object.
* @return
*/
public static boolean Initialize() throws HidException{
if (JR3Controller.Ctor != null) return true;
JR3Controller.Ctor = new JR3Controller();
JR3Controller.Ctor.mgr.addHidServicesListener(JR3Controller.Ctor);
return JR3Controller.Ctor.dev != null;
}
private JR3Controller(){
this.mgr = HidManager.getHidServices();
this.dev = this.mgr.getHidDevice(0x0003, 0x1001, null);
if (this.dev != null){
/*Stuff goes here : Doesn't matter because dev is never not null after the preceding line*/
}
这发生在 Windows 10 中(搜索显示 Windows 10 可能是问题:https ://github.com/signal11/hidapi/issues/231 ),在 Netbeans 上运行 32 位 JVM...
我在这里做错了吗?有没有办法解决这个问题?是否有可用于简单 HID 设备的 hid4java 替代方案?