diff --git a/source/ControllerSwitch/SwitchControllerHandler.cpp b/source/ControllerSwitch/SwitchControllerHandler.cpp index f628d01..11a49b1 100644 --- a/source/ControllerSwitch/SwitchControllerHandler.cpp +++ b/source/ControllerSwitch/SwitchControllerHandler.cpp @@ -1,6 +1,9 @@ #include "SwitchControllerHandler.h" #include +#define JOYSTICK_MAX_FIXED (JOYSTICK_MAX - 1) +#define JOYSTICK_MIN_FIXED (JOYSTICK_MIN + 1) + SwitchControllerHandler::SwitchControllerHandler(std::unique_ptr &&controller) : m_controller(std::move(controller)) { @@ -27,11 +30,11 @@ void SwitchControllerHandler::Exit() void SwitchControllerHandler::ConvertAxisToSwitchAxis(float x, float y, float deadzone, s32 *x_out, s32 *y_out) { float floatRange = 2.0f; - //JOYSTICK_MAX is 1 above the s16 max value, causing crashes on various games including Xenoblade Chronicles 2 - float newRange = ((JOYSTICK_MAX-1) - JOYSTICK_MIN); + //JOYSTICK_MAX is 1 above and JOYSTICK_MIN is 1 below acceptable joystick values, causing crashes on various games including Xenoblade Chronicles 2 and Resident Evil 4 + float newRange = (JOYSTICK_MAX_FIXED - JOYSTICK_MIN_FIXED); - *x_out = (((x + 1.0f) * newRange) / floatRange) + JOYSTICK_MIN; - *y_out = (((y + 1.0f) * newRange) / floatRange) + JOYSTICK_MIN; + *x_out = (((x + 1.0f) * newRange) / floatRange) + JOYSTICK_MIN_FIXED; + *y_out = (((y + 1.0f) * newRange) / floatRange) + JOYSTICK_MIN_FIXED; /* OldRange = (OldMax - OldMin) NewRange = (NewMax - NewMin)