Mouse routines
Allegro provides functions for reading the mouse state and displaying a mouse
cursor on-screen. You can read the absolute position of the mouse and the
state of the mouse buttons from global variables. Additionally, you can read
the mouse position difference as mouse mickeys, which is the number of pixels
the cursor moved since the last time this information was read.
Allegro offers three ways to display the mouse cursor:
-
Standard Allegro cursor
Allegro is responsible for drawing the mouse cursor from a timer. Use
set_mouse_sprite() and show_mouse() to define your own cursor and display
it on the screen.
You need to call scare_mouse()/unscare_mouse() to hide the mouse cursor
whenever you draw to the screen.
-
Custom operating system cursor (hardware cursor)
Allegro will let the operating system draw the mouse cursor. Use
set_mouse_sprite() and show_mouse() (or show_os_cursor) to define your
own cursor and display it on the screen. Not all graphics drivers are
capable of this and some may only be able to display cursors upto a
certain size. Allegro will fall back on its own cursor drawing if it
cannot let the OS handle this. On some platforms, the hardware cursor
is incompatible with get_mouse_mickeys() and it is therefor disabled by
default. In such cases you need to call enable_hardware_cursor() to
enable it explicitly.
-
Default operating system cursor
Allegro will not draw its own cursor, but use the operating system default
cursor. You can use the select_mouse_cursor() function to select the cursor
shape to display. As with custom operating system cursors, you need to call
enable_hardware_cursor() before you can use this. Or you can use the
low level show_os_cursor() function.
Not all drivers will support all functionality. See the platform specific
information for more details.