|
User Events? |
Aaron Santiago
Member #12,074
June 2010
|
I tried reading it in the docs, but I became hopelessly lost, really really fast, right around here: |
SiegeLord
Member #7,827
October 2006
|
RTFM some more? There's more to the documentation than the function signature... Essentially though, the use case would be like this: ALLEGRO_EVENT_SOURCE source; al_init_user_event_source(&source); ALLEGRO_EVENT_QUEUE* queue = al_create_event_queue(); al_register_event_source(queue, &source); ALLEGRO_EVENT event; event.user.data1 = 5; al_emit_user_event(&source, &event, 0); ALLEGRO_EVENT event2; al_wait_for_event(queue, &event2); printf("%d\n", (int)event2.user.data1); // will print 5
"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Aaron Santiago
Member #12,074
June 2010
|
So if a user source can emit normal events, then what's the point of user events? |
SiegeLord
Member #7,827
October 2006
|
Aaron Santiago said: So if a user source can emit normal events How did you arrive at this conclusion? A user source can only emit user events. EDIT: Either way, user events are useful because they have 4 separate data fields that you can fill with anything you desire. No other event type has the same. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Aaron Santiago
Member #12,074
June 2010
|
That's what the code you posted did, it emitted a normal event. ALLEGRO_EVENT event; ALLEGRO_USER_EVENT userEvent; //?
|
Evert
Member #794
November 2000
|
Aaron Santiago said: That's what the code you posted did, it emitted a normal event.
You're misunderstaning. |
Aaron Santiago
Member #12,074
June 2010
|
That makes sense. |
Matthew Leverton
Supreme Loser
January 1999
|
Have you looked at ex_user_events.c? |
Edgar Reynaldo
Major Reynaldo
May 2007
|
I don't think the documentation for user events is that great either. The manual entry for ALLEGRO_EVENT doesn't mention how to test for a user event type when processing events from a queue. Are we supposed to set event.type to some magic number that we remember later or what? Also, the 'user' field of an ALLEGRO_EVENT that represents an ALLEGRO_USER_EVENT is not documented anywhere either, and it should probably be on the ALLEGRO_EVENT manual page. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Aaron Santiago
Member #12,074
June 2010
|
Yeah, the user field kind of blew my mind a little. There's like 0 documentation on this, really. |
|