SFML community forums

Help => Window => Topic started by: charisma_ts on November 15, 2017, 10:12:55 pm

Title: Problem with Joystick Axis
Post by: charisma_ts on November 15, 2017, 10:12:55 pm
Hi I am just beginning with SFML. I try to detect axis position for x and y in joystick. I do not press any button but the value x and y axis are not equal to 0. What could make this happen?
I attached my screenshot of the program.
Title: Re: Problem with Joystick Axis
Post by: Laurent on November 15, 2017, 10:24:01 pm
The stick is analog, you can't expect to get an exact zero for its position. Calibration and dead zone may help.
Title: Re: Problem with Joystick Axis
Post by: charisma_ts on November 15, 2017, 10:29:09 pm
I want only to detect movement when the analog button is moved. How can I do that?
Title: Re: Problem with Joystick Axis
Post by: achpile on November 16, 2017, 06:16:39 am
if (sf::Joystick::getAxisPosition(joyID, joyAxis) >  GAMEPAD_THRESHOLD)
Title: Re: Problem with Joystick Axis
Post by: charisma_ts on November 16, 2017, 07:14:49 am
if (sf::Joystick::getAxisPosition(joyID, joyAxis) >  GAMEPAD_THRESHOLD)
What is the value of GAMEPAD_THRESHOLD?
Title: Re: Problem with Joystick Axis
Post by: Laurent on November 16, 2017, 08:03:52 am
It's just an example, to show you the idea. Use whatever works best for you.
Title: Re: Problem with Joystick Axis
Post by: achpile on November 16, 2017, 08:37:32 am
if (sf::Joystick::getAxisPosition(joyID, joyAxis) >  GAMEPAD_THRESHOLD)
What is the value of GAMEPAD_THRESHOLD?

i use 50.0f
Title: Re: Problem with Joystick Axis
Post by: achpile on November 16, 2017, 10:31:03 am
Btw, your attachment name is not cool at all