0
\$\begingroup\$

When querying XInput for the status of the thumb sticks, it doesn't return 0 when the sticks are not in a moved position.

Instead, it returns an arbitrary value which is a small portion of the value the stick was moved to before returning to idle state. Every other button and trigger on the controller correctly returns 0 when not engaged.

I poll the controller in the main loop with Controller.GetState, so the state of the device should always be current.

The XInput documentation asserts that a value of 0 is to be expected when the sticks are not in use.

I've worked around the problem by moving the player only if the stick is moved by 10% or more of it's possible movement limit, but I'd like more precise stick control.

Any assistance would be gratefully received.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

This sounds like a fairly normal issue. Analog sticks are notoriously imprecise, and develop a drift over their lifetimes. (If you've ever had such a well-used gamepad that when you boot up some games, your character has a bit of a lean to one side or even moves slightly when the stick is "idle", that's this effect).

Games typically compensate for this by processing the raw stick value to apply what's called a "deadzone" — a cutoff value below which small drifts are considered zero. The same can be applied at the high end, to ensure the distance from the center caps out at exactly one in every direction, rather than having a bias in some direction.

Searching for "analog deadzone" will let you find different strategies for applying this, such as this previous answer.

The XInput documentation itself calls this out as something to be aware of and gives guidance for how to implement deadzones in your game code:

In order for users to have a consistent gameplay experience, your game must implement dead zone correctly. The dead zone is "movement" values reported by the controller even when the analog thumbsticks are untouched and centered. There is also a dead zone for the 2 analog triggers.

Note

Games that use XInput that do not filter dead zone at all will experience poor gameplay. Please note that some controllers are more sensitive than others, thus the dead zone may vary from unit to unit. It is recommended that you test your games with several Xbox controllers on different systems.

Applications should use "dead zones" on analog inputs (triggers, sticks) to indicate when a movement has been made sufficiently on the stick or trigger to be considered valid.

Your application should check for dead zones and respond appopriately

\$\endgroup\$
3
  • \$\begingroup\$ +1 and worth noting that the Xinput docs even include advice for deadzone handling: docs.microsoft.com/en-us/windows/win32/xinput/… \$\endgroup\$ Mar 27 at 11:33
  • 1
    \$\begingroup\$ Haha, I was just adding that quote as your comment came in..😆 \$\endgroup\$
    – DMGregory
    Mar 27 at 11:37
  • \$\begingroup\$ @DMGregory I had a feeling that the analogue nature of the sticks was the reason behind this behaviour, but neglected to read just a /little/ further into the documentation -- particularly the part you quoted. My apologies for neglecting to do so. Instead, I just read the following sentence from the docs: "Each of the thumbstick axis members is a signed value between -32768 and 32767 describing the position of the thumbstick. A value of 0 is centered." and just left it at that. Thank you for your detailed reply. +1 \$\endgroup\$
    – ROGRat
    Mar 27 at 12:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .