Code:
public void update(GameContainer container, int delta) throws SlickException
{
System.out.println(Controllers.getController(0).getName());
System.out.println(Controllers.getController(0).getXAxisValue());
System.out.println(Controllers.getController(0).getYAxisValue());
Controller[] cons = ControllerEnvironment.getDefaultEnvironment().getControllers();
for (Controller c : cons)
{
if (c.getName().contains("USB"))
{
for (net.java.games.input.Component ca : c.getComponents())
{
if (ca.getName().contains("X Axis") || ca.getName().contains("Y Axis"))
{
System.out.println(ca.getPollData());
}
}
}
}
}
getXAxisValue() and getYAxisValue() return -1 at the start of the game. When i click the corresponding direction once, they return 0.
If i use Jinput directly, it returns the correct value.
Tested with 3 different joysticks
The example above outputs the following at the start of the program:
Code:
USB Joystick
-1.0
-1.0
-1.5258789E-5
-1.5258789E-5
If i press the direction, as said, it outputs:
Code:
USB Joystick
0
0
-1.5258789E-5
-1.5258789E-5
Not sure whether it's a LWJGL problem or Slick messing up some LWJGL input initialization.[/quote]