Commit 5c7f03ac authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #4695 from nanthony21/improve_deadband

Improve deadband
parents f0c7608d 279d560f
......@@ -339,13 +339,20 @@ float Joystick::_adjustRange(int value, Calibration_t calibration, bool withDead
axisLength = calibration.center - calibration.min;
}
float axisPercent;
if (withDeadbands) {
if (valueNormalized>calibration.deadband) valueNormalized-=calibration.deadband;
else if (valueNormalized<-calibration.deadband) valueNormalized+=calibration.deadband;
else valueNormalized = 0.f;
if (valueNormalized>calibration.deadband) {
axisPercent = (valueNormalized - calibration.deadband) / (axisLength - calibration.deadband);
} else if (valueNormalized<-calibration.deadband) {
axisPercent = (valueNormalized + calibration.deadband) / (axisLength - calibration.deadband);
} else {
axisPercent = 0.f;
}
}
else {
axisPercent = valueNormalized / axisLength;
}
float axisPercent = valueNormalized / axisLength;
float correctedValue = axisBasis * axisPercent;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment