SDL: Fixed reading the controller accelerometer on Apple platforms

From 14c31ee12a6456db78ad3ff2f100391416ee38a0 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 17 May 2026 17:56:33 -0700
Subject: [PATCH] Fixed reading the controller accelerometer on Apple platforms

DualShock and DualSense controllers no longer have hasGravityAndUserAcceleration set, but we can still get the combined user + gravity acceleration values from those controllers, which is what we want.
---
 src/joystick/apple/SDL_mfijoystick.m | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/src/joystick/apple/SDL_mfijoystick.m b/src/joystick/apple/SDL_mfijoystick.m
index 758da444829a3..ea38169dce60b 100644
--- a/src/joystick/apple/SDL_mfijoystick.m
+++ b/src/joystick/apple/SDL_mfijoystick.m
@@ -946,8 +946,6 @@ static bool IOS_JoystickOpen(SDL_Joystick *joystick, int device_index)
             GCMotion *motion = controller.motion;
             if (motion && motion.hasRotationRate) {
                 SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO, 0.0f);
-            }
-            if (motion && motion.hasGravityAndUserAcceleration) {
                 SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 0.0f);
             }
         }
@@ -1198,20 +1196,17 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
             if (motion && motion.sensorsActive) {
                 float data[3];
 
-                if (motion.hasRotationRate) {
-                    GCRotationRate rate = motion.rotationRate;
-                    data[0] = rate.x;
-                    data[1] = rate.z;
-                    data[2] = -rate.y;
-                    SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO, timestamp, data, 3);
-                }
-                if (motion.hasGravityAndUserAcceleration) {
-                    GCAcceleration accel = motion.acceleration;
-                    data[0] = -accel.x * SDL_STANDARD_GRAVITY;
-                    data[1] = -accel.y * SDL_STANDARD_GRAVITY;
-                    data[2] = -accel.z * SDL_STANDARD_GRAVITY;
-                    SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, timestamp, data, 3);
-                }
+                GCRotationRate rate = motion.rotationRate;
+                data[0] = rate.x;
+                data[1] = rate.z;
+                data[2] = -rate.y;
+                SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO, timestamp, data, 3);
+
+                GCAcceleration accel = motion.acceleration;
+                data[0] = -accel.x * SDL_STANDARD_GRAVITY;
+                data[1] = -accel.y * SDL_STANDARD_GRAVITY;
+                data[2] = -accel.z * SDL_STANDARD_GRAVITY;
+                SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, timestamp, data, 3);
             }
         }