SDL: Scale the values correctly based on the sensor type (thanks @meyraud705)

From b3a0174b26bf5ffc0bad77ae5446855ed003d426 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 29 Jul 2021 14:23:15 -0700
Subject: [PATCH] Scale the values correctly based on the sensor type (thanks
 @meyraud705)

---
 src/joystick/hidapi/SDL_hidapi_switch.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c
index 0be289ffa..aef17c8de 100644
--- a/src/joystick/hidapi/SDL_hidapi_switch.c
+++ b/src/joystick/hidapi/SDL_hidapi_switch.c
@@ -1341,9 +1341,15 @@ static void SendSensorUpdate(SDL_Joystick *joystick, SDL_DriverSwitch_Context *c
      * since that's our de facto standard from already supporting those controllers, and
      * users will want consistent axis mappings across devices.
      */
-    data[0] = -HIDAPI_DriverSwitch_ScaleGyro(values[1]);
-    data[1] = HIDAPI_DriverSwitch_ScaleGyro(values[2]);
-    data[2] = -HIDAPI_DriverSwitch_ScaleGyro(values[0]);
+    if (type == SDL_SENSOR_GYRO) {
+        data[0] = -HIDAPI_DriverSwitch_ScaleGyro(values[1]);
+        data[1] = HIDAPI_DriverSwitch_ScaleGyro(values[2]);
+        data[2] = -HIDAPI_DriverSwitch_ScaleGyro(values[0]);
+    } else {
+        data[0] = -HIDAPI_DriverSwitch_ScaleAccel(values[1]);
+        data[1] = HIDAPI_DriverSwitch_ScaleAccel(values[2]);
+        data[2] = -HIDAPI_DriverSwitch_ScaleAccel(values[0]);
+    }
 
     /* Right Joy-Con flips some axes, so let's flip them back for consistency */
     if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) {