From df220aa2c2d209f7b253e958abc2cf0d63a8bca9 Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony Date: Wed, 4 Mar 2020 21:11:55 +0100 Subject: [PATCH] Hotfix for 100% deadzone returning 0 input It makes more sense for 100% deadzone to just make it so that you have to push the axis all the way to trigger it, rather than 100% deadzone resulting in no axis input ever happening... So, let's make it be the former way instead --- src/g_game.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 4db55329e..2cddaf8b8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1045,14 +1045,19 @@ static INT32 G_BasicDeadZoneCalculation(INT32 magnitude, fixed_t deadZone) const INT32 jdeadzone = (JOYAXISRANGE * deadZone) / FRACUNIT; INT32 deadzoneAppliedValue = 0; - if (jdeadzone > 0 && magnitude > jdeadzone && deadZone < FRACUNIT) + if (jdeadzone > 0 && magnitude > jdeadzone) { - INT32 adjustedMagnitude = abs(magnitude); - adjustedMagnitude = min(adjustedMagnitude, JOYAXISRANGE); + 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); + adjustedMagnitude = min(adjustedMagnitude, JOYAXISRANGE); - adjustedMagnitude -= jdeadzone; + adjustedMagnitude -= jdeadzone; - deadzoneAppliedValue = (adjustedMagnitude * JOYAXISRANGE) / (JOYAXISRANGE - jdeadzone); + deadzoneAppliedValue = (adjustedMagnitude * JOYAXISRANGE) / (JOYAXISRANGE - jdeadzone); + } } return deadzoneAppliedValue;