mirror of
https://github.com/cathery/sys-con.git
synced 2024-11-05 08:26:32 +00:00
Fixed another joystick value edge case
Joystick values of -32768 and lower cause Resident Evil 4 to crash
This commit is contained in:
parent
033b9abece
commit
bde2cfa2b0
@ -1,6 +1,9 @@
|
||||
#include "SwitchControllerHandler.h"
|
||||
#include <cmath>
|
||||
|
||||
#define JOYSTICK_MAX_FIXED (JOYSTICK_MAX - 1)
|
||||
#define JOYSTICK_MIN_FIXED (JOYSTICK_MIN + 1)
|
||||
|
||||
SwitchControllerHandler::SwitchControllerHandler(std::unique_ptr<IController> &&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)
|
||||
|
Loading…
Reference in New Issue
Block a user