diff --git a/core/input/input.cpp b/core/input/input.cpp index e89c71d7620..d96efb4a9e7 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -1075,7 +1075,8 @@ void Input::joy_axis(int p_device, JoyAxis p_axis, float p_value) { return; } - JoyEvent map = _get_mapped_axis_event(map_db[joy.mapping], p_axis, p_value); + JoyAxisRange range; + JoyEvent map = _get_mapped_axis_event(map_db[joy.mapping], p_axis, p_value, range); if (map.type == TYPE_BUTTON) { bool pressed = map.value > 0.5; @@ -1115,7 +1116,7 @@ void Input::joy_axis(int p_device, JoyAxis p_axis, float p_value) { if (map.type == TYPE_AXIS) { JoyAxis axis = JoyAxis(map.index); float value = map.value; - if (axis == JoyAxis::TRIGGER_LEFT || axis == JoyAxis::TRIGGER_RIGHT) { + if (range == FULL_AXIS && (axis == JoyAxis::TRIGGER_LEFT || axis == JoyAxis::TRIGGER_RIGHT)) { // Convert to a value between 0.0f and 1.0f. value = 0.5f + value / 2.0f; } @@ -1221,7 +1222,7 @@ Input::JoyEvent Input::_get_mapped_button_event(const JoyDeviceMapping &mapping, return event; } -Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, JoyAxis p_axis, float p_value) { +Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, JoyAxis p_axis, float p_value, JoyAxisRange &r_range) { JoyEvent event; for (int i = 0; i < mapping.bindings.size(); i++) { @@ -1267,6 +1268,7 @@ Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, J case TYPE_AXIS: event.index = (int)binding.output.axis.axis; event.value = value; + r_range = binding.output.axis.range; if (binding.output.axis.range != binding.input.axis.range) { switch (binding.output.axis.range) { case POSITIVE_HALF_AXIS: diff --git a/core/input/input.h b/core/input/input.h index 26466bdeade..8ef4692c690 100644 --- a/core/input/input.h +++ b/core/input/input.h @@ -220,7 +220,7 @@ private: Vector map_db; JoyEvent _get_mapped_button_event(const JoyDeviceMapping &mapping, JoyButton p_button); - JoyEvent _get_mapped_axis_event(const JoyDeviceMapping &mapping, JoyAxis p_axis, float p_value); + JoyEvent _get_mapped_axis_event(const JoyDeviceMapping &mapping, JoyAxis p_axis, float p_value, JoyAxisRange &r_range); void _get_mapped_hat_events(const JoyDeviceMapping &mapping, HatDir p_hat, JoyEvent r_events[(size_t)HatDir::MAX]); JoyButton _get_output_button(String output); JoyAxis _get_output_axis(String output);