From 5f1ae5eac208101e62da6361be21265f06d3a3b8 Mon Sep 17 00:00:00 2001 From: Ariel Manzur Date: Sun, 20 Dec 2015 11:33:29 -0300 Subject: fix debouncing in axis buttons --- main/input_default.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'main/input_default.cpp') diff --git a/main/input_default.cpp b/main/input_default.cpp index c90d456864..4141102bf6 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -596,7 +596,12 @@ uint32_t InputDefault::joy_axis(uint32_t p_last_id, int p_device, int p_axis, co if (map.type == TYPE_BUTTON) { float deadzone = p_value.min == 0 ? 0.5f : 0.0f; - return _button_event(p_last_id, p_device, map.index, p_value.value > deadzone ? true : false); + bool pressed = p_value.value > deadzone ? true : false; + if (pressed == joy_buttons_pressed.has(_combine_device(map.index,p_device))) { + // button already pressed or released, this is an axis bounce value + return p_last_id; + }; + return _button_event(p_last_id, p_device, map.index, pressed); }; if (map.type == TYPE_AXIS) { -- cgit v1.2.3