From 29e1dbf78e620b1c269c39d52b409cf25d956ce3 Mon Sep 17 00:00:00 2001
From: jpy794 <[EMAIL REDACTED]>
Date: Sun, 9 Feb 2025 15:39:42 +0800
Subject: [PATCH] Fix joystick device list before polling event
---
src/sdl2_compat.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 23b42b20..64a85da0 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -5858,6 +5858,14 @@ SDL_InitSubSystem(Uint32 flags)
SDL_GetNumAudioDevices(SDL2_TRUE);
}
}
+
+ /* enumerate joysticks and haptics to build device list */
+ if (flags & (SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD)) {
+ SDL_NumJoysticks();
+ }
+ if (flags & SDL_INIT_HAPTIC) {
+ SDL_NumHaptics();
+ }
}
return result;
}