Jump to content

  • Log In with Google      Sign In   
  • Create Account


Joystick sign conventions


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 aerojockey   Members   -  Reputation: 172

Like
1Likes
Like

Posted 15 February 2013 - 02:12 AM

Quick question--it's so hard to Google for answers like this one: Is the sign convention for PC joysticks or D-pads something I can generally rely on?  It seems that the horizontal axis is positive right, and the vertical axis positive down, and the horizontal axis has the lower axis number.  If that's true for all joysticks, then all I'd have to do to detect the correct axis mappings is to ask the user to move the joystick around the perimeter a few times.  If this is inconsistent then I'd have to map the horizontal and vertical axes separately.  Thanks.



Sponsor:

#2 frob   Moderators   -  Reputation: 20462

Like
4Likes
Like

Posted 15 February 2013 - 03:03 AM

Generally yes.

It is always possible that somebody is using an obscure joystick from the 1970s with bad drivers and the axis values are reversed, but that is not normal.

Some players like the option of reversing up/down and left/right. You might decide to include the options as a convenience, not because of a hardware issue.

Calibrations are typically done by the system, and they also generally include a dead zone so you don't need to. They are nice options to provide to your users if you'd like, but less necessary than they were two decades ago.
Check out my personal indie blog at bryanwagstaff.com.

#3 Wyrframe   Members   -  Reputation: 731

Like
0Likes
Like

Posted 15 February 2013 - 03:18 AM

Under Windows, most gamepad interfaces (such as what DirectX and LWJGL expose) provide a way to query the names of each axis and sometimes button, so even if you're not sure about the numbering convention, you can check the human-readable string names for X+, Y-, et cetera.

 

This is particularly helpful if someone is using an XBox 360 controller. I discovered (quite to my consternation) that up until a year or so ago, it sometimes had the left joystick X/Y axis numbered 1/0, and the right joystick X/Y numbered 2/3. More recently, I've found it's consistently numbered the same as my other dual-stick gamepads (LX,LY,RX,RY numbered 0,1,2,3 in that order).


(( This email has been quad-ROT13 encrypted. Reading it violates the DMCA. ))
(( 我说很少的汉语,还我的语法平庸, but at least I'm UNICODE-compliant. ))


#4 aerojockey   Members   -  Reputation: 172

Like
0Likes
Like

Posted 15 February 2013 - 10:24 AM

It is always possible that somebody is using an obscure joystick from the 1970s with bad drivers and the axis values are reversed, but that is not normal.

 

For those people I have my "Advanced Controls Setup" option; namely editing the control settings file with a text editor.  :)  Thanks for the advice.



#5 Sik_the_hedgehog   Crossbones+   -  Reputation: 1636

Like
0Likes
Like

Posted 15 February 2013 - 12:06 PM

Yeah, if you find a joystick that doesn't go by those conventions you can safely assume the user already knows and already had problem with the majority of games out there. Allowing remapping of axes is still a good idea (just like allowing remapping of buttons), but where needed you can pretty much assume that's the case for the first two axes.

 

The second set of two axes (right stick) is a different issue. So far I think pretty much about all controllers in use these days would map axes 2 and 3 to those, but not all controllers are designed to gimmick the 360 or PS3 ones. In particular, some controllers with different layouts are bound to lack the second stick (e.g. there are some controllers around that gimmick the Saturn controllers).

 

And the D-pad is usually mapped to the hat on controllers that have sticks. Take this into account too.


Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

#6 aerojockey   Members   -  Reputation: 172

Like
0Likes
Like

Posted 15 February 2013 - 03:30 PM

And the D-pad is usually mapped to the hat on controllers that have sticks. Take this into account too.

 

I actually just noticed this.  The game is multiplatform, and the D-Pad is considered a joystick on Linux but a D-pad on Windows.  Furthermore, the D-pad sign convention is positve up.  Nice of them to keep things simple.  Since the distinction is irrelevant to my game I'm going to make hats into honorary joysticks.



#7 Sik_the_hedgehog   Crossbones+   -  Reputation: 1636

Like
0Likes
Like

Posted 15 February 2013 - 03:38 PM

I think Linux doesn't understand the concept of hats at all which is why hats get converted to axes. At least if I recall correctly the joystick API only returned axes and buttons.


Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS