Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Joystick Axes - Question  (Read 4491 times)

0 Members and 1 Guest are viewing this topic.

Jamin Grey

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Of Stranger Flames
Joystick Axes - Question
« on: February 16, 2012, 03:28:33 am »
I'm using SFML 1.6, on Win7 32bit.

SFML 1.6 has constants for these Joystick axes:
X,Y,Z,R,U,V, and POV.

SFML 2 has the same axes, but replaces POV with PovX and PovY.

My questions are:
(Barring any really uncommon gamepads that do everything differently and illogically just to be contrary - only focusing on very common gamepads that my users are likely to have)

1) Is 'X' always horizontal on a joystick, 'Y' always vertical, 'Z' always horizontal, 'R' always vertical, and so on? Or do I have no (in-general) guarantee of their real-world orientation on the controller?

2) Is 'POV' a different way that some gamepads internally handle joysticks, or is it an entirely different (from the gamepad user's perspective) type of control? Basically, is POV still a joystick on a gamepad, or is it a different type of control on a gamepad?

3) What's the reasoning of putting the joystick position range between -100.0f and 100.0f? Why not -1.0 to 1.0? Is that how Windows handles it, or how gamepads normally give the values, or does SFML translate it to that? Why's it like that? Just curious. =)

4) Is there any way to know that axis 'A' is paired with axis 'B'? For example, can I be reasonably certain that if AxisX and AxisY exist, they are on the same joystick (even if I don't know for which is horizontal and which is vertical)?

5) How can I detect if two axes are on the same gamepad joystick or if they belong to separate joysticks on the same gamepad? Can I get enumerate the joysticks on the gamepad, and detect if an axis belongs to it?
Of Stranger Flames - My work-in-progress para-historical (and classically-inspired) 2D rpg.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Joystick Axes - Question
« Reply #1 on: February 16, 2012, 08:16:51 am »
Quote
1) Is 'X' always horizontal on a joystick, 'Y' always vertical, 'Z' always horizontal, 'R' always vertical, and so on? Or do I have no (in-general) guarantee of their real-world orientation on the controller?

Yes for X and Y. Don't know about Z and R.

Quote
2) Is 'POV' a different way that some gamepads internally handle joysticks, or is it an entirely different (from the gamepad user's perspective) type of control? Basically, is POV still a joystick on a gamepad, or is it a different type of control on a gamepad?

POV is usually something that can be rotated 360 degrees. On gamepads, I guess it's just a regular joystick.

Quote
3) What's the reasoning of putting the joystick position range between -100.0f and 100.0f? Why not -1.0 to 1.0? Is that how Windows handles it, or how gamepads normally give the values, or does SFML translate it to that? Why's it like that? Just curious. =)

It's an arbitrary choice, there's no strong reason behind it.

Quote
4) Is there any way to know that axis 'A' is paired with axis 'B'? For example, can I be reasonably certain that if AxisX and AxisY exist, they are on the same joystick (even if I don't know for which is horizontal and which is vertical)?

Nop, each joystick driver is free to assign logical axes to whatever physical axes they want, and there's no way to know this mapping -- unless testing first.

Quote
5) How can I detect if two axes are on the same gamepad joystick or if they belong to separate joysticks on the same gamepad? Can I get enumerate the joysticks on the gamepad, and detect if an axis belongs to it?

Isn't it the same question as 4)?
Laurent Gomila - SFML developer

Jamin Grey

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Of Stranger Flames
Joystick Axes - Question
« Reply #2 on: February 16, 2012, 06:56:20 pm »
Uh, yes, question 4 and 5 are the same. I came back and editted my post several times to add questions, but it was late and I was sleepy. =)

Thanks for answer my questions.

Quote
POV is usually something that can be rotated 360 degrees. On gamepads, I guess it's just a regular joystick.

So some gamepads handle a joystick as a value between 0 and 360, and some handle a joystick as two separate values one for horizontal, and one for vertical? So I either get one or the other for a single joystick, but not both?
Of Stranger Flames - My work-in-progress para-historical (and classically-inspired) 2D rpg.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Joystick Axes - Question
« Reply #3 on: February 16, 2012, 07:41:43 pm »
Quote
So some gamepads handle a joystick as a value between 0 and 360, and some handle a joystick as two separate values one for horizontal, and one for vertical? So I either get one or the other for a single joystick, but not both?

It doesn't really make any difference, I think it's the OS that transforms the values of both POV axes to an angle, or not -- Windows does it, Linux doesn't.
And since SFML exposes the POV as two separate axes, it really doesn't make any difference. It's just two different axes.
Laurent Gomila - SFML developer

Jamin Grey

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Of Stranger Flames
Joystick Axes - Question
« Reply #4 on: February 17, 2012, 05:28:59 am »
What confuses me, is SFML makes X,Y,Z,R,U,V axis available, and the POV 360 or (in SFML 2), the two PovX and PovY.

So... is POV (SFML 1.6) a separate joystick from AxisX and AxisY, or is it the same joystick as AxisX and AxisY, but just reinterpreted data?

I mean, let's suppose I have a gamepad with two joysticks on it - one for the left thumb and one for the right. So one of the joysticks is AxisX and AxisY. Another joystick is maybe AxisZ and AxisR. Is POV also sent only when I move the first joystick? Or when I move either joystick? Or is it a possiblility, depending on the gamepad, that I get POV instead of AxisX and AxisY?
Of Stranger Flames - My work-in-progress para-historical (and classically-inspired) 2D rpg.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Joystick Axes - Question
« Reply #5 on: February 17, 2012, 08:06:39 am »
PovX/PovY is a separate pair of axes, it is not an alias for another pair.
Laurent Gomila - SFML developer

 

anything