/* Get the current state of a button on a joystick  */
Uint8 SDL_JoystickGetButton(SDL_Joystick *joystick, int button)
/* Get the current state of a button on a joystick  */
Uint8 SDL_JoystickGetButton(SDL_Joystick *joystick, int button)
{
    Uint8 state;
    if (!SDL_PrivateJoystickValid(joystick)) {
        return 0;
    }
    if (button < joystick->nbuttons) {
        state = joystick->buttons[button];
    } else {
        SDL_SetError("Joystick only has %d buttons", joystick->nbuttons);
        state = 0;
    }
    return state;
}