key_shifts(3)

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

✨ 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_FLAG
  • KB_CTRL_FLAG
  • KB_ALT_FLAG
  • KB_LWIN_FLAG
  • KB_RWIN_FLAG
  • KB_MENU_FLAG
  • KB_COMMAND_FLAG
  • KB_SCROLOCK_FLAG
  • KB_NUMLOCK_FLAG
  • KB_CAPSLOCK_FLAG
  • KB_INALTSEQ_FLAG
  • KB_ACCENT1_FLAG
  • KB_ACCENT2_FLAG
  • KB_ACCENT3_FLAG
  • KB_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 the poll_keyboard() thing when keyboard_needs_poll() says TRUE, 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