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

Started by yashiro32, March 11, 2015, 20:48:36

Previous topic - Next topic

yashiro32

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.

EasyPickins

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.

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