|
EventsALLEGRO_EVENT
An ALLEGRO_EVENT is a union of all builtin event structures, i.e. it is an object large enough to hold the data of any event type. All events have the following fields in common:
By examining the type field you can then access type-specific fields. The any.source field tells you which event source generated that particular event. The any.timestamp field tells you when the event was generated. The time is referenced to the same starting point as al_current_time(). ALLEGRO_EVENT_SOURCE
An event source is any object which can generate events. Event sources are usually referred to by distinct types, e.g. ALLEGRO_KEYBOARD, but can be casted to ALLEGRO_EVENT_SOURCE when used in contexts that accept generic event sources. Each event is of one of the following types
ALLEGRO_EVENT_TYPE
An integer used to distinguish between different types of events. ALLEGRO_GET_EVENT_TYPE
Make an event type identifier, which is a 32-bit integer. Usually this will be made from four 8-bit character codes, for example:
You should try to make your IDs unique so they don't clash with any 3rd party code you may be using. IDs less than 1024 are reserved for Allegro or its addons. al_create_event_queue
Create a new, empty event queue, returning a pointer to object if successful. Returns NULL on error. al_create_user_event_source
Allocate an event source for emitting user events. al_destroy_event_queue
Destroy the event queue specified. All event sources currently registered with the queue will be automatically unregistered before the queue is destroyed. al_destroy_user_event_source
Destroy an event source created with al_create_user_event_source. al_drop_next_event
Drop the next event packet from the queue. If the queue is empty, nothing happens. Returns true iff an event was dropped. al_emit_user_event
Emit a user event. The event source must have been created with al_create_user_event_source. Some fields of the event being passed in may be modified. Returns Reference counting will be performed on the event if You need to call al_unref_user_event when you are done with a reference counted user event that you have gotten from al_get_next_event, al_peek_next_event, al_wait_for_event, etc. You may, but do not need to, call al_unref_user_event on non-reference counted user events. al_event_queue_is_empty
Return true if the event queue specified is currently empty. al_flush_event_queue
Drops all events, if any, from the queue. al_get_next_event
Take the next event packet out of the event queue specified, and copy the contents into RET_EVENT, returning true. The original event packet will be removed from the queue. If the event queue is empty, return false and the contents of RET_EVENT are unspecified. al_peek_next_event
Copy the contents of the next event packet in the event queue specified into RET_EVENT and return true. The original event packet will remain at the head of the queue. If the event queue is actually empty, this function returns false and the contents of RET_EVENT are unspecified. al_register_event_source
Register the event source with the event queue specified. An event source may be registered with any number of event queues simultaneously, or none. Trying to register an event source with the same event queue more than once does nothing. al_unref_user_event
Unreference a user-defined event. This must be called on any user event that you get from al_get_next_event, al_peek_next_event, al_wait_for_event, etc. which is reference counted. This function does nothing if the event is not reference counted. See also: al_emit_user_event. al_unregister_event_source
Unregister an event source with an event queue. If the event source is not actually registered with the event queue, nothing happens. If the queue had any events in it which originated from the event source, they will no longer be in the queue after this call. al_wait_for_event
Wait until the event queue specified is non-empty. If RET_EVENT is not NULL, the first event packet in the queue will be copied into RET_EVENT and removed from the queue. If RET_EVENT is NULL the first event packet is left at the head of the queue. al_wait_for_event_timed
Wait until the event queue specified is non-empty. If RET_EVENT is not NULL, the first event packet in the queue will be copied into RET_EVENT and removed from the queue. If RET_EVENT is NULL the first event packet is left at the head of the queue. TIMEOUT_MSECS determines approximately how many seconds to wait. If the call times out, false is returned. Otherwise true is returned. al_wait_for_event_until
|
Last updated: 2009-07-05 05:34:15 UTC