Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (604)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (654)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Polling two components simultaneously?  (Read 2198 times)
0 Members and 1 Guest are viewing this topic.
Offline wrAthchild

Senior Newbie

« Posted 2008-07-14 10:28:38 »

After solving the JAR/dll problem in my last (and first Smiley) 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?  Huh

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  Cool

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 Grin Well well.

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

Thanks for listening.
Offline wrAthchild

Senior Newbie

« Reply #1 - Posted 2008-07-14 19:11:36 »

I would love some input on this matter  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
Offline endolf

JGO Coder

Medals: 7
Exp: 15 years

Current project release date: sometime in 3003

« Reply #2 - Posted 2008-07-17 21:57:02 »

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.



Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline wrAthchild

Senior Newbie

« Reply #3 - Posted 2008-07-18 00:58:18 »

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? Smiley) 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
Offline endolf

JGO Coder

Medals: 7
Exp: 15 years

Current project release date: sometime in 3003

« Reply #4 - Posted 2008-07-18 06:24:59 »


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.



Offline wrAthchild

Senior Newbie

« Reply #5 - Posted 2008-07-18 16:44:50 »

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

/ Anders
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

bilznatch (20 views)
2015-08-04 11:03:17

SHC (39 views)
2015-08-01 03:58:20

Jesse (24 views)
2015-07-29 04:35:27

Riven (45 views)
2015-07-27 16:38:00

Riven (25 views)
2015-07-27 15:35:20

Riven (27 views)
2015-07-27 12:26:13

Riven (18 views)
2015-07-27 12:23:39

BurntPizza (41 views)
2015-07-25 00:14:37

BurntPizza (50 views)
2015-07-24 22:06:39

BurntPizza (33 views)
2015-07-24 06:06:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!