select_mouse_cursor(3)
π select_mouse_cursor β the Allegro manual, but make it cute π
okay bestie, gather round, because this is select_mouse_cursor(3) from the Allegro manual and it's literally the function that decides whether your mouse pointer is the OS's own little diva or Allegro's homemade bestie. sit with me, we're gonna slay this π
β¨ NAME β¨
select_mouse_cursor β tells Allegro to select software or hardware cursor drawing. that's it, that's the whole vibe check π
πΈ SYNOPSIS πΈ
#include <allegro.h>
void select_mouse_cursor(int cursor);
no cap, that's the whole signature. one int, one dream π
π¦ DESCRIPTION π¦
so like, this function lets you use the operating system's native mouse cursors instead of some custom cursor you cooked up yourself. iconic behaviour, fr fr.
BUT β and this is the part where you have to pay attention, bestie β you have to enable that functionality first by calling enable_hardware_cursor() beforehand. if you skip that step, it's giving nothing. the OS won't give you its cute cursors, and Allegro will just substitute its own cursor images instead. and if the operating system literally doesn't support this whole thing? same deal, Allegro subs in its own images. no drama, just fallback energy π«Ά
you can change those substitute images using set_mouse_cursor_bitmap() β that's your glow-up tool for the backup cursors.
β οΈ also!! note that the effects of this function are not apparent untilshow_mouse()is called. so don't be out here calling this and staring at your screen like ποΈπποΈ wondering why nothing changed. callshow_mouse(), then we talk.
and if you wanna know whether the operating system's native cursor is actually being used, or whether Allegro made a substitution (the betrayal π), you can check the GFX_SYSTEM_CURSOR flag in gfx_capabilities β but only after calling show_mouse(). timing matters, babes.
so the cursor argument selects the type of cursor to be displayed:
MOUSE_CURSOR_NONEβ selects an invisible mouse cursor. in that sense, it is similar to callingshow_mouse(NULL). ghost mode. you're literally not there π»MOUSE_CURSOR_ALLEGROβ selects the custom Allegro cursor, i.e. the one that you set withset_mouse_sprite(). this is your cursor, your art, your main character moment β¨MOUSE_CURSOR_ARROWβ the operating system default arrow cursor. classic. the vanilla latte of cursors π₯€MOUSE_CURSOR_BUSYβ the operating system defaultbusycursor (hourglass). it's giving "loading, please hold, i'm doing my best" β³MOUSE_CURSOR_QUESTIONβ the operating system defaultquestioncursor (arrow with question mark). the "huh??" era βMOUSE_CURSOR_EDITβ the operating system defaulteditcursor (vertical bar). text-entry core βοΈ
π Example π
here's the moment you've been waiting for, the code block, the whole reason you're here:
/* initialize mouse sub-system */
install_mouse();
enable_hardware_cursor();
/* Set busy pointer */
select_mouse_cursor(MOUSE_CURSOR_BUSY);
show_mouse(screen);
/* Initialize stuff */
...
/* Set normal arrow pointer */
select_mouse_cursor(MOUSE_CURSOR_ARROW);
look at that. busy pointer while you're setting things up, then back to the arrow when you're done. that's called β¨user experienceβ¨ and she ate π
π SEE ALSO π
the whole friend group, no one left out, we don't do that here:
install_mouse(3)show_mouse(3)set_mouse_sprite(3)gfx_capabilities(3)enable_hardware_cursor(3)set_mouse_cursor_bitmap(3)show_os_cursor(3)exsyscur(3)
and that's the page, bestie!! this whole thing came to you courtesy of the <strong>Allegro</strong> manual, <strong>version 4.4.3</strong>, dated right there in the footer next to select_mouse_cursor(3) β so if it's broken, it's not my fault, go read the source ππ
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms