/* Get the ball axis change since the last poll  */
int SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy)
/* Get the ball axis change since the last poll  */
int SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy)
{
    int retval;
    if (!SDL_PrivateJoystickValid(joystick)) {
        return -1;
    }
    retval = 0;
    if (ball < joystick->nballs) {
        if (dx) {
            *dx = joystick->balls[ball].dx;
        }
        if (dy) {
            *dy = joystick->balls[ball].dy;
        }
        joystick->balls[ball].dx = 0;
        joystick->balls[ball].dy = 0;
    } else {
        return SDL_SetError("Joystick only has %d balls", joystick->nballs);
    }
    return retval;
}