poll_mouse(3)

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

πŸ’– poll_mouse(3) πŸ’–

okay bestie, we're in the Allegro manual today, and this one is from the Allegro game programming library β€” yes, that Allegro, the one your gamedev mutuals keep posting about. let's get into it πŸŽ€


✨ SYNOPSIS ✨

#include <allegro.h>

int poll_mouse();

that's it. that's the whole vibe. one line of C and it's lowkey carrying your entire cursor situation πŸ¦‹


🌸 DESCRIPTION 🌸

so here's the tea. wherever possible, Allegro reads your mouse input asynchronously β€” meaning it's peeking at it from inside an interrupt handler, doing the work behind your back, main character energy, no help required from you πŸ’…

but on some platforms that may not be possible. and when that happens? it's giving you have to do it, bestie. you must call this routine at regular intervals to update the mouse state variables. that's the whole job. that's the assignment.

and now the part that's actually kind of iconic β€” the way that Allegro lets you test your mouse polling code even if you're programming on a platform that doesn't require it?? because after the first time you call this function, Allegro will switch into polling mode. periodt. and from that point onwards, you have to call this routine in order to get any mouse input at all, regardless of whether the current driver actually needs to be polled or not.

πŸ™ˆ no cap: once you've called it one single time, there's no going back to the free async life. it's polling mode forever now. that's the deal. that's the trade. iykyk.

⭐ RETURN VALUE ⭐

  • zero on success ✨ slay
  • a negative number on failure β€” specifically, like, no mouse driver installed 😭 so if you get a negative back, check your driver situation fr fr

🫢 SEE ALSO 🫢

go read mouse_needs_poll(3) next if you're nosy about whether your platform is one of the poll-requiring ones πŸ‘‘ it's literally the sibling of this function.


and that's the page bestie πŸ’– this whole thing lives in Allegro version 4.4.3, so if you're out here on some other version, maybe double-check before you @ me. mwah, go poll responsibly πŸŒˆπŸŽ€πŸ¦‹

πŸ“¦ where this page comes from