More gamepad deadzone tweakage

This commit is contained in:
Zwip-Zwap Zapony 2020-03-04 21:44:57 +01:00
parent df220aa2c2
commit bce6349b1d

View file

@ -1044,21 +1044,18 @@ static INT32 G_BasicDeadZoneCalculation(INT32 magnitude, fixed_t deadZone)
{
const INT32 jdeadzone = (JOYAXISRANGE * deadZone) / FRACUNIT;
INT32 deadzoneAppliedValue = 0;
if (jdeadzone > 0 && magnitude > jdeadzone)
{
if (deadZone >= FRACUNIT) // If the deadzone value is at 100%...
return JOYAXISRANGE; // ...return 100% input directly, to avoid dividing by 0
else
{
INT32 adjustedMagnitude = abs(magnitude);
if (jdeadzone >= JOYAXISRANGE && adjustedMagnitude >= JOYAXISRANGE) // If the deadzone and magnitude are both 100%...
return JOYAXISRANGE; // ...return 100% input directly, to avoid dividing by 0
else if (adjustedMagnitude > jdeadzone) // Otherwise, calculate how much the magnitude exceeds the deadzone
{
adjustedMagnitude = min(adjustedMagnitude, JOYAXISRANGE);
adjustedMagnitude -= jdeadzone;
deadzoneAppliedValue = (adjustedMagnitude * JOYAXISRANGE) / (JOYAXISRANGE - jdeadzone);
}
}
return deadzoneAppliedValue;
}