---
name: "poll_joystick"
section: "3alleg"
platform: "linux"
package: "liballegro-doc"
version: "2:4.2.2-2.2"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/poll_joystick"
---

# poll\_joystick(3alleg)

Polls the joystick. Allegro game programming library.

## NAME

poll\_joystick - Polls the joystick. Allegro game programming library.

## SYNOPSIS

**#include \<allegro.h\>**

**int poll\_joystick();**

## DESCRIPTION

The joystick handler is not interrupt driven, so you need to call this function every now and again to update the global position values. Example:

```
   do {
      /* Get joystick input */
      poll_joystick();
      /* Process input for the first joystick */
      if (joy[0].button[0].b)
         first_button_pressed();
      if (joy[0].button[1].b)
         second_button_pressed();
      ...
   } while(!done);
```

## RETURN VALUE

Returns zero on success or a negative number on failure (usually because no joystick driver was installed).

## SEE ALSO

[**install\_joystick**(3alleg)](/install_joystick/3alleg.md), [**joy**(3alleg)](/joy/3alleg.md), [**num\_joysticks**(3alleg)](/num_joysticks/3alleg.md), [**exjoy**(3alleg)](/exjoy/3alleg.md)
