poll_keyboard(3)

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

✨ poll_keyboard ✨

okay bestie, gather round, because we're talking about poll_keyboard from the Allegro manual β€” aka the Allegro game programming library's lil keyboard-checking baddie πŸ’…


🌸 NAME 🌸

poll_keyboard β€” she polls the keyboard. that's it, that's the job. Allegro game programming library energy πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

int poll_keyboard();

πŸ’– DESCRIPTION πŸ’–

so here's the tea: wherever possible, Allegro reads your keyboard input asynchronously β€” like, from inside an interrupt handler (iykyk, very main character of her). but on some platforms that's just not doable 😭 and in that case you have to call this routine at regular intervals so the keyboard state variables actually get updated. no call, no update. periodt.

and here's the part that's lowkey iconic: to help you test your keyboard polling code even if you're programming on a platform that doesn't require it β€” after the first time you call this function, Allegro switches into polling mode πŸ”₯ so from that point onwards you will have to call this routine to get any keyboard input at all, regardless of whether the current driver actually needs to be polled or not. like, she commits. no take-backs. πŸ™ˆ

also, quick PSA for your convenience: keypressed(), readkey(), and ureadkey() call poll_keyboard() automatically 🫢 so you only actually need to use this function when you're out here accessing the key[] array and the key_shifts variable. those two? they don't get the free ride. ngl.


⭐ RETURN VALUE ⭐

returns zero on success πŸŽ‰ or a negative number on failure β€” which fr fr means there's no keyboard driver installed. tragic. πŸ’€


🌈 SEE ALSO 🌈


ok that's the whole page bestie, every flag and fact accounted for, no cap πŸ§šπŸ’œ

and that's a wrap on this one β€” shoutout to Allegro, version 4.4.3 for bringing us this absolute queen of a function. go poll something. slay πŸ‘‘βœ¨

πŸ“¦ where this page comes from