---
name: "SDL_JoyBallEvent"
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_JoyBallEvent"
---

# SDL\_JoyBallEvent(3)

Joystick trackball motion event structure

## NAME

SDL\_JoyBallEvent - Joystick trackball motion event structure

## STRUCTURE DEFINITION

```
typedef struct{
  Uint8 type;
  Uint8 which;
  Uint8 ball;
  Sint16 xrel, yrel;
} SDL_JoyBallEvent;
```

## STRUCTURE DATA

- **type**

  **SDL\_JOYBALLMOTION**

- **which**

  Joystick device index

- **ball**

  Joystick trackball index

- **xrel**, **yrel**

  The relative motion in the X/Y direction

## DESCRIPTION

**SDL\_JoyBallEvent** is a member of the **SDL\_Event** union and is used when an event of type **SDL\_JOYBALLMOTION** is reported.

A **SDL\_JOYBALLMOTION** event occurs when a user moves a trackball on the joystick. The field **which** is the index of the joystick that reported the event and **ball** is the index of the trackball (for a more detailed explaination see the *Joystick section*). Trackballs only return relative motion, this is the change in position on the ball since it was last polled (last cycle of the event loop) and it is stored in **xrel** and **yrel**.

## SEE ALSO

**SDL\_Event**, *Joystick Functions*, **SDL\_JoystickEventState**, **SDL\_JoystickGetBall**
