From 7e89dc432c8781114f4855d6d2f24675a5a1ce5f Mon Sep 17 00:00:00 2001 From: Gilles Roudiere Date: Wed, 18 Apr 2018 21:38:52 +0200 Subject: [PATCH] Fixes left/up axis not mappable as actions --- core/os/input_event.cpp | 4 ++-- editor/project_settings_editor.cpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index bdb61cbfd9b..5003be77ab3 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -656,10 +656,10 @@ bool InputEventJoypadMotion::action_match(const Ref &p_event, bool * if (jm.is_null()) return false; - bool match = (axis == jm->axis && ((axis_value < 0) == (jm->axis_value < 0) || jm->axis_value == 0)); + bool match = (axis == jm->axis && (((axis_value < 0) == (jm->axis_value < 0)) || jm->axis_value == 0)); if (match) { if (p_pressed != NULL) - *p_pressed = Math::abs(jm->get_axis_value() >= p_deadzone); + *p_pressed = Math::abs(jm->get_axis_value()) >= p_deadzone; if (p_strength != NULL) *p_strength = (*p_pressed) ? Math::inverse_lerp(p_deadzone, 1.0f, Math::abs(jm->get_axis_value())) : 0.0f; } diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 8ae573baef1..3127644a81f 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -234,6 +234,7 @@ void ProjectSettingsEditor::_device_input_add() { Ref jm; jm.instance(); jm->set_axis(device_index->get_selected() >> 1); + jm->set_axis_value(device_index->get_selected() & 1 ? 1 : -1); jm->set_device(_get_current_device()); bool should_update_event = true; @@ -243,7 +244,7 @@ void ProjectSettingsEditor::_device_input_add() { Ref aie = events[i]; if (aie.is_null()) continue; - if (aie->get_device() == jm->get_device() && aie->get_axis() == jm->get_axis()) { + if (aie->get_device() == jm->get_device() && aie->get_axis() == jm->get_axis() && aie->get_axis_value() == jm->get_axis_value()) { should_update_event = false; break; }