From ea89e73a88a0f61b8556245ef45f110515e3836e Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Thu, 17 Dec 2020 14:36:57 +0100 Subject: [PATCH] Better gamepad axis event injection. In the core input handling code we have checks to make sure that if axis rapidly change sign we inject mid-points to release any pending inputmap action. The function though, did not correctly insert the mid-point causing dpads mapped to an axis that behaves like tri-state buttons (-1,0,1) to not be released correctly. This commit fixes that by including in the check the case where the axis swtiches from abs(1) to 0. --- main/input_default.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/input_default.cpp b/main/input_default.cpp index f54b1eee8f4..a36445e33b5 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -783,10 +783,10 @@ void InputDefault::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) { jx.min = p_value.min; jx.value = p_value.value < 0.5 ? 0.6 : 0.4; joy_axis(p_device, p_axis, jx); - } else if (ABS(last) > 0.5 && last * p_value.value < 0) { + } else if (ABS(last) > 0.5 && last * p_value.value <= 0) { JoyAxis jx; jx.min = p_value.min; - jx.value = p_value.value < 0 ? 0.1 : -0.1; + jx.value = last > 0 ? 0.1 : -0.1; joy_axis(p_device, p_axis, jx); }