SDL: Fixed incorrect error message when a joystick can't be opened

From 9f7b2c3595e0b475aa51eb20ffee4b3baf5ccf63 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 2 Jan 2025 16:52:59 -0800
Subject: [PATCH] Fixed incorrect error message when a joystick can't be opened

---
 test/testcontroller.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/test/testcontroller.c b/test/testcontroller.c
index 4b563d08e3fb1..d7fb62c3d7479 100644
--- a/test/testcontroller.c
+++ b/test/testcontroller.c
@@ -910,8 +910,10 @@ static void AddController(SDL_JoystickID id, bool verbose)
     new_controller->id = id;
 
     new_controller->joystick = SDL_OpenJoystick(id);
-    new_controller->num_axes = SDL_GetNumJoystickAxes(new_controller->joystick);
-    new_controller->axis_state = (AxisState *)SDL_calloc(new_controller->num_axes, sizeof(*new_controller->axis_state));
+    if (new_controller->joystick) {
+        new_controller->num_axes = SDL_GetNumJoystickAxes(new_controller->joystick);
+        new_controller->axis_state = (AxisState *)SDL_calloc(new_controller->num_axes, sizeof(*new_controller->axis_state));
+    }
 
     joystick = new_controller->joystick;
     if (joystick) {
@@ -2002,8 +2004,7 @@ int main(int argc, char *argv[])
     }
 
     SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI, "1");
-    SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1");
-    SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");
+    SDL_SetHint(SDL_HINT_JOYSTICK_ENHANCED_REPORTS, "auto");
     SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_STEAM, "1");
     SDL_SetHint(SDL_HINT_JOYSTICK_ROG_CHAKRAM, "1");
     SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");