Hello,
I want to use my spacemouse XT (RS 232) with JInput. I work on Linux and Eclipse Europa. I have made various tests, but in the end the following message appears when I execute the Java program :
Loading: net.java.games.input.LinuxEnvironmentPlugin
Failed to open device (/dev/input/event1): Failed to open device /dev/input/event1 (13)
Failed to open device (/dev/input/event0): Failed to open device /dev/input/event0 (13)
java.lang.ClassCastException: net.java.games.input.LinuxMouse
at net.java.games.input.LinuxEnvironmentPlugin.enumerateControllers(LinuxEnvironmentPlugin.java:257)
at net.java.games.input.LinuxEnvironmentPlugin.<init>(LinuxEnvironmentPlugin.java:113)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at java.lang.Class.newInstance0(Class.java:350)
at java.lang.Class.newInstance(Class.java:303)
at net.java.games.input.DefaultControllerEnvironment.getControllers(DefaultControllerEnvironment.java:157)
at TestJinput.<init>(TestJinput.java:10)
at Lanceur.main(Lanceur.java:5)
My Java program :
//source : http://www.java-gaming.org/forums/index.php?topic=16866.0
import net.java.games.input.Controller;
import net.java.games.input.ControllerEnvironment;
public class TestJinput {
public TestJinput() {
ControllerEnvironment ce =
ControllerEnvironment.getDefaultEnvironment();
Controller[] ca = ce.getControllers();
}
}
My configuration :
[root@client ~]# modprobe magellan
[root@client ~]# inputattach -mag /dev/ttyS0
[toto@client ~]$ cat /proc/bus/input/devices
....
I: Bus=0013 Vendor=001a Product=0001 Version=0100
N: Name="LogiCad3D Magellan / SpaceMouse"
P: Phys=ttyS0/serio0/input0
S: Sysfs=/class/input/input2
H: Handlers=event2 js0
B: EV=b
B: KEY=1ff 0 0 0 0 0 0 0 0
B: ABS=3f
[toto@client ~]$ ls -l /dev/input/
total 0
drwxr-xr-x 2 root root 120 avr 9 13:51 by-path/
crw------- 1 root root 13, 64 avr 9 2008 event0
crw------- 1 root root 13, 65 avr 9 2008 event1
crw------- 1 toto root 13, 66 avr 9 13:51 event2
crw------- 1 toto root 13, 0 avr 9 13:51 js0
crw-r--r-- 1 root root 13, 63 avr 9 2008 mice
crw-r--r-- 1 root root 13, 32 avr 9 2008 mouse0
crw------- 1 root root 13, 128 avr 9 2008 ts0
The test with the <a href=http://www.home.unix-ag.org/simon/files/spacenavi.c>spacenavi.c</a> Program :
[toto@client ~]$ ./spacenavi /dev/input/event2
found "LogiCad3D Magellan / SpaceMouse" on /dev/input/event2
Supported event types:
Event type 0x00 (Sync?)
Event type 0x01 (Keys or Buttons)
Event type 0x03 (Absolute Axes)
detected leds:
State: 19 -86 0 79 73 41 - off off
I had to add the following line in the <a href=http://www.home.unix-ag.org/simon/files/spacenavi.c>spacenavi.c</a> Program :
...
case EV_REL:
case EV_ABS:
if (event.code <= REL_RZ)
axes[event.code - REL_X] = event.value;
break;
...