key_shifts(3)
β¨ key_shifts(3) β¨
okay bestie, welcome to the Allegro manual π this one's about key_shifts, and it's giving "tiny variable, huge power" energy, fr fr.
πΈ NAME πΈ
key_shifts β a bitmask holding the current state of all the modifier keys, straight out of the Allegro game programming library π
π¦ SYNOPSIS π¦
#include <allegro.h>
extern volatile int key_shifts;
π DESCRIPTION π
so key_shifts is a bitmask and it's tracking the current state of shift / ctrl / alt, the special Windows keys, and the accent escape characters. all of them. at once. main character energy honestly π
wherever possible, this value gets updated asynchronously β like, it just keeps itself fresh, no effort required, slay. BUT if keyboard_needs_poll() returns TRUE, then nope, you gotta manually call poll_keyboard() yourself to update it with the current input state. no skipping that, bestie, that's the vibe check π«Ά
this bad boy can contain any of these flags:
KB_SHIFT_FLAGKB_CTRL_FLAGKB_ALT_FLAGKB_LWIN_FLAGKB_RWIN_FLAGKB_MENU_FLAGKB_COMMAND_FLAGKB_SCROLOCK_FLAGKB_NUMLOCK_FLAGKB_CAPSLOCK_FLAGKB_INALTSEQ_FLAGKB_ACCENT1_FLAGKB_ACCENT2_FLAGKB_ACCENT3_FLAGKB_ACCENT4_FLAG
π Example π
here's the little scenario, look at it, it ate:
if (key[KEY_W]) {
if (key_shifts & KB_SHIFT_FLAG) {
/* User is pressing shift + W. */
} else {
/* Hmmm... lower case W then. */
}
}
like. it's checking if W is pressed, then peeking at whether shift is ALSO in the mix. iconic. lowercase W erasure otherwise π
π SEE ALSO π
install_keyboard(3), poll_keyboard(3), key(3), excamera(3), exkeys(3)
heads up bestie: don't forget thepoll_keyboard()thing whenkeyboard_needs_poll()saysTRUE, or your modifier state is gonna be lowkey stale π
k bye, this was Allegro version 4.4.3 territory, page key_shifts(3), mwah πβ¨
π¦ 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