Add a joystick deadzone in the code. For example:
Code:
#define JOY_DEADZONE 10
if (xJ_raw < 127-JOY_DEADZONE)
{
xJ_raw = xJ_raw + JOY_DEADZONE;
}
else if (xJ_raw > 127+JOY_DEADZONE)
{
xJ_raw = xJ_raw - JOY_DEADZONE;
}
else
{
xJ_raw = 0;
}
if (yJ_raw < 127-JOY_DEADZONE)
{
yJ_raw = yJ_raw + JOY_DEADZONE;
}
else if (yJ_raw > 127+JOY_DEADZONE)
{
yJ_raw = yJ_raw - JOY_DEADZONE;
}
else
{
yJ_raw = 0;
}
Of course, the above assumes that the joystick is biased at 127 and you are using unsigned variables for your joystick axes.