SDL: Fix: GameCube controller adapter hotplug not working (4b4f6)

From 4b4f6b3e228f8386262e4129eb3b39d6704ded61 Mon Sep 17 00:00:00 2001
From: "Joe [ReRezd]" <[EMAIL REDACTED]>
Date: Mon, 19 May 2025 00:36:55 -0400
Subject: [PATCH] Fix: GameCube controller adapter hotplug not working

SDL_PrivateJoystickAdded was called before setting the InstanceId in the adapters ctx->joysticks array.  This would eventually broadcast the SDL_EVENT_JOYSTICK_ADDED event with the new InstanceId, if your program listens for the added events and opens joysticks at that point it would always fail because there would be no matching InstanceId in the ctx->joysticks array.

(cherry picked from commit afd1e5102321cfa3c8e0798bbee159452f51ef4d)
---
 src/joystick/hidapi/SDL_hidapijoystick.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c
index 62e3633f6b29d..7bc52305e6a82 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick.c
+++ b/src/joystick/hidapi/SDL_hidapijoystick.c
@@ -822,11 +822,12 @@ SDL_bool HIDAPI_JoystickConnected(SDL_HIDAPI_Device *device, SDL_JoystickID *pJo
 
     ++SDL_HIDAPI_numjoysticks;
 
-    SDL_PrivateJoystickAdded(joystickID);
-
     if (pJoystickID) {
         *pJoystickID = joystickID;
     }
+
+    SDL_PrivateJoystickAdded(joystickID);
+
     return SDL_TRUE;
 }