Joystick

ALLEGRO_JOYSTICK

typedef struct ALLEGRO_JOYSTICK ALLEGRO_JOYSTICK;

This is an abstract data type representing a physical joystick.

ALLEGRO_JOYSTICK_STATE

typedef struct ALLEGRO_JOYSTICK_STATE ALLEGRO_JOYSTICK_STATE;

This is a structure that is used to hold a "snapshot" of a joystick's axes and buttons at a particular instant. All fields public and read-only.

struct {
      float axis[num_axes];             // -1.0 to 1.0 
} stick[num_sticks];
int button[num_buttons];                // 0 to 32767

ALLEGRO_JOYFLAGS

enum
  • ALLEGRO_JOYFLAG_DIGITAL - the stick provides digital input
  • ALLEGRO_JOYFLAG_ANALOGUE - the stick provides analogue input

(this enum is a holdover from the old API and may be removed)

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_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_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_name

const char *al_get_joystick_name(ALLEGRO_JOYSTICK *joy)

Return the name of the given joystick.

al_get_joystick_number

int al_get_joystick_number(ALLEGRO_JOYSTICK *joy)

Return the joystick number, i.e. 'i' such that al_get_joystick(i) returns the same joystick object.

al_get_joystick_state

void al_get_joystick_state(ALLEGRO_JOYSTICK *joy, ALLEGRO_JOYSTICK_STATE *ret_state)

Get the current joystick state.

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_joystick_num_axes

int al_get_joystick_num_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_num_buttons

int al_get_joystick_num_buttons(const ALLEGRO_JOYSTICK *joy)

Return the number of buttons on the joystick.

al_get_joystick_num_sticks

int al_get_joystick_num_sticks(const ALLEGRO_JOYSTICK *joy)

Return the number of "sticks" on the given joystick.

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_get_num_joysticks

int al_get_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_release_joystick

void al_release_joystick(ALLEGRO_JOYSTICK *joy)

Release a previously 'gotten' joystick object.

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_get_joystick_event_source

ALLEGRO_EVENT_SOURCE *al_get_joystick_event_source(ALLEGRO_JOYSTICK *joystick)

Retrieve the associated event source.

Last updated: 2009-08-09 08:22:39 UTC