AL_INIT_USER_EVENT_SOURCE(3)

πŸ“¦
version 5.2.11.3 Β· 3 versions
, in arch rolling

πŸ’– NAME πŸ’–

okay so bestie, this is al_init_user_event_source(3) from the Library Functions Manual β€” the Allegro 5 API function that sets up an event source for emitting user events ✨

✨ SYNOPSIS ✨

#include <allegro5/allegro.h>

void al_init_user_event_source(ALLEGRO_EVENT_SOURCE *src)

πŸ¦‹ DESCRIPTION πŸ¦‹

So what this icon does is initialise an event source for emitting user events. That's the whole vibe. But hear me out: the space for the event source must already have been allocated before you call this. She is not out here doing your malloc for you, bestie β€” she just initialises what's already there πŸ’…

One possible way of creating custom event sources is to derive other structures with ALLEGRO_EVENT_SOURCE at the head, e.g.:

              typedef struct THING THING;

              struct THING {
                  ALLEGRO_EVENT_SOURCE event_source;
                  int field1;
                  int field2;
                  /* etc. */
              };

              THING *create_thing(void)
              {
                  THING *thing = malloc(sizeof(THING));

                  if (thing) {
                      al_init_user_event_source(&thing->event_source);
                      thing->field1 = 0;
                      thing->field2 = 0;
                  }

                  return thing;
              }

The advantage here is that the THING pointer will be the same as the ALLEGRO_EVENT_SOURCE pointer. Events emitted by the event source will have the event source pointer as the source field, from which you can get a pointer to a THING by a simple cast (after you make sure to check that the event is of the correct type). It's giving pointer math but make it cute 😌

However, it is only one technique and you are not obliged to use it. No pressure, bestie β€” do what works for your code 🫢

⚠️ real talk: the user event source will never be destroyed automatically. You must destroy it manually with al_destroy_user_event_source(3). Don't leave her hanging, okay? 😭

🌈 SEE ALSO 🌈


byeee bestie 🫢 this has been the Allegro reference manual (source/version vibes: iconic; date: not listed in this footer, so she's a mystery πŸ’€) β€” now go init that event source and slay βœ¨πŸ’–

πŸ“¦ where this page comes from
  • arch rolling: allegro 5.2.11.3-2 Β· Zlib AND BSD-3-Clause AND OFL-1.1 AND LicenseRef-Custom
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms