2015-03-31 37 views
0

当前我有一个N-Trig多点触控面板挂接到事件文件/ dev/input/event4,并且我试着this来访问它。我已经在java.library.path中包含了所有的本地文件,但即使在超级用户的情况下也会出现此错误。例外:Java/dev/input/eventX

java.io.IOException: Invalid argument 
    at sun.nio.ch.FileDispatcherImpl.read0(Native Method) 
    at sun.nio.ch.FileDispatcherImpl.read(FileDispatcherImpl.java:46) 
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) 
    at sun.nio.ch.IOUtil.read(IOUtil.java:197) 
    at sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:149) 
    at com.dgis.input.evdev.EventDevice.readEvent(EventDevice.java:269) 
    at com.dgis.input.evdev.EventDevice.access$1(EventDevice.java:265) 
    at com.dgis.input.evdev.EventDevice$1.run(EventDevice.java:200) 
EVENT: null 
Exception in thread "Thread-0" java.lang.NullPointerException 
    at com.asdev.t3.Bootstrap$1.event(Bootstrap.java:41) 
    at com.dgis.input.evdev.EventDevice.distributeEvent(EventDevice.java:256) 
    at com.dgis.input.evdev.EventDevice.access$2(EventDevice.java:253) 
    at com.dgis.input.evdev.EventDevice$1.run(EventDevice.java:201) 

有没有人知道为什么会发生这种情况?谢谢

回答

1

我在项目的issues page上回答了这个问题。

通过attilapara
嗨,我试图用这个库在树莓派,我得到了相同的 例外,但我想通了问题的根源,并设法 得到它的工作。基本上,问题是这个库仅为针对64位CPU/OS而编写的 。说明:

的input_event结构看起来像这样(源):

struct input_event { 
    struct timeval time; 
    unsigned short type; 
    unsigned short code; 
    unsigned int value; 
}; 

在这里,我们的timeval,它具有下列部件(源):

time_t   tv_sec  seconds 
suseconds_t tv_usec  microseconds 

这两种类型被表示不同在一个32位和一个64位的 系统上。

解决办法:

  1. 变化input_event的从24到16字节的大小:源文件 了evdev-java的/ SRC/COM/DGIS /输入的

变更线34/evdev/InputEvent.java from:

public static final int STRUCT_SIZE_BYTES = 24; to this: 

    public static final int STRUCT_SIZE_BYTES = 16; Change the parse function in the same source file as follows: 

public static InputEvent parse(ShortBuffer shortBuffer, String source) throws IOException { 
    InputEvent e = new InputEvent(); 
    short a,b,c,d; 

    a=shortBuffer.get(); 
    b=shortBuffer.get(); 
    //c=shortBuffer.get(); 
    //d=shortBuffer.get(); 
    e.time_sec = (b<<16) | a; //(d<<48) | (c<<32) | (b<<16) | a; 
    a=shortBuffer.get(); 
    b=shortBuffer.get(); 
    //c=shortBuffer.get(); 
    //d=shortBuffer.get(); 
    e.time_usec = (b<<16) | a; //(d<<48) | (c<<32) | (b<<16) | a; 
    e.type = shortBuffer.get(); 
    e.code = shortBuffer.get(); 
    c=shortBuffer.get(); 
    d=shortBuffer.get(); 
    e.value = (d<<16) | c; 
    e.source = source; 

    return e; 
}