ALLEGRO_USER_EVENT(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– ALLEGRO_USER_EVENT πŸ’–

okay bestie, welcome to the Allegro 5 API β€” yes, that's the manual name, we're keeping it, and no we are not skipping anything. this is the whole page, every single field, every single line of code, all of it. slay. 🫢


✨ NAME ✨

ALLEGRO_USER_EVENT β€” the Allegro 5 API struct that lets you be the one cooking up events, not the library. main character energy, fr fr. πŸ‘‘


🌈 SYNOPSIS 🌈

#include <allegro5/allegro.h>

typedef struct ALLEGRO_USER_EVENT ALLEGRO_USER_EVENT;

that's it. that's the whole vibe. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so like β€” this is an event structure that can be emitted by user event sources. meaning: not the system, not the OS, not Allegro doing its thing behind the scenes β€” you. you're the event source now. iconic. ✨

these are the public fields, and bestie, we are listing all of them:

  • ALLEGRO_EVENT_SOURCE *source;
  • intptr_t data1;
  • intptr_t data2;
  • intptr_t data3;
  • intptr_t data4;

like every other event type out there, this structure is a part of the ALLEGRO_EVENT union. so if you've got an ALLEGRO_EVENT variable called ev, you reach into it like this:

  • ev.user.source
  • ev.user.data1
  • ev.user.data2
  • ev.user.data3
  • ev.user.data4

no cap, that .user. is doing all the work. πŸŽ€


🌸 how to actually make one 🌸

to create a new user event you would do this β€” copy it exactly, it's not a suggestion, it's the recipe:

ALLEGRO_EVENT_SOURCE my_event_source;
ALLEGRO_EVENT my_event;
float some_var;

al_init_user_event_source(&my_event_source);

my_event.user.type = ALLEGRO_GET_EVENT_TYPE('M','I','N','E');
my_event.user.data1 = 1;
my_event.user.data2 = &some_var;

al_emit_user_event(&my_event_source, &my_event, NULL);

look at that. al_init_user_event_source, a type tagged 'M','I','N','E', some data, and then al_emit_user_event. chef's kiss. πŸ˜­πŸ’–


🧚 the rules, bestie 🧚

event type identifiers for user events are assigned by the user. that's you. that's your job now. πŸ‘‘

please please please go read the docs for ALLEGRO_GET_EVENT_TYPE(3alleg5) because it lays out the rules you should follow when assigning those identifiers. not optional, don't freestyle it, iykyk. πŸ’€


πŸ’œ SEE ALSO πŸ’œ


and that's the page!! πŸŽ€ this was the Allegro reference manual, ALLEGRO_USER_EVENT(3alleg5) β€” go forth and emit your own events, bestie, you ate. πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from