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

Author Topic: How to test if the Joystick POV is at angle 90?  (Read 1985 times)

0 Members and 1 Guest are viewing this topic.

CyanPrime

  • Newbie
  • *
  • Posts: 18
    • View Profile
How to test if the Joystick POV is at angle 90?
« on: March 31, 2011, 05:34:19 am »
How would I do that?
I tried

Code: [Select]

if((Event.Type == sf::Event::JoyMoved) && (Event.JoyMove.Axis == 0) && (Event.JoyMove.Position == 90))


But that didn't work.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
How to test if the Joystick POV is at angle 90?
« Reply #1 on: March 31, 2011, 07:51:21 am »
- you forget to test the joystick index
- POV is sf::Joy::AxisPOV, not 0
- axes positions are float, so they could be 89.9999 or 90.00001 but never 90 (for example), use a small range instead of strict equality
Laurent Gomila - SFML developer

CyanPrime

  • Newbie
  • *
  • Posts: 18
    • View Profile
How to test if the Joystick POV is at angle 90?
« Reply #2 on: March 31, 2011, 09:03:14 am »
Code: [Select]

if((Event.Type == sf::Event::JoyMoved) && (Event.JoyMove.Axis == sf::Joy::AxisPOV) && (Event.JoyMove.Position >= 80 && Event.JoyMove.Position <= 100)){
                Sound.Play();
                cout << Event.JoyMove.Position <<endl;
            }


Still not working. tried on 2 controllers.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
How to test if the Joystick POV is at angle 90?
« Reply #3 on: March 31, 2011, 09:24:58 am »
You can print the different values that you test and see which one is wrong.
Laurent Gomila - SFML developer

 

anything