From 6428d6fc612e31753d424e2efcfcc6afc6d2e93a Mon Sep 17 00:00:00 2001 From: Eidolon Date: Thu, 8 Dec 2022 21:25:10 -0600 Subject: [PATCH] Fix axis inversion and camera look inversion --- src/g_game.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index b406b8f94..b4a127a73 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -935,7 +935,12 @@ static INT16 GetJoystickAxisValue(UINT8 which, joyaxis_e axissel, INT32 axisval) // flip it around if (flp) - retaxis = -retaxis; + { + if (retaxis == -32768) + retaxis = 32767; + else + retaxis = -retaxis; + } return retaxis; } @@ -943,6 +948,7 @@ static INT16 GetJoystickAxisValue(UINT8 which, joyaxis_e axissel, INT32 axisval) INT16 G_JoyAxis(UINT8 which, joyaxis_e axissel) { INT32 axisval; + INT32 value; // find what axis to get switch (axissel) @@ -975,7 +981,16 @@ INT16 G_JoyAxis(UINT8 which, joyaxis_e axissel) return 0; } - return GetJoystickAxisValue(which, axissel, axisval); + value = GetJoystickAxisValue(which, axissel, axisval); + if (axissel == JA_LOOK) + { + // Look is inverted because +Y goes _down_ in gamepads. + if (value == -32768) + value = 32767; + else + value = -value; + } + return value; } static INT16 GetAnalogInput(UINT8 which, gamecontrols_e gc)