SFML community forums

Help => General => Topic started by: CyanPrime on March 31, 2011, 05:34:19 am

Title: How to test if the Joystick POV is at angle 90?
Post by: CyanPrime 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.
Title: How to test if the Joystick POV is at angle 90?
Post by: Laurent 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
Title: How to test if the Joystick POV is at angle 90?
Post by: CyanPrime 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.
Title: How to test if the Joystick POV is at angle 90?
Post by: Laurent on March 31, 2011, 09:24:58 am
You can print the different values that you test and see which one is wrong.