From d38e7c936db599e1300d4aae0188bfc6569b5e59 Mon Sep 17 00:00:00 2001 From: Nikhil Narayana Date: Thu, 1 Sep 2022 13:46:15 -0700 Subject: [PATCH] Revert "Fix rounding error when computing the emulated stick values (#356)" This reverts commit 4407176f5ec5cfe814ccd167cd004ca106b9c0f6. --- Source/Core/Core/HW/GCPadEmu.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/Source/Core/Core/HW/GCPadEmu.cpp b/Source/Core/Core/HW/GCPadEmu.cpp index 85f0b18e03..223eec1743 100644 --- a/Source/Core/Core/HW/GCPadEmu.cpp +++ b/Source/Core/Core/HW/GCPadEmu.cpp @@ -126,20 +126,16 @@ GCPadStatus GCPad::GetInput() const // sticks m_main_stick->GetState(&x, &y); - // immediately compute and cast the absolute offsets to u8 to avoid rounding inconsistencies - // for example, when x or y is 0.5/-0.5, the absolute offset of that axis should always be 63, never 64 - u8 stickXAbsoluteOffset = static_cast(abs(x) * GCPadStatus::MAIN_STICK_RADIUS); - u8 stickYAbsoluteOffset = static_cast(abs(y) * GCPadStatus::MAIN_STICK_RADIUS); - pad.stickX = static_cast(GCPadStatus::MAIN_STICK_CENTER_X + sign(x) * stickXAbsoluteOffset); - pad.stickY = static_cast(GCPadStatus::MAIN_STICK_CENTER_Y + sign(y) * stickYAbsoluteOffset); + pad.stickX = + static_cast(GCPadStatus::MAIN_STICK_CENTER_X + (x * GCPadStatus::MAIN_STICK_RADIUS)); + pad.stickY = + static_cast(GCPadStatus::MAIN_STICK_CENTER_Y + (y * GCPadStatus::MAIN_STICK_RADIUS)); m_c_stick->GetState(&x, &y); - // immediately compute and cast the absolute offsets to u8 to avoid rounding inconsistencies - // for example, when x or y is 0.5/-0.5, the absolute offset of that axis should always be 63, never 64 - u8 substickXAbsoluteOffset = static_cast(abs(x) * GCPadStatus::C_STICK_RADIUS); - u8 substickYAbsoluteOffset = static_cast(abs(y) * GCPadStatus::C_STICK_RADIUS); - pad.substickX = static_cast(GCPadStatus::C_STICK_CENTER_X + sign(x) * substickXAbsoluteOffset); - pad.substickY = static_cast(GCPadStatus::C_STICK_CENTER_Y + sign(y) * substickYAbsoluteOffset); + pad.substickX = + static_cast(GCPadStatus::C_STICK_CENTER_X + (x * GCPadStatus::C_STICK_RADIUS)); + pad.substickY = + static_cast(GCPadStatus::C_STICK_CENTER_Y + (y * GCPadStatus::C_STICK_RADIUS)); // triggers m_triggers->GetState(&pad.button, trigger_bitmasks, triggers);