summaryrefslogtreecommitdiff
path: root/main/input_default.cpp
diff options
context:
space:
mode:
authorAriel Manzur <ariel@godotengine.org>2015-12-20 11:33:29 -0300
committerAriel Manzur <ariel@godotengine.org>2015-12-20 11:33:29 -0300
commit5f1ae5eac208101e62da6361be21265f06d3a3b8 (patch)
tree84edc4cddfc20be34aba6cd2fe10b7f6a10513fa /main/input_default.cpp
parent33e5c3181d2b74e83e8f95570502c63178876be1 (diff)
fix debouncing in axis buttons
Diffstat (limited to 'main/input_default.cpp')
-rw-r--r--main/input_default.cpp7
1 files changed, 6 insertions, 1 deletions
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) {