Controller name fix
The controller name is cleared by SDL when the joystick subsystem is shut down. Copy the joyname to another buffer, and the problem is fixed.
if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0)
{
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != -1)
joyname = SDL_JoystickNameForIndex(joyindex);
SDL_QuitSubSystem(SDL_INIT_JOYSTICK); // <-------------- JOYNAME GETS CORRUPTED HERE
}
else
joyname = SDL_JoystickNameForIndex(joyindex);
return joyname;