Joystick routines

Summary
Install a joystick driver, returning true if successful.
Uninstalls the active joystick driver.
Return the number of joysticks on the system (depending on the OS this may not be accurate).
Get a handle for joystick number NUM on the system.
Release a previously ‘gotten’ joystick object.
Return the name of the given joystick.
Return the number of “sticks” on the given joystick.
Return the flags of the given “stick”.
Return the name of the given “stick”.
Return the number of axes on the given “stick”.
Return the name of the given axis.
Return the number of buttons on the joystick.
Return the name of the given button.
Get the current joystick state.

Functions

al_install_joystick

bool al_install_joystick(void)

Install a joystick driver, returning true if successful.  If a joystick driver was already installed, returns true immediately.

al_uninstall_joystick

void al_uninstall_joystick(void)

Uninstalls the active joystick driver.  All outstanding ALLEGRO_JOYSTICKs are automatically released.  If no joystick driver was active, this function does nothing.

This function is automatically called when Allegro is shut down.

al_num_joysticks

int al_num_joysticks(void)

Return the number of joysticks on the system (depending on the OS this may not be accurate).  Returns 0 if there is no joystick driver installed.

al_get_joystick

ALLEGRO_JOYSTICK *al_get_joystick(int num)

Get a handle for joystick number NUM on the system.  If successful a pointer to a joystick object is returned.  Otherwise NULL is returned.

If the joystick was previously ‘gotten’ (and not yet released) then the returned pointer will be the same as in previous calls.

al_release_joystick

void al_release_joystick(ALLEGRO_JOYSTICK *joy)

Release a previously ‘gotten’ joystick object.

al_get_joystick_name

const char *al_get_joystick_name(ALLEGRO_JOYSTICK *joy)

Return the name of the given joystick.

al_get_num_joystick_sticks

int al_get_num_joystick_sticks(const ALLEGRO_JOYSTICK *joy)

Return the number of “sticks” on the given joystick.

al_get_joystick_stick_flags

int al_get_joystick_stick_flags(const ALLEGRO_JOYSTICK *joy,
int stick)

Return the flags of the given “stick”.  If the stick doesn’t exist, NULL is returned.

al_get_joystick_stick_name

const char *al_get_joystick_stick_name(const ALLEGRO_JOYSTICK *joy,
int stick)

Return the name of the given “stick”.  If the stick doesn’t exist, NULL is returned.

al_get_num_joystick_axes

int al_get_num_joystick_axes(const ALLEGRO_JOYSTICK *joy,
int stick)

Return the number of axes on the given “stick”.  If the stick doesn’t exist, 0 is returned.

al_get_joystick_axis_name

const char *al_get_joystick_axis_name(const ALLEGRO_JOYSTICK *joy,
int stick,
int axis)

Return the name of the given axis.  If the axis doesn’t exist, NULL is returned.

al_get_num_joystick_buttons

int al_get_num_joystick_buttons(const ALLEGRO_JOYSTICK *joy)

Return the number of buttons on the joystick.

al_get_joystick_button_name

const char *al_get_joystick_button_name(const ALLEGRO_JOYSTICK *joy,
int button)

Return the name of the given button.  If the button doesn’t exist, NULL is returned.

al_get_joystick_state

void al_get_joystick_state(ALLEGRO_JOYSTICK *joy,
ALLEGRO_JOYSTATE *ret_state)

Get the current joystick state.

bool al_install_joystick(void)
Install a joystick driver, returning true if successful.
void al_uninstall_joystick(void)
Uninstalls the active joystick driver.
int al_num_joysticks(void)
Return the number of joysticks on the system (depending on the OS this may not be accurate).
ALLEGRO_JOYSTICK *al_get_joystick(int num)
Get a handle for joystick number NUM on the system.
void al_release_joystick(ALLEGRO_JOYSTICK *joy)
Release a previously ‘gotten’ joystick object.
const char *al_get_joystick_name(ALLEGRO_JOYSTICK *joy)
Return the name of the given joystick.
int al_get_num_joystick_sticks(const ALLEGRO_JOYSTICK *joy)
Return the number of “sticks” on the given joystick.
int al_get_joystick_stick_flags(const ALLEGRO_JOYSTICK *joy,
int stick)
Return the flags of the given “stick”.
const char *al_get_joystick_stick_name(const ALLEGRO_JOYSTICK *joy,
int stick)
Return the name of the given “stick”.
int al_get_num_joystick_axes(const ALLEGRO_JOYSTICK *joy,
int stick)
Return the number of axes on the given “stick”.
const char *al_get_joystick_axis_name(const ALLEGRO_JOYSTICK *joy,
int stick,
int axis)
Return the name of the given axis.
int al_get_num_joystick_buttons(const ALLEGRO_JOYSTICK *joy)
Return the number of buttons on the joystick.
const char *al_get_joystick_button_name(const ALLEGRO_JOYSTICK *joy,
int button)
Return the name of the given button.
void al_get_joystick_state(ALLEGRO_JOYSTICK *joy,
ALLEGRO_JOYSTATE *ret_state)
Get the current joystick state.