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