select_mouse_cursor(3alleg4)

✨ select_mouse_cursor ✨

okay bestie, welcome to the select_mouse_cursor(3alleg4) page from the Allegro manual πŸ’– this one is short, sweet, and lowkey iconic β€” it's all about whose mouse cursor you're looking at: the OS's own sparkly native one, or Allegro's homemade one. Let's get into it πŸŽ€


🌸 NAME 🌸

select_mouse_cursor β€” tells Allegro to select software or hardware cursor drawing.


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

void select_mouse_cursor(int cursor);

πŸ’… DESCRIPTION πŸ’…

So here's the vibe: this function lets you use the operating system's native mouse cursors instead of some custom cursor you cooked up yourself. That's the main character energy right there 🫢

But β€” and this is important β€” you have to turn that functionality on first by calling enable_hardware_cursor() beforehand. Like, you can't just walk in and expect the native cursor to show up. Enable it first, bestie.

If the operating system doesn't support this whole native-cursor thing, or if you never enabled it, then Allegro will just substitute its own cursor images instead. No drama, it just does its own thing. And if you wanna change those substitute images, you can do that with set_mouse_cursor_bitmap() ✨

Heads up: the effects of this function are not apparent until you call show_mouse(). So don't sit there staring at your screen wondering why nothing changed β€” you forgot the show_mouse() call, bestie 😭

And if you wanna know whether you're actually getting the operating system's native cursor or whether Allegro made a substitution, you can check the GFX_SYSTEM_CURSOR flag inside gfx_capabilities β€” but only after you've called show_mouse(). Timing matters, fr fr.

The cursor argument picks which type of cursor gets displayed:

  • MOUSE_CURSOR_NONE β€” selects an invisible mouse cursor. So like, in that sense it's basically the same as calling show_mouse(NULL) πŸ‘»
  • MOUSE_CURSOR_ALLEGRO β€” selects the custom Allegro cursor, i.e. the one you set with set_mouse_sprite().
  • MOUSE_CURSOR_ARROW β€” the operating system's default arrow cursor. classic. the original. πŸ’…
  • MOUSE_CURSOR_BUSY β€” the operating system's default busy cursor (hourglass). you know, the "girl help I'm working on it" one ⏳
  • MOUSE_CURSOR_QUESTION β€” the operating system's default question cursor (arrow with question mark). it's giving confused 🧚
  • MOUSE_CURSOR_EDIT β€” the operating system's default edit cursor (vertical bar). text-entry realness ✍️

Example time, periodt:

/* 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);

πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, bestie πŸŽ€ this was Allegro version 4.4.3, and the original footer was all like select_mouse_cursor(3alleg4) β€” so go forth, pick your cursor, and slay βœ¨πŸ‘‘