Hello,
I have a problem with a gamepad on os x, it returns only -1.0 and 1.0. It works on the same hardware running WinXP. The controller works with “joystick und gamepad tester.app” on os x, it returns values form -128 to 127, where 0 is at one end, -128 at middle stick and -1 at the other end.
I have test the device with:
java -Djava.library.path=. -cp jinput.jar:jinput-test.jar net.java.games.input.test.ControllerReadTest
TestCode:
public class foo {
public static void main(String[] args) {
Controller[] ca = ControllerEnvironment.getDefaultEnvironment().getControllers();
Controller Tx=null;
for(int i =0;i<ca.length;i++){
System.out.println(ca[i].getName());
if (!ca[i].getName().equals("ART TECH GAME. ")) continue;
Tx = ca[i];
System.out.println("Type: "+Tx.getType().toString());
/* Get this controllers components (buttons and axis) */
Component[] components = Tx.getComponents();
System.out.println("Component Count: "+components.length);
for(int j=0;j<components.length;j++){
/* Get the components name */
System.out.println("Component "+j+": "+components[j].getName());
System.out.println(" Identifier: "+ components[j].getIdentifier().getName());
System.out.print(" ComponentType: ");
if (components[j].isRelative()) {
System.out.print("Relative");
} else {
System.out.print("Absolute");
}
if (components[j].isAnalog()) {
System.out.print(" Analog");
} else {
System.out.print(" Digital");
}
}
}
while(true) {
Tx.poll();
Component[] components = Tx.getComponents();
StringBuffer buffer = new StringBuffer();
for(int i=0;i<components.length;i++) {
if(i>0) {
buffer.append(", ");
}
buffer.append(components[i].getName());
buffer.append(": ");
buffer.append(components[i].getPollData());
}
System.out.println(buffer.toString());
try {
Thread.sleep(20);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
Output:
ART TECH GAME.
Type: Stick
Component Count: 6
Component 0: x
Identifier: x
ComponentType: Absolute AnalogComponent 1: y
Identifier: y
ComponentType: Absolute AnalogComponent 2: z
Identifier: z
ComponentType: Absolute AnalogComponent 3: rx
Identifier: rx
ComponentType: Absolute AnalogComponent 4: ry
Identifier: ry
ComponentType: Absolute AnalogComponent 5: rz
Identifier: rz
ComponentType: Absolute AnalogApple Magic Mouse
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
x: -1.0, y: -1.0, z: 1.0, rx: -1.0, ry: 1.0, rz: 1.0
any tips to debug this issue?
Thanks Maik