|
NAMEALLEGRO_EVENT - Allegro 5 APISYNOPSIS
DESCRIPTIONAn 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_get_time(3). Each event is of one of the following types, with the usable fields given. ALLEGRO_EVENT_JOYSTICK_AXISA joystick axis value changed.
ALLEGRO_EVENT_JOYSTICK_BUTTON_DOWNA joystick button was pressed.
ALLEGRO_EVENT_JOYSTICK_BUTTON_UPA joystick button was released.
ALLEGRO_EVENT_JOYSTICK_CONFIGURATIONA joystick was plugged in or unplugged. See al_reconfigure_joysticks(3) for details.ALLEGRO_EVENT_KEY_DOWNA keyboard key was pressed.
Note: this event is about the physical keys being pressed on the keyboard. Look for ALLEGRO_EVENT_KEY_CHAR events for character input. ALLEGRO_EVENT_KEY_UPA keyboard key was released.
ALLEGRO_EVENT_KEY_CHARA character was typed on the keyboard, or a character was auto-repeated.
Some special keys will set the unichar field to their standard ASCII values: Tab=9, Return=13, Escape=27. In addition if you press the Control key together with A to Z the unichar field will have the values 1 to 26. For example Ctrl-A will set unichar to 1 and Ctrl-H will set it to 8. As of Allegro 5.0.2 there are some inconsistencies in the treatment of Backspace (8 or 127) and Delete (127 or 0) keys on different platforms. These can be worked around by checking the keycode field.
Note: in many input methods, characters are not entered one-for-one with physical key presses. Multiple key presses can combine to generate a single character, e.g. apostrophe + e may produce `é'. Fewer key presses can also generate more characters, e.g. macro sequences expanding to common phrases. ALLEGRO_EVENT_MOUSE_AXESOne or more mouse axis values changed.
Note: Calling al_set_mouse_xy(3) also will result in a change of axis values, but such a change is reported with ALLEGRO_EVENT_MOUSE_WARPED(3) events instead which are identical except for their type. Note: currently mouse.display may be NULL if an event is generated in response to al_set_mouse_axis(3). ALLEGRO_EVENT_MOUSE_BUTTON_DOWNA mouse button was pressed.
ALLEGRO_EVENT_MOUSE_BUTTON_UPA mouse button was released.
ALLEGRO_EVENT_MOUSE_WARPEDal_set_mouse_xy(3) was called to move the mouse. This event is identical to ALLEGRO_EVENT_MOUSE_AXES otherwise.ALLEGRO_EVENT_MOUSE_ENTER_DISPLAYThe mouse cursor entered a window opened by the program.
ALLEGRO_EVENT_MOUSE_LEAVE_DISPLAYThe mouse cursor left the boundaries of a window opened by the program.
ALLEGRO_EVENT_TOUCH_BEGINThe touch input device registered a new touch.
SINCE5.1.0ALLEGRO_EVENT_TOUCH_ENDA touch ended.Has the same fields as ALLEGRO_EVENT_TOUCH_BEGIN(3). SINCE5.1.0ALLEGRO_EVENT_TOUCH_MOVEThe position of a touch changed.Has the same fields as ALLEGRO_EVENT_TOUCH_BEGIN(3). SINCE5.1.0ALLEGRO_EVENT_TOUCH_CANCELA touch was cancelled. This is device specific but could for example mean that a finger moved off the border of the device or moved so fast that it could not be tracked any longer.Has the same fields as ALLEGRO_EVENT_TOUCH_BEGIN(3). SINCE5.1.0ALLEGRO_EVENT_TIMERA [timer]ALLEGRO_TIMER(3) counter incremented.
ALLEGRO_EVENT_DISPLAY_EXPOSEThe display (or a portion thereof) has become visible.
Note: The display needs to be created with ALLEGRO_GENERATE_EXPOSE_EVENTS flag for these events to be generated. ALLEGRO_EVENT_DISPLAY_RESIZEThe window has been resized.
You should normally respond to these events by calling al_acknowledge_resize(3). Note that further resize events may be generated by the time you process the event, so these fields may hold outdated information. ALLEGRO_EVENT_DISPLAY_CLOSEThe close button of the window has been pressed.
ALLEGRO_EVENT_DISPLAY_LOSTWhen using Direct3D, displays can enter a “lost” state. In that state, drawing calls are ignored, and upon entering the state, bitmap’s pixel data can become undefined. Allegro does its best to preserve the correct contents of bitmaps (see the ALLEGRO_NO_PRESERVE_TEXTURE flag) and restore them when the device is “found” (see ALLEGRO_EVENT_DISPLAY_FOUND(3)). However, this is not 100% fool proof (see discussion in al_create_bitmap(3)’s documentation).Note: This event merely means that the display was lost, that is, DirectX suddenly lost the contents of all video bitmaps. In particular, you can keep calling drawing functions – they just most likely won’t do anything. If Allegro’s restoration of the bitmaps works well for you then no further action is required when you receive this event.
ALLEGRO_EVENT_DISPLAY_FOUNDGenerated when a lost device is restored to operating state. See ALLEGRO_EVENT_DISPLAY_LOST(3).
ALLEGRO_EVENT_DISPLAY_SWITCH_OUTThe window is no longer active, that is the user might have clicked into another window or “tabbed” away. In response to this event you might want to call al_clear_keyboard_state(3) (possibly passing display.source as its argument) in order to prevent Allegro’s keyboard state from getting out of sync.
ALLEGRO_EVENT_DISPLAY_SWITCH_INThe window is the active one again.
ALLEGRO_EVENT_DISPLAY_ORIENTATIONGenerated when the rotation or orientation of a display changes.
ALLEGRO_EVENT_DISPLAY_HALT_DRAWINGWhen a display receives this event it should stop doing any drawing and then call al_acknowledge_drawing_halt(3) immediately.This is currently only relevant for Android and iOS. It will be sent when the application is switched to background mode, in addition to ALLEGRO_EVENT_DISPLAY_SWITCH_OUT(3). The latter may also be sent in situations where the application is not active but still should continue drawing, for example when a popup is displayed in front of it. Note: This event means that the next time you call a drawing function, your program will crash. So you must stop drawing and you must immediately reply with al_acknowledge_drawing_halt(3). Allegro sends this event because it cannot handle this automatically. Your program might be doing the drawing in a different thread from the event handling, in which case the drawing thread needs to be signaled to stop drawing before acknowledging this event. Note: Mobile devices usually never quit an application, so to prevent the battery from draining while your application is halted it can be a good idea to call al_stop_timer(3) on all your timers, otherwise they will keep generating events. If you are using audio, you can also stop all audio voices (or pass NULL to al_set_default_voice(3) if you use the default mixer), otherwise Allegro will keep streaming silence to the voice even if the stream or mixer are stopped or detached. SINCE5.1.0SEE ALSOALLEGRO_EVENT_DISPLAY_RESUME_DRAWING(3)ALLEGRO_EVENT_DISPLAY_RESUME_DRAWINGWhen a display receives this event, it may resume drawing again, and it must call al_acknowledge_drawing_resume(3) immediately.This is currently only relevant for Android and iOS. The event will be sent when an application returns from background mode and is allowed to draw to the display again, in addition to ALLEGRO_EVENT_DISPLAY_SWITCH_IN(3). The latter event may also be sent in a situation where the application is already active, for example when a popup in front of it closes. Note: Unlike ALLEGRO_EVENT_DISPLAY_FOUND(3) it is not necessary to reload any bitmaps when you receive this event. SINCE5.1.0SEE ALSOALLEGRO_EVENT_DISPLAY_HALT_DRAWING(3)ALLEGRO_EVENT_DISPLAY_CONNECTEDThis event is sent when a physical display is connected to the device Allegro runs on. Currently, on most platforms, Allegro supports only a single physical display. However, on iOS, a secondary physical display is supported.
SINCE5.1.1ALLEGRO_EVENT_DISPLAY_DISCONNECTEDThis event is sent when a physical display is disconnected from the device Allegro runs on. Currently, on most platforms, Allegro supports only a single physical display. However, on iOS, a secondary physical display is supported.
Visit the GSP FreeBSD Man Page Interface. |