---
name: "SDL_JoystickGetBall"
section: "3"
platform: "linux"
package: "libsdl1.2-dev"
version: "1.2.15+dfsg2-8"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_JoystickGetBall"
---

# SDL\_JoystickGetBall(3)

Get relative trackball motion

## NAME

SDL\_JoystickGetBall - Get relative trackball motion

## SYNOPSIS

**#include "SDL.h"**

**int SDL\_JoystickGetBall**(**SDL\_Joystick \*joystick, int ball, int \*dx, int \*dy**);

## DESCRIPTION

Get the **ball** axis change.

Trackballs can only return relative motion since the last call to **SDL\_JoystickGetBall**, these motion deltas a placed into **dx** and **dy**.

## RETURN VALUE

Returns **0** on success or **-1** on failure

## EXAMPLES

```
int delta_x, delta_y;
SDL_Joystick *joy;
.
.
.
SDL_JoystickUpdate();
if(SDL_JoystickGetBall(joy, 0, &delta_x, &delta_y)==-1)
  printf("TrackBall Read Error!
");
printf("Trackball Delta- X:%d, Y:%d
", delta_x, delta_y);
```

## SEE ALSO

**SDL\_JoystickNumBalls**
