LWJGL Forum

Programming => Bug Reports / RFE => Topic started by: yashiro32 on March 11, 2015, 20:48:36

Title: controller.getAxisValue() always get default value of -1
Post by: yashiro32 on March 11, 2015, 20:48:36
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.
Title: Re: controller.getAxisValue() always get default value of -1
Post by: EasyPickins 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.


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