select_mouse_cursor(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’– 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 until show_mouse() is called. so don't be out here calling this and staring at your screen like πŸ‘οΈπŸ‘„πŸ‘οΈ wondering why nothing changed. call show_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 calling show_mouse(NULL). ghost mode. you're literally not there πŸ‘»
  • MOUSE_CURSOR_ALLEGRO β€” selects the custom Allegro cursor, i.e. the one that you set with set_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 default busy cursor (hourglass). it's giving "loading, please hold, i'm doing my best" ⏳
  • MOUSE_CURSOR_QUESTION β€” the operating system default question cursor (arrow with question mark). the "huh??" era ❓
  • MOUSE_CURSOR_EDIT β€” the operating system default edit cursor (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:


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