---
name: "calibrate_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/calibrate_joystick"
---

# calibrate\_joystick(3alleg)

Calibrates the specified joystick. Allegro game programming library.

## NAME

calibrate\_joystick - Calibrates the specified joystick. Allegro game programming library.

## SYNOPSIS

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

**int calibrate\_joystick(int n);**

## DESCRIPTION

Most joysticks need to be calibrated before they can provide full  analogue input. This function performs the next operation in the  calibration series for the specified stick, assuming that the joystick  has been positioned in the manner described by a previous call to  calibrate\_joystick\_name(), returning zero on success. For example, a  simple routine to fully calibrate all the joysticks might look like:

```
   int i;
   for (i=0; i<;num_joysticks; i++) {
      while (joy[i].flags & JOYFLAG_CALIBRATE) {
         char *msg = calibrate_joystick_name(i);
         textprintf_ex(..., "%s, and press a key\n", msg);
         readkey();
         if (calibrate_joystick(i) != 0) {
            textprintf_ex(..., "oops!\n");
            readkey();
            exit(1);
         }
      }
   }
```

## RETURN VALUE

Returns zero on success, non-zero if the calibration could not be performed successfully.

## SEE ALSO

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