2015-03-31 34 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; 
}