SDL: Removed SDL_HINT_ACCELEROMETER_AS_JOYSTICK

From 9ce7fe2848a2cb3a610558eaf872b4a57fdfffc9 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 11 Feb 2024 09:25:16 -0800
Subject: [PATCH] Removed SDL_HINT_ACCELEROMETER_AS_JOYSTICK

Sensors are a first-class object in SDL and we haven't gotten any feedback that this feature is useful these days.

Closes https://github.com/libsdl-org/SDL/pull/7879
---
 .../app/src/main/AndroidManifest.xml          |   2 +-
 .../org/libsdl/app/SDLControllerManager.java  |   4 +-
 docs/README-migration.md                      |   1 +
 include/SDL3/SDL_hints.h                      |   9 -
 src/core/android/SDL_android.c                |   8 +-
 src/core/linux/SDL_udev.c                     |   6 -
 src/joystick/android/SDL_sysjoystick.c        |  35 +---
 src/joystick/android/SDL_sysjoystick_c.h      |   3 +-
 src/joystick/apple/SDL_mfijoystick.m          | 185 +++++-------------
 src/joystick/apple/SDL_mfijoystick_c.h        |   2 -
 test/testautomation_hints.c                   |   2 -
 test/testcontroller.c                         |   1 -
 12 files changed, 55 insertions(+), 203 deletions(-)

diff --git a/android-project/app/src/main/AndroidManifest.xml b/android-project/app/src/main/AndroidManifest.xml
index e0d033410e14..dde60492b647 100644
--- a/android-project/app/src/main/AndroidManifest.xml
+++ b/android-project/app/src/main/AndroidManifest.xml
@@ -66,7 +66,7 @@
         android:hardwareAccelerated="true" >
 
         <!-- Example of setting SDL hints from AndroidManifest.xml:
-        <meta-data android:name="SDL_ENV.SDL_ACCELEROMETER_AS_JOYSTICK" android:value="0"/>
+        <meta-data android:name="SDL_ENV.SDL_ANDROID_TRAP_BACK_BUTTON" android:value="0"/>
          -->
      
         <activity android:name="SDLActivity"
diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java b/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
index 8e5345b8cdea..814a3565dddb 100644
--- a/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
@@ -23,7 +23,7 @@ public class SDLControllerManager
 
     public static native int nativeAddJoystick(int device_id, String name, String desc,
                                                int vendor_id, int product_id,
-                                               boolean is_accelerometer, int button_mask,
+                                               int button_mask,
                                                int naxes, int axis_mask, int nhats);
     public static native int nativeRemoveJoystick(int device_id);
     public static native int nativeAddHaptic(int device_id, String name);
@@ -235,7 +235,7 @@ public void pollInputDevices() {
 
                     mJoysticks.add(joystick);
                     SDLControllerManager.nativeAddJoystick(joystick.device_id, joystick.name, joystick.desc,
-                            getVendorId(joystickDevice), getProductId(joystickDevice), false,
+                            getVendorId(joystickDevice), getProductId(joystickDevice),
                             getButtonMask(joystickDevice), joystick.axes.size(), getAxisMask(joystick.axes), joystick.hats.size()/2);
                 }
             }
diff --git a/docs/README-migration.md b/docs/README-migration.md
index b98a94cf5cdb..f2ba041c435d 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -703,6 +703,7 @@ SDL_AddHintCallback() now returns a standard int result instead of void, returni
 Calling SDL_GetHint() with the name of the hint being changed from within a hint callback will now return the new value rather than the old value. The old value is still passed as a parameter to the hint callback.
 
 The following hints have been removed:
+* SDL_HINT_ACCELEROMETER_AS_JOYSTICK
 * SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS - gamepad buttons are always positional
 * SDL_HINT_IDLE_TIMER_DISABLED - use SDL_DisableScreenSaver instead
 * SDL_HINT_IME_SUPPORT_EXTENDED_TEXT - the normal text editing event has extended text
diff --git a/include/SDL3/SDL_hints.h b/include/SDL3/SDL_hints.h
index 992c446c2f33..b72ac5e0ee19 100644
--- a/include/SDL3/SDL_hints.h
+++ b/include/SDL3/SDL_hints.h
@@ -47,15 +47,6 @@
 extern "C" {
 #endif
 
-/**
- * Set if Android/iOS accelerometers should be listed as joystick devices.
- *
- * This variable can be set to the following values:
- *    "0"       - The accelerometer is not listed as a joystick
- *    "1"       - The accelerometer is available as a 3 axis joystick (the default).
- */
-#define SDL_HINT_ACCELEROMETER_AS_JOYSTICK "SDL_ACCELEROMETER_AS_JOYSTICK"
-
 /**
  * Specify the behavior of Alt+Tab while the keyboard is grabbed.
  *
diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index 6b39cf619df3..852e11e5a481 100644
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
@@ -269,7 +269,7 @@ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)(
 JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)(
     JNIEnv *env, jclass jcls,
     jint device_id, jstring device_name, jstring device_desc, jint vendor_id, jint product_id,
-    jboolean is_accelerometer, jint button_mask, jint naxes, jint axis_mask, jint nhats);
+    jint button_mask, jint naxes, jint axis_mask, jint nhats);
 
 JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)(
     JNIEnv *env, jclass jcls,
@@ -289,7 +289,7 @@ static JNINativeMethod SDLControllerManager_tab[] = {
     { "onNativePadUp", "(II)I", SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp) },
     { "onNativeJoy", "(IIF)V", SDL_JAVA_CONTROLLER_INTERFACE(onNativeJoy) },
     { "onNativeHat", "(IIII)V", SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat) },
-    { "nativeAddJoystick", "(ILjava/lang/String;Ljava/lang/String;IIZIIII)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick) },
+    { "nativeAddJoystick", "(ILjava/lang/String;Ljava/lang/String;IIIIII)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick) },
     { "nativeRemoveJoystick", "(I)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick) },
     { "nativeAddHaptic", "(ILjava/lang/String;)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic) },
     { "nativeRemoveHaptic", "(I)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic) }
@@ -1068,14 +1068,14 @@ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)(
 JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)(
     JNIEnv *env, jclass jcls,
     jint device_id, jstring device_name, jstring device_desc,
-    jint vendor_id, jint product_id, jboolean is_accelerometer,
+    jint vendor_id, jint product_id,
     jint button_mask, jint naxes, jint axis_mask, jint nhats)
 {
     int retval;
     const char *name = (*env)->GetStringUTFChars(env, device_name, NULL);
     const char *desc = (*env)->GetStringUTFChars(env, device_desc, NULL);
 
-    retval = Android_AddJoystick(device_id, name, desc, vendor_id, product_id, is_accelerometer, button_mask, naxes, axis_mask, nhats);
+    retval = Android_AddJoystick(device_id, name, desc, vendor_id, product_id, button_mask, naxes, axis_mask, nhats);
 
     (*env)->ReleaseStringUTFChars(env, device_name, name);
     (*env)->ReleaseStringUTFChars(env, device_desc, desc);
diff --git a/src/core/linux/SDL_udev.c b/src/core/linux/SDL_udev.c
index aa12289efe72..167176fa3097 100644
--- a/src/core/linux/SDL_udev.c
+++ b/src/core/linux/SDL_udev.c
@@ -428,12 +428,6 @@ static int device_class(struct udev_device *dev)
             devclass |= SDL_UDEV_DEVICE_JOYSTICK;
         }
 
-        val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_ACCELEROMETER");
-        if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE) &&
-            val && SDL_strcmp(val, "1") == 0) {
-            devclass |= SDL_UDEV_DEVICE_JOYSTICK;
-        }
-
         val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_MOUSE");
         if (val && SDL_strcmp(val, "1") == 0) {
             devclass |= SDL_UDEV_DEVICE_MOUSE;
diff --git a/src/joystick/android/SDL_sysjoystick.c b/src/joystick/android/SDL_sysjoystick.c
index 8b064c889812..0d2972f5ee83 100644
--- a/src/joystick/android/SDL_sysjoystick.c
+++ b/src/joystick/android/SDL_sysjoystick.c
@@ -52,8 +52,6 @@
 #define AKEYCODE_BUTTON_16 203
 #endif
 
-#define ANDROID_ACCELEROMETER_NAME      "Android Accelerometer"
-#define ANDROID_ACCELEROMETER_DEVICE_ID INT_MIN
 #define ANDROID_MAX_NBUTTONS            36
 
 static SDL_joylist_item *JoystickByDeviceId(int device_id);
@@ -303,7 +301,7 @@ int Android_OnHat(int device_id, int hat_id, int x, int y)
     return -1;
 }
 
-int Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, SDL_bool is_accelerometer, int button_mask, int naxes, int axis_mask, int nhats)
+int Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, int button_mask, int naxes, int axis_mask, int nhats)
 {
     SDL_joylist_item *item;
     SDL_JoystickGUID guid;
@@ -366,7 +364,6 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v
         goto done;
     }
 
-    item->is_accelerometer = is_accelerometer;
     if (button_mask == 0xFFFFFFFF) {
         item->nbuttons = ANDROID_MAX_NBUTTONS;
     } else {
@@ -463,11 +460,6 @@ static void ANDROID_JoystickDetect(void);
 static int ANDROID_JoystickInit(void)
 {
     ANDROID_JoystickDetect();
-
-    if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE)) {
-        /* Default behavior, accelerometer as joystick */
-        Android_AddJoystick(ANDROID_ACCELEROMETER_DEVICE_ID, ANDROID_ACCELEROMETER_NAME, ANDROID_ACCELEROMETER_NAME, 0, 0, SDL_TRUE, 0, 3, 0x0003, 0);
-    }
     return 0;
 }
 
@@ -614,31 +606,6 @@ static int ANDROID_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool en
 
 static void ANDROID_JoystickUpdate(SDL_Joystick *joystick)
 {
-    SDL_joylist_item *item = (SDL_joylist_item *)joystick->hwdata;
-
-    if (!item) {
-        return;
-    }
-
-    if (item->is_accelerometer) {
-        int i;
-        Sint16 value;
-        float values[3];
-        Uint64 timestamp = SDL_GetTicksNS();
-
-        if (Android_JNI_GetAccelerometerValues(values)) {
-            for (i = 0; i < 3; i++) {
-                if (values[i] > 1.0f) {
-                    values[i] = 1.0f;
-                } else if (values[i] < -1.0f) {
-                    values[i] = -1.0f;
-                }
-
-                value = (Sint16)(values[i] * 32767.0f);
-                SDL_SendJoystickAxis(timestamp, item->joystick, i, value);
-            }
-        }
-    }
 }
 
 static void ANDROID_JoystickClose(SDL_Joystick *joystick)
diff --git a/src/joystick/android/SDL_sysjoystick_c.h b/src/joystick/android/SDL_sysjoystick_c.h
index 28dd6b3bed7c..06424887a6a9 100644
--- a/src/joystick/android/SDL_sysjoystick_c.h
+++ b/src/joystick/android/SDL_sysjoystick_c.h
@@ -32,7 +32,7 @@ extern int Android_OnPadDown(int device_id, int keycode);
 extern int Android_OnPadUp(int device_id, int keycode);
 extern int Android_OnJoy(int device_id, int axisnum, float value);
 extern int Android_OnHat(int device_id, int hat_id, int x, int y);
-extern int Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, SDL_bool is_accelerometer, int button_mask, int naxes, int axis_mask, int nhats);
+extern int Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, int button_mask, int naxes, int axis_mask, int nhats);
 extern int Android_RemoveJoystick(int device_id);
 
 /* A linked list of available joysticks */
@@ -42,7 +42,6 @@ typedef struct SDL_joylist_item
     int device_id; /* Android's device id */
     char *name;    /* "SideWinder 3D Pro" or whatever */
     SDL_JoystickGUID guid;
-    SDL_bool is_accelerometer;
     SDL_Joystick *joystick;
     int nbuttons, naxes, nhats;
     int dpad_state;
diff --git a/src/joystick/apple/SDL_mfijoystick.m b/src/joystick/apple/SDL_mfijoystick.m
index b8770a6c4a8b..e33bd07079a9 100644
--- a/src/joystick/apple/SDL_mfijoystick.m
+++ b/src/joystick/apple/SDL_mfijoystick.m
@@ -31,7 +31,6 @@
 
 
 #if defined(SDL_PLATFORM_IOS) && !defined(SDL_PLATFORM_TVOS)
-#define SDL_JOYSTICK_iOS_ACCELEROMETER
 #import <CoreMotion/CoreMotion.h>
 #endif
 
@@ -112,11 +111,6 @@ @interface GCMicroGamepad (SDL)
 
 #endif /* SDL_JOYSTICK_MFI */
 
-#ifdef SDL_JOYSTICK_iOS_ACCELEROMETER
-static const char *accelerometerName = "iOS Accelerometer";
-static CMMotionManager *motionManager = nil;
-#endif /* SDL_JOYSTICK_iOS_ACCELEROMETER */
-
 static SDL_JoystickDeviceItem *deviceList = NULL;
 
 static int numjoysticks = 0;
@@ -674,8 +668,8 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
 }
 #endif /* SDL_JOYSTICK_MFI */
 
-#if defined(SDL_JOYSTICK_iOS_ACCELEROMETER) || defined(SDL_JOYSTICK_MFI)
-static void IOS_AddJoystickDevice(GCController *controller, SDL_bool accelerometer)
+#if defined(SDL_JOYSTICK_MFI)
+static void IOS_AddJoystickDevice(GCController *controller)
 {
     SDL_JoystickDeviceItem *device = deviceList;
 
@@ -691,24 +685,10 @@ static void IOS_AddJoystickDevice(GCController *controller, SDL_bool acceleromet
         return;
     }
 
-    device->accelerometer = accelerometer;
     device->instance_id = SDL_GetNextObjectID();
     device->pause_button_index = -1;
 
-    if (accelerometer) {
-#ifdef SDL_JOYSTICK_iOS_ACCELEROMETER
-        device->name = SDL_strdup(accelerometerName);
-        device->naxes = 3; /* Device acceleration in the x, y, and z axes. */
-        device->nhats = 0;
-        device->nbuttons = 0;
-
-        /* Use the accelerometer name as a GUID. */
-        SDL_memcpy(&device->guid.data, device->name, SDL_min(sizeof(SDL_JoystickGUID), SDL_strlen(device->name)));
-#else
-        SDL_free(device);
-        return;
-#endif /* SDL_JOYSTICK_iOS_ACCELEROMETER */
-    } else if (controller) {
+    if (controller) {
 #ifdef SDL_JOYSTICK_MFI
         if (!IOS_AddMFIJoystickDevice(device, controller)) {
             SDL_free(device->name);
@@ -735,7 +715,7 @@ static void IOS_AddJoystickDevice(GCController *controller, SDL_bool acceleromet
 
     SDL_PrivateJoystickAdded(device->instance_id);
 }
-#endif /* SDL_JOYSTICK_iOS_ACCELEROMETER || SDL_JOYSTICK_MFI */
+#endif /* SDL_JOYSTICK_MFI */
 
 static SDL_JoystickDeviceItem *IOS_RemoveJoystickDevice(SDL_JoystickDeviceItem *device)
 {
@@ -828,12 +808,6 @@ static int IOS_JoystickInit(void)
 #ifdef SDL_JOYSTICK_MFI
         NSNotificationCenter *center;
 #endif
-#ifdef SDL_JOYSTICK_iOS_ACCELEROMETER
-        if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE)) {
-            /* Default behavior, accelerometer as joystick */
-            IOS_AddJoystickDevice(nil, SDL_TRUE);
-        }
-#endif
 
 #ifdef SDL_JOYSTICK_MFI
         /* GameController.framework was added in iOS 7. */
@@ -844,7 +818,7 @@ static int IOS_JoystickInit(void)
         /* For whatever reason, this always returns an empty array on
          macOS 11.0.1 */
         for (GCController *controller in [GCController controllers]) {
-            IOS_AddJoystickDevice(controller, SDL_FALSE);
+            IOS_AddJoystickDevice(controller);
         }
 
 #ifdef SDL_PLATFORM_TVOS
@@ -860,7 +834,7 @@ static int IOS_JoystickInit(void)
                                           usingBlock:^(NSNotification *note) {
                                             GCController *controller = note.object;
                                             SDL_LockJoysticks();
-                                            IOS_AddJoystickDevice(controller, SDL_FALSE);
+                                            IOS_AddJoystickDevice(controller);
                                             SDL_UnlockJoysticks();
                                           }];
 
@@ -970,74 +944,62 @@ static int IOS_JoystickOpen(SDL_Joystick *joystick, int device_index)
     device->joystick = joystick;
 
     @autoreleasepool {
-        if (device->accelerometer) {
-#ifdef SDL_JOYSTICK_iOS_ACCELEROMETER
-            if (motionManager == nil) {
-                motionManager = [[CMMotionManager alloc] init];
-            }
-
-            /* Shorter times between updates can significantly increase CPU usage. */
-            motionManager.accelerometerUpdateInterval = 0.1;
-            [motionManager startAccelerometerUpdates];
-#endif
-        } else {
 #ifdef SDL_JOYSTICK_MFI
-            if (device->pause_button_index >= 0) {
-                GCController *controller = device->controller;
-                controller.controllerPausedHandler = ^(GCController *c) {
-                  if (joystick->hwdata) {
-                      joystick->hwdata->pause_button_pressed = SDL_GetTicks();
-                  }
-                };
-            }
+        if (device->pause_button_index >= 0) {
+            GCController *controller = device->controller;
+            controller.controllerPausedHandler = ^(GCController *c) {
+              if (joystick->hwdata) {
+                  joystick->hwdata->pause_button_pressed = SDL_GetTicks();
+              }
+            };
+        }
 
 #ifdef ENABLE_MFI_SENSORS
-            if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
-                GCController *controller = joystick->hwdata->controller;
-                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);
-                }
+        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+            GCController *controller = joystick->hwdata->controller;
+            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);
+            }
+        }
 #endif /* ENABLE_MFI_SENSORS */
 
 #ifdef ENABLE_MFI_SYSTEM_GESTURE_STATE
-            if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
-                GCController *controller = joystick->hwdata->controller;
-                for (id key in controller.physicalInputProfile.buttons) {
-                    GCControllerButtonInput *button = controller.physicalInputProfile.buttons[key];
-                    if ([button isBoundToSystemGesture]) {
-                        button.preferredSystemGestureState = GCSystemGestureStateDisabled;
-                    }
+        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+            GCController *controller = joystick->hwdata->controller;
+            for (id key in controller.physicalInputProfile.buttons) {
+                GCControllerButtonInput *button = controller.physicalInputProfile.buttons[key];
+                if ([button isBoundToSystemGesture]) {
+                    button.preferredSystemGestureState = GCSystemGestureStateDisabled;
                 }
             }
+        }
 #endif /* ENABLE_MFI_SYSTEM_GESTURE_STATE */
 
-            if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
-                GCController *controller = device->controller;
+        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+            GCController *controller = device->controller;
 #ifdef ENABLE_MFI_LIGHT
-                if (controller.light) {
-                    SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, SDL_TRUE);
-                }
+            if (controller.light) {
+                SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, SDL_TRUE);
+            }
 #endif
 
 #ifdef ENABLE_MFI_RUMBLE
-                if (controller.haptics) {
-                    for (GCHapticsLocality locality in controller.haptics.supportedLocalities) {
-                        if ([locality isEqualToString:GCHapticsLocalityHandles]) {
-                            SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE);
-                        } else if ([locality isEqualToString:GCHapticsLocalityTriggers]) {
-                            SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, SDL_TRUE);
-                        }
+            if (controller.haptics) {
+                for (GCHapticsLocality locality in controller.haptics.supportedLocalities) {
+                    if ([locality isEqualToString:GCHapticsLocalityHandles]) {
+                        SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE);
+                    } else if ([locality isEqualToString:GCHapticsLocalityTriggers]) {
+                        SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, SDL_TRUE);
                     }
                 }
-#endif
             }
-#endif /* SDL_JOYSTICK_MFI */
+#endif
         }
+#endif /* SDL_JOYSTICK_MFI */
     }
     if (device->is_siri_remote) {
         ++SDL_AppleTVRemoteOpenedAsJoystick;
@@ -1046,50 +1008,6 @@ static int IOS_JoystickOpen(SDL_Joystick *joystick, int device_index)
     return 0;
 }
 
-static void IOS_AccelerometerUpdate(SDL_Joystick *joystick)
-{
-#ifdef SDL_JOYSTICK_iOS_ACCELEROMETER
-    const float maxgforce = SDL_IPHONE_MAX_GFORCE;
-    const SInt16 maxsint16 = 0x7FFF;
-    CMAcceleration accel;
-    Uint64 timestamp = SDL_GetTicksNS();
-
-    @autoreleasepool {
-        if (!motionManager.isAccelerometerActive) {
-            return;
-        }
-
-        accel = motionManager.accelerometerData.acceleration;
-    }
-
-    /*
-     Convert accelerometer data from floating point to Sint16, which is what
-     the joystick system expects.
-
-     To do the conversion, the data is first clamped onto the interval
-     [-SDL_IPHONE_MAX_G_FORCE, SDL_IPHONE_MAX_G_FORCE], then the data is multiplied
-     by MAX_SINT16 so that it is mapped to the full range of an Sint16.
-
-     You can customize the clamped range of this function by modifying the
-     SDL_IPHONE_MAX_GFORCE macro in SDL_config_ios.h.
-
-     Once converted to Sint16, the accelerometer data no longer has coherent
-     units. You can convert the data back to units of g-force by multiplying
-     it in your application's code by SDL_IPHONE_MAX_GFORCE / 0x7FFF.
-     */
-
-    /* clamp the data */
-    accel.x = SDL_clamp(accel.x, -maxgforce, maxgforce);
-    accel.y = SDL_clamp(accel.y, -maxgforce, maxgforce);
-    accel.z = SDL_clamp(accel.z, -maxgforce, maxgforce);
-
-    /* pass in data mapped to range of SInt16 */
-    SDL_SendJoystickAxis(timestamp, joystick, 0, (accel.x / maxgforce) * maxsint16);
-    SDL_SendJoystickAxis(timestamp, joystick, 1, -(accel.y / maxgforce) * maxsint16);
-    SDL_SendJoystickAxis(timestamp, joystick, 2, (accel.z / maxgforce) * maxsint16);
-#endif /* SDL_JOYSTICK_iOS_ACCELEROMETER */
-}
-
 #ifdef SDL_JOYSTICK_MFI
 static Uint8 IOS_MFIJoystickHatStateForDPad(GCControllerDirectionPad *dpad)
 {
@@ -1715,9 +1633,7 @@ static void IOS_JoystickUpdate(SDL_Joystick *joystick)
         return;
     }
 
-    if (device->accelerometer) {
-        IOS_AccelerometerUpdate(joystick);
-    } else if (device->controller) {
+    if (device->controller) {
         IOS_MFIJoystickUpdate(joystick);
     }
 }
@@ -1743,11 +1659,7 @@ static void IOS_JoystickClose(SDL_Joystick *joystick)
         }
 #endif /* ENABLE_MFI_RUMBLE */
 
-        if (device->accelerometer) {
-#ifdef SDL_JOYSTICK_iOS_ACCELEROMETER
-            [motionManager stopAccelerometerUpdates];
-#endif
-        } else if (device->controller) {
+        if (device->controller) {
 #ifdef SDL_JOYSTICK_MFI
             GCController *controller = device->controller;
             controller.controllerPausedHandler = nil;
@@ -1797,10 +1709,6 @@ static void IOS_JoystickQuit(void)
         while (deviceList != NULL) {
             IOS_RemoveJoystickDevice(deviceList);
         }
-
-#ifdef SDL_JOYSTICK_iOS_ACCELEROMETER
-        motionManager = nil;
-#endif
     }
 
     numjoysticks = 0;
@@ -1813,9 +1721,6 @@ static SDL_bool IOS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMappi
     if (device == NULL) {
         return SDL_FALSE;
     }
-    if (device->accelerometer) {
-        return SDL_FALSE;
-    }
 
     if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
         int axis = 0;
diff --git a/src/joystick/apple/SDL_mfijoystick_c.h b/src/joystick/apple/SDL_mfijoystick_c.h
index b74e095aff83..4a974913480b 100644
--- a/src/joystick/apple/SDL_mfijoystick_c.h
+++ b/src/joystick/apple/SDL_mfijoystick_c.h
@@ -32,8 +32,6 @@
 
 typedef struct joystick_hwdata
 {
-    SDL_bool accelerometer;
-
     GCController __unsafe_unretained *controller;
     void *rumble;
     int pause_button_index;
diff --git a/test/testautomation_hints.c b/test/testautomation_hints.c
index 0e22b7074743..18b69c012708 100644
--- a/test/testautomation_hints.c
+++ b/test/testautomation_hints.c
@@ -7,7 +7,6 @@
 #include "testautomation_suites.h"
 
 static const char *HintsEnum[] = {
-    SDL_HINT_ACCELEROMETER_AS_JOYSTICK,
     SDL_HINT_FRAMEBUFFER_ACCELERATION,
     SDL_HINT_GAMECONTROLLERCONFIG,
     SDL_HINT_GRAB_KEYBOARD,
@@ -29,7 +28,6 @@ static const char *HintsEnum[] = {
     SDL_HINT_XINPUT_ENABLED,
 };
 static const char *HintsVerbose[] = {
-    "SDL_ACCELEROMETER_AS_JOYSTICK",
     "SDL_FRAMEBUFFER_ACCELERATION",
     "SDL_GAMECONTROLLERCONFIG",
     "SDL_GRAB_KEYBOARD",
diff --git a/test/testcontroller.c b/test/testcontroller.c
index 1c093d13eee9..dc5ca4cdbdbf 100644
--- a/test/testcontroller.c
+++ b/test/testcontroller.c
@@ -1917,7 +1917,6 @@ int main(int argc, char *argv[])
         return 1;
     }
 
-    SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
     SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1");
     SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");
     SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_STEAM, "1");