0

I'm trying to get the value from the thumbstick with XInput, but the values are weird and I don't know how to handle them correctly.

How do I calculate so that I can read the values between -1 (thumbstick to the left/up) +1 (thumbstick to the right/down)

Similiar to XNA's Gamepad.GetState().ThumbSticks.Left.X ( -1 = to the left, +1 = to the right ).

Any ideas?

Deukalion
  • 2,516
  • 9
  • 32
  • 50

1 Answers1

3

According to the documentation, _XINPUT_GAMEPAD.sThumbLX is a SHORT whose value lies between -32768 and 32767. If you want to convert that to a range of [-1, 1), divide the value by 32768.0.

Kevin
  • 74,910
  • 12
  • 133
  • 166
  • No, that'll produce a guaranteed value of zero due to integer division. Divide by 32768.0 intstead. – phonetagger Jan 31 '13 at 19:37
  • @phonetagger, good catch on the integer division problem. edited. – Kevin Jan 31 '13 at 19:39
  • I had some odd results first with this, but I guess it was a simple calculation failure that resultet in weird numbers cause I got a ten digit from calculating those without a delimiter... – Deukalion Jan 31 '13 at 20:28