From e85be2f5df3a24dfad50e02c16abb4757abb8141 Mon Sep 17 00:00:00 2001 From: Andreas Haas Date: Sat, 12 Aug 2017 20:45:56 +0200 Subject: [PATCH] InputDefault: Fix joypad actions when axis quickly changes direction. The fix (inserting a fake event so actions get released properly) was already there but disregarded the case when the hardware sends values in the [0;1] range. (cherry picked from commit 3bea3256f5def126b2b6d639ed70c4ddc3990344) --- main/input_default.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main/input_default.cpp b/main/input_default.cpp index 9e750cf297c..3fd2ca7ea3c 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -853,8 +853,14 @@ uint32_t InputDefault::joy_axis(uint32_t p_last_id, int p_device, int p_axis, co return p_last_id; } - if (ABS(joy.last_axis[p_axis]) > 0.5 && joy.last_axis[p_axis] * p_value.value < 0) { - //changed direction quickly, insert fake event to release pending inputmap actions + //when changing direction quickly, insert fake event to release pending inputmap actions + float last = joy.last_axis[p_axis]; + if (p_value.min == 0 && (last < 0.25 || last > 0.75) && (last - 0.5) * (p_value.value - 0.5) < 0) { + JoyAxis jx; + jx.min = p_value.min; + jx.value = p_value.value < 0.5 ? 0.6 : 0.4; + p_last_id = joy_axis(p_last_id, p_device, p_axis, jx); + } 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;