1ALLEGRO_USER_EVENT(3) ALLEGRO_USER_EVENT(3)
2
3
4
6 ALLEGRO_USER_EVENT - Allegro 5 API
7
9 #include <allegro5/allegro.h>
10
11 typedef struct ALLEGRO_USER_EVENT ALLEGRO_USER_EVENT;
12
14 An event structure that can be emitted by user event sources. These
15 are the public fields:
16
17 · ALLEGRO_EVENT_SOURCE *source;
18
19 · intptr_t data1;
20
21 · intptr_t data2;
22
23 · intptr_t data3;
24
25 · intptr_t data4;
26
27 Like all other event types this structure is a part of the ALLE‐
28 GRO_EVENT union. To access the fields in an ALLEGRO_EVENT variable ev,
29 you would use:
30
31 · ev.user.source
32
33 · ev.user.data1
34
35 · ev.user.data2
36
37 · ev.user.data3
38
39 · ev.user.data4
40
41 To create a new user event you would do this:
42
43 ALLEGRO_EVENT_SOURCE my_event_source;
44 ALLEGRO_EVENT my_event;
45 float some_var;
46
47 al_init_user_event_source(&my_event_source);
48
49 my_event.user.type = ALLEGRO_GET_EVENT_TYPE('M','I','N','E');
50 my_event.user.data1 = 1;
51 my_event.user.data2 = &some_var;
52
53 al_emit_user_event(&my_event_source, &my_event, NULL);
54
55 Event type identifiers for user events are assigned by the user.
56 Please see the documentation for ALLEGRO_GET_EVENT_TYPE(3) for the
57 rules you should follow when assigning identifiers.
58
60 al_emit_user_event(3), ALLEGRO_GET_EVENT_TYPE(3), al_init_us‐
61 er_event_source(3)
62
63
64
65Allegro reference manual ALLEGRO_USER_EVENT(3)