Mouse

These functions are declared in the main Allegro header file:

#include <allegro5/allegro.h>

ALLEGRO_MOUSE_STATE

typedef struct ALLEGRO_MOUSE_STATE ALLEGRO_MOUSE_STATE;

Public fields (read only):

buttons - mouse buttons

See also: al_get_mouse_state, al_get_mouse_state_axis, al_mouse_button_down

al_install_mouse

bool al_install_mouse(void)

Install a mouse driver.

Returns true if successful. If a driver was already installed, nothing happens and true is returned.

al_is_mouse_installed

bool al_is_mouse_installed(void)

Returns true if al_install_mouse was called successfully.

al_uninstall_mouse

void al_uninstall_mouse(void)

Uninstalls the active mouse driver, if any. This will automatically unregister the mouse event source with any event queues.

This function is automatically called when Allegro is shut down.

al_get_mouse_num_axes

unsigned int al_get_mouse_num_axes(void)

Return the number of buttons on the mouse.

al_get_mouse_num_buttons

unsigned int al_get_mouse_num_buttons(void)

Return the number of buttons on the mouse.

al_get_mouse_state

void al_get_mouse_state(ALLEGRO_MOUSE_STATE *ret_state)

Save the state of the mouse specified at the time the function is called into the given structure.

See also: ALLEGRO_MOUSE_STATE, al_get_mouse_state_axis

al_get_mouse_state_axis

int al_get_mouse_state_axis(ALLEGRO_MOUSE_STATE *ret_state, int axis)

Extract the mouse axis value from the saved state.

See also: ALLEGRO_MOUSE_STATE, al_get_mouse_state, al_mouse_button_down

al_mouse_button_down

bool al_mouse_button_down(ALLEGRO_MOUSE_STATE *state, int button)

Return true if the mouse button specified was held down in the state specified.

See also: ALLEGRO_MOUSE_STATE, al_get_mouse_state, al_get_mouse_state_axis

al_set_mouse_xy

bool al_set_mouse_xy(ALLEGRO_DISPLAY *display, int x, int y)

Try to position the mouse at the given coordinates on the given display. The mouse movement resulting from a successful move will generate an ALLEGRO_EVENT_MOUSE_WARPED event.

Returns true on success, false on failure.

See also: al_set_mouse_z, al_set_mouse_w

al_set_mouse_z

bool al_set_mouse_z(int z)

Set the mouse wheel position to the given value.

Returns true on success, false on failure.

See also: al_set_mouse_w

al_set_mouse_w

bool al_set_mouse_w(int w)

Set the second mouse wheel position to the given value.

Returns true on success, false on failure.

See also: al_set_mouse_z

al_set_mouse_axis

bool al_set_mouse_axis(int which, int value)

Set the given mouse axis to the given value.

The axis number must not be 0 or 1, which are the X and Y axes. Use al_set_mouse_xy for that.

Returns true on success, false on failure.

See also: al_set_mouse_xy, al_set_mouse_z, al_set_mouse_w

al_get_mouse_event_source

ALLEGRO_EVENT_SOURCE *al_get_mouse_event_source(void)

Retrieve the mouse event source.

Returns NULL if the mouse subsystem was not installed.

Mouse cursors

al_create_mouse_cursor

ALLEGRO_MOUSE_CURSOR *al_create_mouse_cursor(ALLEGRO_BITMAP *bmp,
   int x_focus, int y_focus)

Create a mouse cursor from the bitmap provided.

Returns a pointer to the cursor on success, or NULL on failure.

See also: al_set_mouse_cursor, al_destroy_mouse_cursor

al_destroy_mouse_cursor

void al_destroy_mouse_cursor(ALLEGRO_MOUSE_CURSOR *cursor)

Free the memory used by the given cursor.

Has no effect if cursor is NULL.

See also: al_create_mouse_cursor

al_set_mouse_cursor

bool al_set_mouse_cursor(ALLEGRO_DISPLAY *display, ALLEGRO_MOUSE_CURSOR *cursor)

Set the given mouse cursor to be the current mouse cursor for the given display.

If the cursor is currently 'shown' (as opposed to 'hidden') the change is immediately visible.

Returns true on success, false on failure.

See also: al_set_system_mouse_cursor, al_show_mouse_cursor, al_hide_mouse_cursor

al_set_system_mouse_cursor

bool al_set_system_mouse_cursor(ALLEGRO_DISPLAY *display,
   ALLEGRO_SYSTEM_MOUSE_CURSOR cursor_id)

Set the given system mouse cursor to be the current mouse cursor for the given display. If the cursor is currently 'shown' (as opposed to 'hidden') the change is immediately visible.

If the cursor doesn't exist on the current platform another cursor will be silently be substituted.

The cursors are:

  • ALLEGRO_SYSTEM_MOUSE_CURSOR_DEFAULT
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_ARROW
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_BUSY
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_QUESTION
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_EDIT
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_MOVE
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_N
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_W
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_S
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_E
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NW
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_SW
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_SE
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NE
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_PROGRESS
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_PRECISION
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_LINK
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_ALT_SELECT
  • ALLEGRO_SYSTEM_MOUSE_CURSOR_UNAVAILABLE

Returns true on success, false on failure.

See also: al_set_mouse_cursor, al_show_mouse_cursor, al_hide_mouse_cursor

al_get_mouse_cursor_position

bool al_get_mouse_cursor_position(int *ret_x, int *ret_y)

On platforms where this information is available, this function returns the global location of the mouse cursor, relative to the desktop. You should not normally use this function, as the information is not useful except for special scenarios as moving a window.

Returns true on success, false on failure.

al_hide_mouse_cursor

bool al_hide_mouse_cursor(ALLEGRO_DISPLAY *display)

Hide the mouse cursor in the given display. This has no effect on what the current mouse cursor looks like; it just makes it disappear.

Returns true on success (or if the cursor already was hidden), false otherwise.

See also: al_show_mouse_cursor

al_show_mouse_cursor

bool al_show_mouse_cursor(ALLEGRO_DISPLAY *display)

Make a mouse cursor visible in the given display.

Returns true if a mouse cursor is shown as a result of the call (or one already was visible), false otherwise.

See also: al_hide_mouse_cursor

Allegro version 4.9.21 (WIP) - Last updated: 2010-07-24 19:05:33 UTC