ALLEGRO_GET_EVENT_TYPE(3alleg5)
β¨ ALLEGRO_GET_EVENT_TYPE β¨
okay so bestie, welcome to the Allegro 5 API reference manual, and today's main character is ALLEGRO_GET_EVENT_TYPE. it's giving "tiny macro, huge responsibility" π
πΈ SYNOPSIS πΈ
#include <allegro5/allegro.h>
#define ALLEGRO_GET_EVENT_TYPE(a, b, c, d) AL_ID(a, b, c, d)
like. that's it. that's the whole vibe. π
π DESCRIPTION π
so what this macro does is make an event type identifier, which is a 32-bit integer. periodt.
usually β but not necessarily β that identifier gets built out of four 8-bit character codes. for example:
#define MY_EVENT_TYPE ALLEGRO_GET_EVENT_TYPE('M','I','N','E')
iconic. love that for us. π¦
β οΈ okay important thing, no cap: IDs less than 1024 are reserved for Allegro or its addons. do not use anything lower than ALLEGRO_GET_EVENT_TYPE(0, 0, 4, 0). that range is not yours, bestie, it's spoken for. π
you should also try to make your IDs unique so they don't clash with any 3rd party code you might be using. and like β be creative. numbering from 1024 is not creative. that's the bare minimum and we all know it. π
if you need multiple identifiers, you could define them like this:
#define BASE_EVENT ALLEGRO_GET_EVENT_TYPE('M','I','N','E')
#define BARK_EVENT (BASE_EVENT + 0)
#define MEOW_EVENT (BASE_EVENT + 1)
#define SQUAWK_EVENT (BASE_EVENT + 2)
/* Alternatively */
enum {
BARK_EVENT = ALLEGRO_GET_EVENT_TYPE('M','I','N','E'),
MEOW_EVENT,
SQUAWK_EVENT
};
see how the enum one just... keeps going? no explicit values after the first? yeah. it's giving β¨implicitβ¨ and honestly it ate. π
π SEE ALSO π
and that's the whole page, bestie. this was the Allegro reference manual, page ALLEGRO_GET_EVENT_TYPE(3alleg5) β go forth and make your event types unique, stay above 1024, and absolutely do not be boring about it. mwah. ππ§β¨
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms