keyboard_ucallback(3)
πΈ NAME πΈ
keyboard_ucallback β your very own user specified unicode keyboard callback handler π and it lives in the Allegro game programming library, bestie.
β¨ SYNOPSIS β¨
#include <allegro.h>
extern int (*keyboard_ucallback)(int key, int *scancode);
π DESCRIPTION π
Okay so. This is the unicode-aware version of keyboard_callback(). The way that it works is: if you set it, the keyboard handler calls it in response to every single keypress. Every one. No skips. π
What gets passed in is the character value and the scancode that are about to be added into the input buffer. Your function is allowed to modify the scancode value, and it returns a new or modified key code. That's the whole deal β you get a say before it lands in the buffer. π
And here's the lil trapdoor: if it both sets the scancode to zero and returns zero, the keypress gets ignored entirely. Poof. Gone. Not in the buffer, not your problem. π«₯
β οΈ Real talk though β this routine executes in an interrupt context, so it has to be in locked memory. Not optional. Do not skip this. π
Example, because a vibe check is always better with code:
int silence_g_key(int key, int *scancode)
{
if (key == 'g') {
*scancode = 0;
return 0;
}
return key;
} END_OF_FUNCTION(silence_g_key)
...
install_timer();
LOCK_FUNCTION(silence_g_key);
install_keyboard();
keyboard_ucallback = silence_g_key;
Note that this keyboard callback has priority over the non unicode callback. So if you set both of them? Only the unicode one will work. The other one is just standing there like π§. Sorry babe.
π¦ SEE ALSO π¦
Okay that's the whole page, bestie, you ate it π this was Allegro, version 4.4.3, and it's keyboard_ucallback(3) β go lock that memory and slay β¨π
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms