NullPointerException
Hey there,
I would like to apologize in advance for my bad English.
I want to use your EvDev for my Java-Project on a RaspberryPI 3 with Raspbian (64-bit). Until now everything works fine, but now I have a big problem:
I'm using two keyboards (Keyboard A and B) and I want to seperate them and check their Inputs.
Keyboard A has following files in /dev/input:
Keyboard A /dev/input/event0 /dev/input/event1 /dev/input/by-path/platform-3f980000.usb-usb-0:1.4:1.2-event-kbd
Keyboard B /dev/input/event2 /dev/input/event3 /dev/input/by-path/platform-3f980000.usb-usb-0:1.5:1.2-event-kbd
For example I will only use Keyboard A but I get the same problems with Keyboard B.
If I'm using...as String fn...
event0 -> I can typeIn from the Keyboard but nothing happens.
event1 -> I can typeIn and e returns 3-times null
by-path -> I can typeIn and java returns an NullPointerException in EventDevice.java (see Code below):
Exception in thread "Thread-0" java.lang.NullPointerException at Test$1.event(Test.java:29) 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)
I don't know what I can do to solve this problem. If you need any further information please tell me and I will post it.
Thanks in advance for your help. Greetings JoGGi
Honestly, this is very much a side project, that I'm doing for fun and that I have not touched for a very long time. Not sure I will be able to help you...
That being said, could you send a code sample reproducing the issue? I'll try to have a look...
`import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader;
import com.dgis.input.evdev.EventDevice; import com.dgis.input.evdev.InputEvent; import com.dgis.input.evdev.InputListener;
public class Test {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
new Test(args[0]);
}
public Test(String fn) throws IOException{
System.out.println("Erstelle EventDevice!");
// EventDevice dev = new EventDevice("/dev/input/by-path/platform-3f980000.usb-usb-0:1.4:1.2-event-kbd"); // EventDevice dev = new EventDevice("/dev/input/event1"); // EventDevice dev = new EventDevice("/dev/input/by-id/usb-Logitech_USB_Receiver-if02-event-kbd"); EventDevice dev = new EventDevice("/dev/input/event0"); System.out.println("Erfolgreich!\n");
System.out.println("Gebe Version aus!");
System.out.println("Version: " + dev.getEvdevVersion());
System.out.println("Erfolgreich!\n");
System.out.println("Gebe KeboardInfos aus!");
System.out.println("KeyboardID: " + dev.getBusID());
System.out.println("KeyboardName: " + dev.getDeviceName());
System.out.println("Eroflgreich!\n");
System.out.println("Erstelle KeyListener!");
dev.addListener(new InputListener() {
public void event(InputEvent e) {
System.out.println("KeyCode: " +e.code);
}
});
System.out.println("Erfolgreich!\n");
System.out.println("Frage Taste ab!");
new BufferedReader(new InputStreamReader(System.in)).readLine();
System.out.println("Erfolgreich!\n");
System.out.println("Schließe EventDevice!");
dev.close();
System.out.println("Erfolgreich!\n");
System.out.println("Beende Programm!");
}
} `
This is the latest Code I tried. Every Sysout ist for Check...sry for german. Do you need anything else?
Thank you very much!
I have no idea what goes wrong here... I suspect that the native code is only IA-64 compatible and fails on ARM (I have never tried to run it on a Raspberry).
Good job on this Java wrapper. I am using the adjustments to STRUCT_SIZE_BYTES and the PARSE function suggested in ISSUE #1 and the Wireless USB keypad on Rasberry PI 3b is working well. Thanks!