/* Return the SDL_Joystick associated with an instance id.  */
SDL_Joystick* SDL_JoystickFromInstanceID(SDL_JoystickID instance_id)
/* Return the SDL_Joystick associated with an instance id.  */
SDL_Joystick* SDL_JoystickFromInstanceID(SDL_JoystickID instance_id)
{
    SDL_Joystick *joystick;
    SDL_LockJoysticks();
    for (joystick = SDL_joysticks; joystick; joystick = joystick->next) {
        if (joystick->instance_id == instance_id) {
            break;
        }
    }
    SDL_UnlockJoysticks();
    return joystick;
}