View Single Post
  #6   Spotlight this post!  
Unread 31-01-2004, 21:11
Vladimir Vladimir is offline
the Impaler
#1064 (Wild Beast)
Team Role: Programmer
 
Join Date: Mar 2003
Location: South Milwaukee, WI
Posts: 6
Vladimir is an unknown quantity at this point
Send a message via ICQ to Vladimir Send a message via AIM to Vladimir Send a message via Yahoo to Vladimir
Re: Desensitizing Joysticks

Here's how I'd do it... first psuedocode for understanding:

Code:
x1 = p1_x; // get an axis, store it in temp variable
x1 = x1-127; // make 0 = neutral
x2 = abs(x1); // find magnitude from center
x3 = (x2/127) * x1; // create harshly curved value
x4 = (x3+x1)/2; // average curve with real to lessen curve
p1_x = x4+127; // restore neutral to 127 and replace value
then this should actually work and is a lot more concise... it assumes you have an abs( function available, either include a math library or make your own with something like if (x<0) x*=-1; -- I haven't tested this so don't run me over with your robot if it doesn't work off the first try, there may be some casting or something required with this compiler, but it'll at least be close.

Code:
p1_x-=127;
p1_x = ((p1_x*abs(p1_x)/127)+p1_x)/2+127;
Hope this helps some!

-Sean
__________________
B.R.E.W. (Better Robots Engineered Wisely)