I wrote a small class to implement jinput for joysticks into my code, its picking up the joysticks but the poll data never updates. I have run jtest and it works just fine. Can someone point out whats going wrong before this lib makes me what to hurl an input device?

publicvoidcontrollerAdded(ControllerEventev) {// attach to new joystick if theres not one alreadyif(Joystick_Controller == null)if(checkisJoystick(ev.getController()))this.setJoystick(ev.getController()); }

publicvoidcontrollerRemoved(ControllerEventev) {// if we loose the joystick, try to find another one.if(ev.getController() == Joystick_Controller)this.processfindJoystick(); }

I think they mean that the data itself never updates?, and I can't see anything obvious at this time (spent a whole 20 seconds looking), you're doing the poll on the controller and then getting the poll data, so it should work. Have you tried running the tests that come with JInput?

Yes. Ive run the test module and it works fine. Button presses are displayed normally. When I run the code provided, the only output I get is the notice that my joystick has been found. However button/axis presses do not generate output.

Ive swapped controllers, checked my security permissions, and tried a few other things. I noticed the module gives some errors when loading but so does the test module. And the test module still works correctly.

My console output from the code is:

Quote

Loading: net.java.games.input.LinuxEnvironmentPluginFailed to open device (/dev/input/event11): Failed to open device /dev/input/event11 (13)

Failed to open device (/dev/input/event10): Failed to open device /dev/input/event10 (13)

Failed to open device (/dev/input/event7): Failed to open device /dev/input/event7 (13)

Failed to open device (/dev/input/event6): Failed to open device /dev/input/event6 (13)

Failed to open device (/dev/input/event5): Failed to open device /dev/input/event5 (13)

Failed to open device (/dev/input/event4): Failed to open device /dev/input/event4 (13)

Failed to open device (/dev/input/event3): Failed to open device /dev/input/event3 (13)

Failed to open device (/dev/input/event2): Failed to open device /dev/input/event2 (13)

Failed to open device (/dev/input/event1): Failed to open device /dev/input/event1 (13)

Failed to open device (/dev/input/event0): Failed to open device /dev/input/event0 (13)

I changed several things in the code, and now it works well. I'm not really sure why, but I think I was either calling pollData() to many times instead of storing it to a variable, or because the function calling the poll of this module had a Synchronized keyword on it. But I rewrote it this way and it works now.

Also: I never did get controller connection/disconnection listener to work. That may be because im on a linux build

Seems my problem wasnt cleared up completely by the code change, only I am now more confused than before. I have two joysticks, which I am not plugging in at the same time. Both joysticks, when run with jtest respond correctly and fully. However with my code above, only one joystick responds correctly.

The first one a standard USB gravis gamepad, works fine in my code and jtest.

The second one, an adapter hub for ps2 controllers, works fully with jtest.However under my code, its detected, and only one component axis change is detected, only right after the program starts.I add a few lines to dump a list of all the detected controllers, and I tried plugging the ps2 controller into player 2's slot to seeif I had the wrong controller. Again jtest works fine with it attached to player 1's port on the adapter hub.

The axis change that is detected doesnt seem to be related to the controller, because I get the same output with not controller plugged into the hub after starting the program. I am confused as to why jtest would find the output and not this code,

Not jtest, ControllerReadTest or ControllerEventTest, not just displaying the names etc, but actual values when the controller changes. I'm trying to figure out of JInput is not detecting them, or if it's the usage of JInput.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org