Quote:
|
Originally Posted by Joshua May
One thing we did was add in a "deadband" to the center of the joysticks, which has really helped. The code makes use of an absolute value function that we created. Today, we'll also be adding a ramping function to the joysticks just like what was described above, I can get you that code too if you need it.
Code:
#define DEADBAND 10
int abs(int x)
{
if (x >= 0)
return x;
else
return -x;
}
if (abs((p1_y - 127)) < DEADBAND)
p1_y = 127;
if (abs((p1_x - 127)) < DEADBAND)
p1_x = 127;
|
Here is something similar, only you do not need a seperate function... abs(p1_x) can be replaced with (p1_x && 0x7F), because the last bit is the sign, like so:
Code:
#define DEADBAND 10
if (((((signed int)p1_x-127) && 0x7f) < DEADBAND) p1_x=127;
if (((((signed int)p1_y-127) && 0x7f) < DEADBAND) p1_y=127;