1#include <allegro5/allegro.h>
2#include <allegro5/allegro_native_dialog.h>
3
4#define MY_COMPLEX_EVENT_TYPE ALLEGRO_GET_EVENT_TYPE('m', 'c', 'e', 't')
5
6ALLEGRO_EVENT_QUEUE *m_queue
;
7ALLEGRO_EVENT_SOURCE m_userSrc
;
8ALLEGRO_EVENT m_userEvent
;
9ALLEGRO_EVENT event
;
10
11int cnt
= 0;
12
13static void my_event_dtor
(ALLEGRO_USER_EVENT *ev
)
14{
15al_show_native_message_box(NULL, NULL,
"Event",
"MY_COMPLEX_EVENT_TYPE my_event_dtor called", NULL, ALLEGRO_MESSAGEBOX_ERROR
);
16}
17
18int main
(int argc,
char **argv
)
19{
20 al_init();
21 al_init_user_event_source(&m_userSrc
);
22 m_queue
= al_create_event_queue();
23 al_register_event_source(m_queue,
&m_userSrc
);
24
25 m_userEvent.user.type
= MY_COMPLEX_EVENT_TYPE
;
26 al_emit_user_event(&m_userSrc,
&m_userEvent, my_event_dtor
);
27 al_emit_user_event(&m_userSrc,
&m_userEvent, my_event_dtor
);
28 al_emit_user_event(&m_userSrc,
&m_userEvent, my_event_dtor
);
29
30 while (true)
31 {
32 al_wait_for_event(m_queue,
&event
);
33 if (event.type
== MY_COMPLEX_EVENT_TYPE
)
34 {
35 al_show_native_message_box(NULL, NULL,
"Event",
"MY_COMPLEX_EVENT_TYPE", NULL, ALLEGRO_MESSAGEBOX_ERROR
);
36 al_unref_user_event(&event.user
);
37 }
38 }
39 return 0;
40}