SDL: Fix joystick initialization on BSD
Jeffrey Pfau jeffrey@endrift.com
Sat, 20 Feb 2016 21:44:51 -0800
2 files changed,
14 insertions(+),
0 deletions(-)
M
CHANGES
→
CHANGES
@@ -8,6 +8,7 @@ - Qt: Fix hang if audio sync is enabled and audio fails to initialize
- GBA BIOS: Fix RegisterRamReset setting DISPCNT to the wrong value - OpenGL: Correct boolean vector strcmp strings for uniforms - Wii: Fix tilting direction + - SDL: Fix joystick initialization on BS Misc: - GBA: Slightly optimize GBAProcessEvents - Qt: Add preset for DualShock 4
M
src/platform/sdl/sdl-events.c
→
src/platform/sdl/sdl-events.c
@@ -62,6 +62,19 @@ int nJoysticks = SDL_NumJoysticks();
SDL_JoystickListInit(&context->joysticks, nJoysticks); if (nJoysticks > 0) { mSDLUpdateJoysticks(context); + // Some OSes don't do hotplug detection + if (!SDL_JoystickListSize(&context->joysticks)) { + int i; + for (i = 0; i < nJoysticks; ++i) { + struct SDL_JoystickCombo* joystick = SDL_JoystickListAppend(&context->joysticks); + joystick->joystick = SDL_JoystickOpen(i); + joystick->id = SDL_JoystickInstanceID(joystick->joystick); + joystick->index = SDL_JoystickListSize(&context->joysticks) - 1; +#if SDL_VERSION_ATLEAST(2, 0, 0) + joystick->haptic = SDL_HapticOpenFromJoystick(joystick->joystick); +#endif + } + } } context->playersAttached = 0;