Hello Guest

controller.getAxisValue() always get default value of -1

  • 1 Replies
  • 5664 Views
Using controller.getAxisValue() always get a value that is default set to -1 instead of 0 even before any button or axis controller is pressed.

Re: controller.getAxisValue() always get default value of -1
« Reply #1 on: August 22, 2015, 22:08:53 »
I was able to work around this issue on Windows using LWJGL 2.9.3.
The problem appears to be that the JInputController() constructor calls getPollData() on each axis before the device has been polled.
The workaround is to execute this code before org.lwjgl.input.Controllers.create() is called.

Code: [Select]
ControllerEnvironment e = ControllerEnvironment.getDefaultEnvironment();
net.java.games.input.Controller[] found = e.getControllers();
for (net.java.games.input.Controller c : found) {
    c.poll();
}
Controllers.create();