I’ve got a 360 controller here - and the good news is that it works perfectly.
I’ve also got a Saitek controller here - a pretty standard looking wired USB gamepad with two analogue sticks etc. etc. The problem is the getRXAxisValue()/getRYAxisValue() methods don’t work, when really I’d expect them to work. The hack I’m using to cope with it looks like this:
float fireXaxis = Game.getControllerType() == ControllerType.XBOX360 ? c.getRXAxisValue() : c.getAxisValue(2);
float fireYaxis = Game.getControllerType() == ControllerType.XBOX360 ? c.getRYAxisValue() : c.getAxisValue(3);
where I detect the controller type by checking the axis names with the following lame hackery:
Set<String> axes = new HashSet<String>();
for (int i = 0; i < controller.getAxisCount(); i ++) {
axes.add(controller.getAxisName(i).toLowerCase());
}
if (axes.contains("y axis") && axes.contains("x axis") && axes.contains("y rotation") && axes.contains("x rotation")) {
controllerType = ControllerType.XBOX360;
} else {
controllerType = ControllerType.GENERIC;
}
This all looks like hax to me. Can I do this better?
Cas