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

Author Topic: Problem with Joystick Axis  (Read 2455 times)

0 Members and 1 Guest are viewing this topic.

charisma_ts

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Problem with Joystick Axis
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Problem with Joystick Axis
« Reply #1 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.
Laurent Gomila - SFML developer

charisma_ts

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Problem with Joystick Axis
« Reply #2 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?

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
Re: Problem with Joystick Axis
« Reply #3 on: November 16, 2017, 06:16:39 am »
if (sf::Joystick::getAxisPosition(joyID, joyAxis) >  GAMEPAD_THRESHOLD)

charisma_ts

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Problem with Joystick Axis
« Reply #4 on: November 16, 2017, 07:14:49 am »
if (sf::Joystick::getAxisPosition(joyID, joyAxis) >  GAMEPAD_THRESHOLD)
What is the value of GAMEPAD_THRESHOLD?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Problem with Joystick Axis
« Reply #5 on: November 16, 2017, 08:03:52 am »
It's just an example, to show you the idea. Use whatever works best for you.
Laurent Gomila - SFML developer

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
Re: Problem with Joystick Axis
« Reply #6 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

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
Re: Problem with Joystick Axis
« Reply #7 on: November 16, 2017, 10:31:03 am »
Btw, your attachment name is not cool at all