1
0
mirror of https://github.com/cathery/sys-con.git synced 2024-07-03 02:18:43 +00:00

Clamp joystick values when dpad and lstick are swapped

They will now fit inside the circle like regular sticks
This commit is contained in:
cathery 2020-01-24 01:39:36 +03:00
parent c7c5c42ae8
commit bbed9abf55

View File

@ -136,6 +136,15 @@ void SwitchHDLHandler::FillHdlState(const NormalizedButtonData &data)
daxis_y += data.buttons[14] ? -1.0f : 0.0f; //DDOWN
daxis_x += data.buttons[15] ? -1.0f : 0.0f; //DLEFT
float real_magnitude = std::sqrt(daxis_x * daxis_x + daxis_y * daxis_y);
float clipped_magnitude = std::min(1.0f, real_magnitude);
float ratio = clipped_magnitude / real_magnitude;
daxis_x *= ratio;
daxis_y *= ratio;
m_controllerHandler.ConvertAxisToSwitchAxis(daxis_x, daxis_y, 0, &m_hdlState.joysticks[JOYSTICK_LEFT].dx, &m_hdlState.joysticks[JOYSTICK_LEFT].dy);
}
else