install_keyboard(3)

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

πŸ’– install_keyboard(3) πŸ’–

okay bestie, gather round, we're talking about install_keyboard from the Allegro manual (that's the 3 in the parentheses, iykyk β€” it's a library function, not a command you type in your shell 🐚✨).


🌸 NAME 🌸

install_keyboard β€” installs the Allegro keyboard interrupt handler. that's it, that's the whole vibe πŸ’…


✨ SYNOPSIS ✨

#include <allegro.h>

int install_keyboard();

πŸ¦‹ DESCRIPTION πŸ¦‹

So basically: this function installs the Allegro keyboard interrupt handler. πŸŽ€ And you must call it before you use any of the keyboard input routines, okay? No skipping ahead, babe.

And here's the tea β˜•: once you've set up the Allegro handler, you can no longer use operating system calls or C library functions to access the keyboard. like, it's taken. it's Allegro's keyboard now. periodt. 🫢

Also β€” heads up, this part is lowkey important β€” on some platforms the keyboard won't work unless you've set a graphics mode. Even if this function returns a success value before you call set_gfx_mode. 😭 That can happen in environments with graphic windowed modes, because Allegro usually reads the keyboard through the graphical window (which only appears after the set_gfx_mode call). it's giving "technically succeeded but not actually ready" πŸ’€

Example, bestie:

allegro_init();
install_timer();
install_keyboard();
/* We are not 100% sure we can read the keyboard yet! */
if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0)
   abort_on_error("Couldn't set graphic mode!");

/* Now we are guaranteed to be able to read the keyboard. */
readkey();

see how the comment literally says you're not 100% sure yet?? yeah. she's honest. 🌈


πŸ‘‘ RETURN VALUE πŸ‘‘

Returns zero on success ✨, or a negative number on failure. But honestly? you may decide not to even check the return value, because this function is very unlikely to fail. main character energy β€” she just works. πŸ’… (still, checking is free, no cap.)


🌟 SEE ALSO 🌟


and that's the whole page, bestie!! πŸŽ€ this was Allegro version 4.4.3 talking about install_keyboard(3) β€” go forth and install that keyboard handler before literally anything else, mwah πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from