Discussion:
Analog stick values not smoothly changed
(too old to reply)
e***@gmail.com
2006-10-09 15:52:22 UTC
Permalink
Hi everyone,
I'm writing a game in c++ that's using directInput for gamepad support.
I want the right analog stick to be used as a unit circle (simply an x
& y vector between -1 and 1).
I am using the DIPROPRANGE strucy with SetProperty to set the minimum
and maximum values of the axes (lMin and lMax properties) as explained
in the msdn example here:
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/input/tuts/tut3/step4setjoystickbehavior.asp

Anyway, I now get a value between +/-60,000 on each axis - and then
divide it by 60,000 to get the unit circle values (so it basically
gives me a nice float value between -1 and 1).

Now, the problem is that the values change very drastically and tend to
snap to the 1/-1 values instead of giving me nice values in between.
What happens as a result is that when I move my analog stick in a
circular motion it basically jumps between 8 directions (top, top
right, right etc.)
instead of moving gradually between them.

I know this is probably something that would be very hard to trace
(could also be just cheap hardware), so I guess i'm just asking if
someone's exprienced something like this before?
Material on this subject on the net is very scarce...

Thanks!
Ehud.
n!
2006-10-24 15:49:22 UTC
Permalink
Post by e***@gmail.com
Anyway, I now get a value between +/-60,000 on each axis - and then
divide it by 60,000 to get the unit circle values (so it basically
gives me a nice float value between -1 and 1).
Now, the problem is that the values change very drastically and tend to
snap to the 1/-1 values instead of giving me nice values in between.
What happens as a result is that when I move my analog stick in a
circular motion it basically jumps between 8 directions (top, top
right, right etc.)
instead of moving gradually between them.
Can you show the snippit of conversion code? Are you sure you're dividing by
60000.0f (note the .0f) rather than an integer value? If you're dividing by
an integer value the result will be an integer and thus you will get only
0, -1 or 1 as the input value.

n!

Loading...