Polling two components simultaneously?

After solving the JAR/dll problem in my last (and first :)) thread, I’m moving on…

I’m using a Logitech USB gamepad, and its left analog stick to move a character left/right. In a method for processing poll data I check event.getComponent().getIdentifier() to find out which component was polled. In the case above I look for Component.Identifier.Axis.X (left analog is polled) and then call methods to update character position and animation. However, more often than not, the event registered is coming from Component.Identifier.Axis.Y instead of X; for example when polling max to the left (X axis) its hard to avoid polling some small value on the Y axis aswell. I would be fine if BOTH X and Y values were registered, but it seems one is replacing the other? ???

I could look for that small Y axis value too, but this gets confusing when the character is moving to the right (max right on left analog); if only ONE component at a time is registered, my character behaves unexpectedly to say the least 8)

In comparison: when using the older JInput version (with dxinput.dll; see my JAR problem thread…) with the Axis class, I had no problem with moving characters or controlling their animations. So I was aaalmost ready…then I had to do it all over again, to make it work running my app as a JAR with this new version ;D Well well.

I need some advice; are there other components (than X / Y) to use when checking the analog sticks?

Thanks for listening.

I would love some input on this matter :stuck_out_tongue:

Is it for example possible (on a gamepad) to press a button while polling right/left on any of the analog sticks? This I was able to do with the older version (that included Axis class), worked great. I hope I can get that functionality from the latest version aswell.

Sorry for being impatient but I’m dying to finish the job. Have a nice evening all.

/ Anders

You will always get a small variation on an axis in my experience. Are you saying that you can poll the controller, then read the getPollData for both the X and Y, but only one, is registering?, or are you using the new event interface?, I’m confused as you mention polling, but also using the new event system.

Either way it should be perfectly possible to have two axis or more move at once. Check the Webstart demo out with your device and you should see it work.

HTH

Endolf

I’m using the Event class the way it is described in “Getting started…”. What I meant was this:

If I push the, say left, analog stick max to the left and keep it there, I would expect to get -1.0 on Identifier.Axis.X. But more often I instead get for example -0.11035 on Identifier.Axis.Y, replacing(?) the registered X value (at least it seems I can no longer check its value…). Of course it’s fully logical that the stick is not held clean to the left, with no value (=0.0) on the Y axis. But I somehow fail to check both those values (X and Y) only one at a time, thus making it very difficult to manage which way my characters should move . That’s the reason I asked if polling two components (Axix.X and Axis.Y = 2 components? :)) at the same time is possible. I admit I have not yet given it enough time; still a bit frustrated over my JAR/dll issue hehe…

Haven’t got a grip of EventQueue either yet. Good to hear it’s fully possible, I can sleep good tonight then.

/ Anders

Hi

There should be multiple events on the event queue, you should be able to just keep reading it till there are none left on it. The old value of X should still be attainable by calling getPollData on the X axis component too.

I’m away for the weekend again, I should be back reading forums on monday. Let us know how it goes.

Cheers

Endolf

Aha! Then I know what to do, good news thanks.

/ Anders