Skip to content

Commit

Permalink
Revert "Fix rounding error when computing the emulated stick values (#…
Browse files Browse the repository at this point in the history
…356)"

This reverts commit 4407176.
  • Loading branch information
NikhilNarayana authored Sep 1, 2022
1 parent 548c617 commit d38e7c9
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions Source/Core/Core/HW/GCPadEmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>(abs(x) * GCPadStatus::MAIN_STICK_RADIUS);
u8 stickYAbsoluteOffset = static_cast<u8>(abs(y) * GCPadStatus::MAIN_STICK_RADIUS);
pad.stickX = static_cast<u8>(GCPadStatus::MAIN_STICK_CENTER_X + sign(x) * stickXAbsoluteOffset);
pad.stickY = static_cast<u8>(GCPadStatus::MAIN_STICK_CENTER_Y + sign(y) * stickYAbsoluteOffset);
pad.stickX =
static_cast<u8>(GCPadStatus::MAIN_STICK_CENTER_X + (x * GCPadStatus::MAIN_STICK_RADIUS));
pad.stickY =
static_cast<u8>(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<u8>(abs(x) * GCPadStatus::C_STICK_RADIUS);
u8 substickYAbsoluteOffset = static_cast<u8>(abs(y) * GCPadStatus::C_STICK_RADIUS);
pad.substickX = static_cast<u8>(GCPadStatus::C_STICK_CENTER_X + sign(x) * substickXAbsoluteOffset);
pad.substickY = static_cast<u8>(GCPadStatus::C_STICK_CENTER_Y + sign(y) * substickYAbsoluteOffset);
pad.substickX =
static_cast<u8>(GCPadStatus::C_STICK_CENTER_X + (x * GCPadStatus::C_STICK_RADIUS));
pad.substickY =
static_cast<u8>(GCPadStatus::C_STICK_CENTER_Y + (y * GCPadStatus::C_STICK_RADIUS));

// triggers
m_triggers->GetState(&pad.button, trigger_bitmasks, triggers);
Expand Down

0 comments on commit d38e7c9

Please sign in to comment.