LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: honeybadger on December 09, 2010, 13:44:03

Title: Joystick Axis Value Not Read by JInput Until It Is Moved At Least Once!?
Post by: honeybadger on December 09, 2010, 13:44:03
Hi guys,

Hope someone can help me out here...

I'm using a joystick to read the user input. The code looks something like this:

------

myValue = myJoystick.getAxisValue(0); //Where 0 is the axis id of the analog stick

------

The problem is, by default, "myValue" is always equals to "-1".

It is only when I move the stick AT LEAST ONCE will "myValue" reflect the true value of the controller axis.

Can anyone please tell me how I could get "myValue" to reflect the true axis value right from the start?

Thanks very much guys. Greatly appreciate your help!

PS:

I use the Controller class from "org.lwjgl.input.Controller".
Title: Re: Joystick Axis Value Not Read by JInput Until It Is Moved At Least Once!?
Post by: Blu3 on March 30, 2011, 18:18:00
I'm experiencing the same problem. Ive tried several joysticks.
If i use JInput directly, it gives me the correct values at once so there's definately something wrong with LWJGL's classes.

Id' appreciate any help as well.
Title: Re: Joystick Axis Value Not Read by JInput Until It Is Moved At Least Once!?
Post by: kappa on March 30, 2011, 18:52:36
there is an example here (http://java-game-lib.svn.sourceforge.net/viewvc/java-game-lib/trunk/LWJGL/src/java/org/lwjgl/test/input/TestControllers.java?revision=3511&view=markup), maybe that will help.
Title: Re: Joystick Axis Value Not Read by JInput Until It Is Moved At Least Once!?
Post by: Blu3 on March 30, 2011, 20:06:04
Quote from: kappa on March 30, 2011, 18:52:36
there is an example here (http://java-game-lib.svn.sourceforge.net/viewvc/java-game-lib/trunk/LWJGL/src/java/org/lwjgl/test/input/TestControllers.java?revision=3511&view=markup), maybe that will help.

Well, no. Here's the output at the start program when i haven't pressed anything on my controller:

(http://img576.imageshack.us/img576/8633/copyof1294778499078.png)

It fires all events correctly but the axis values get initialized with -1. That's the same value for when i press left. Shouldn't it be 0?