From a84992c3954b8421c2cd440e882530defd0055d1 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 3 Jul 2021 15:04:33 +1000 Subject: [PATCH] NeGcon: Use 0..1 range instead of -1..1 for I/II/L --- src/core/negcon.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/negcon.cpp b/src/core/negcon.cpp index 4a9846698..ff8fd515d 100644 --- a/src/core/negcon.cpp +++ b/src/core/negcon.cpp @@ -53,9 +53,10 @@ float NeGcon::GetAxisState(s32 axis_code) const if (axis_code < 0 || axis_code >= static_cast(Axis::Count)) return 0.0f; - // 0..255 -> -1..1 - const float value = (((static_cast(m_axis_state[static_cast(axis_code)]) / 255.0f) * 2.0f) - 1.0f); - return std::clamp(value, -1.0f, 1.0f); + if (axis_code == static_cast(Axis::Steering)) + return (((static_cast(m_axis_state[static_cast(Axis::Steering)]) / 255.0f) * 2.0f) - 1.0f); + else + return (static_cast(m_axis_state[static_cast(axis_code)]) / 255.0f); } void NeGcon::SetAxisState(s32 axis_code, float value) @@ -78,7 +79,7 @@ void NeGcon::SetAxisState(s32 axis_code, float value) } // I, II, L: -1..1 -> 0..255 - const u8 u8_value = static_cast(std::clamp(((value + 1.0f) / 2.0f) * 255.0f, 0.0f, 255.0f)); + const u8 u8_value = static_cast(std::clamp(value * 255.0f, 0.0f, 255.0f)); SetAxisState(static_cast(axis_code), u8_value); }