Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (590)
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 2011 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.

HTH

Endolf

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 »

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

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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

trollwarrior1 (33 views)
2014-11-22 12:13:56

xFryIx (73 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (40 views)
2014-11-12 21:09:33

kovacsa (65 views)
2014-11-07 19:57:14

TehJavaDev (70 views)
2014-11-03 22:04:50

BurntPizza (68 views)
2014-11-03 18:54:52

moogie (83 views)
2014-11-03 06:22:04

CopyableCougar4 (82 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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
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!