logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

ALLEGRO_EVENT - Allegro 5 API

Description

       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:

       type (ALLEGRO_EVENT_TYPE)
              Indicates the type of event.

       any.source (ALLEGRO_EVENT_SOURCE *)
              The event source which generated the event.

       any.timestamp (double)
              When the event was generated.

       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(3alleg5).

       Each event is of one of the following types, with the usable fields given.

   ALLEGRO_EVENT_JOYSTICK_AXIS
       A joystick axis value changed.

       joystick.id (ALLEGRO_JOYSTICK *)
              The joystick which generated the event.  This is not the same as the event source joystick.source.

       joystick.stick (int)
              The stick number, counting from zero.  Axes on a joystick are grouped into “sticks”.

       joystick.axis (int)
              The axis number on the stick, counting from zero.

       joystick.pos (float)
              The axis position, from -1.0 to +1.0.

   ALLEGRO_EVENT_JOYSTICK_BUTTON_DOWN
       A joystick button was pressed.

       joystick.id (ALLEGRO_JOYSTICK *)
              The joystick which generated the event.

       joystick.button (int)
              The button which was pressed, counting from zero.

   ALLEGRO_EVENT_JOYSTICK_BUTTON_UP
       A joystick button was released.

       joystick.id (ALLEGRO_JOYSTICK *)
              The joystick which generated the event.

       joystick.button (int)
              The button which was released, counting from zero.

   ALLEGRO_EVENT_JOYSTICK_CONFIGURATION
       A joystick was plugged in or unplugged.  See al_reconfigure_joysticks(3alleg5) for details.

   ALLEGRO_EVENT_KEY_DOWN
       A keyboard key was pressed.

       keyboard.keycode (int)
              The code corresponding to the physical key which was pressed.  See the [Key codes] section for the
              list of ALLEGRO_KEY_* constants.

       keyboard.display (ALLEGRO_DISPLAY *)
              The display which had keyboard focus when the event occurred.

              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_UP
       A keyboard key was released.

       keyboard.keycode (int)
              The code corresponding to the physical key which was released.  See the [Key  codes]  section  for
              the list of ALLEGRO_KEY_* constants.

       keyboard.display (ALLEGRO_DISPLAY *)
              The display which had keyboard focus when the event occurred.

   ALLEGRO_EVENT_KEY_CHAR
       A character was typed on the keyboard, or a character was auto-repeated.

       keyboard.keycode (int)
              The  code  corresponding  to the physical key which was last pressed.  See the [Key codes] section
              for the list of ALLEGRO_KEY_* constants.

       keyboard.unichar (int)
              A Unicode code point (character).  This may be zero or negative if the event was generated  for  a
              non-visible  “character”,  such  as  an  arrow or Function key.  In that case you can act upon the
              keycode field.

              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.

       keyboard.modifiers (unsigned)
              This is a bitfield of the modifier keys which were pressed when the event occurred.  See “Keyboard
              modifier flags” for the constants.

       keyboard.repeat (bool)
              Indicates if this is a repeated character.

       keyboard.display (ALLEGRO_DISPLAY *)
              The display which had keyboard focus when the event occurred.

              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_AXES
       One or more mouse axis values changed.

       mouse.x (int)
              x-coordinate

       mouse.y (int)
              y-coordinate

       mouse.z (int)
              z-coordinate.  This usually means the vertical axis of a mouse wheel, where  up  is  positive  and
              down is negative.

       mouse.w (int)
              w-coordinate.  This usually means the horizontal axis of a mouse wheel.

       mouse.dx (int)
              Change in the x-coordinate value since the previous ALLEGRO_EVENT_MOUSE_AXES event.

       mouse.dy (int)
              Change in the y-coordinate value since the previous ALLEGRO_EVENT_MOUSE_AXES event.

       mouse.dz (int)
              Change in the z-coordinate value since the previous ALLEGRO_EVENT_MOUSE_AXES event.

       mouse.dw (int)
              Change in the w-coordinate value since the previous ALLEGRO_EVENT_MOUSE_AXES event.

       mouse.pressure (float)
              Pressure, ranging from 0.0 to 1.0.

       mouse.display (ALLEGRO_DISPLAY *)
              The display which had mouse focus.

              Note:  Calling  al_set_mouse_xy(3alleg5)  also  will result in a change of axis values, but such a
              change is reported with ALLEGRO_EVENT_MOUSE_WARPED(3alleg5) 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(3alleg5).

   ALLEGRO_EVENT_MOUSE_BUTTON_DOWN
       A mouse button was pressed.

       mouse.x (int)
              x-coordinate

       mouse.y (int)
              y-coordinate

       mouse.z (int)
              z-coordinate

       mouse.w (int)
              w-coordinate

       mouse.button (unsigned)
              The mouse  button  which  was  pressed,  numbering  from  1.   As  a  convenience,  the  constants
              ALLEGRO_MOUSE_BUTTON_LEFT,  ALLEGRO_MOUSE_BUTTON_RIGHT,  ALLEGRO_MOUSE_BUTTON_MIDDLE are provided.
              However, depending on the hardware there may be more  or  fewer  mouse  buttons.   You  can  check
              al_get_mouse_num_buttons(3alleg5) if you want to be sure.

       mouse.pressure (float)
              Pressure, ranging from 0.0 to 1.0.

       mouse.display (ALLEGRO_DISPLAY *)
              The display which had mouse focus.

   ALLEGRO_EVENT_MOUSE_BUTTON_UP
       A mouse button was released.

       mouse.x (int)
              x-coordinate

       mouse.y (int)
              y-coordinate

       mouse.z (int)
              z-coordinate

       mouse.w (int)
              w-coordinate

       mouse.button (unsigned)
              The  mouse  button  which  was  released,  numbering  from  1.   As  a  convenience, the constants
              ALLEGRO_MOUSE_BUTTON_LEFT, ALLEGRO_MOUSE_BUTTON_RIGHT, ALLEGRO_MOUSE_BUTTON_MIDDLE  are  provided.
              However,  depending  on  the  hardware  there  may  be more or fewer mouse buttons.  You can check
              al_get_mouse_num_buttons(3alleg5) if you want to be sure.

       mouse.pressure (float)
              Pressure, ranging from 0.0 to 1.0.

       mouse.display (ALLEGRO_DISPLAY *)
              The display which had mouse focus.

   ALLEGRO_EVENT_MOUSE_WARPEDal_set_mouse_xy(3alleg5)   was   called   to   move   the   mouse.    This   event   is   identical    to
       ALLEGRO_EVENT_MOUSE_AXES otherwise.

   ALLEGRO_EVENT_MOUSE_ENTER_DISPLAY
       The mouse cursor entered a window opened by the program.

       mouse.x (int)
              x-coordinate

       mouse.y (int)
              y-coordinate

       mouse.z (int)
              z-coordinate

       mouse.w (int)
              w-coordinate

       mouse.display (ALLEGRO_DISPLAY *)
              The display which had mouse focus.

   ALLEGRO_EVENT_MOUSE_LEAVE_DISPLAY
       The mouse cursor left the boundaries of a window opened by the program.

       mouse.x (int)
              x-coordinate

       mouse.y (int)
              y-coordinate

       mouse.z (int)
              z-coordinate

       mouse.w (int)
              w-coordinate

       mouse.display (ALLEGRO_DISPLAY *)
              The display which had mouse focus.

   ALLEGRO_EVENT_TOUCH_BEGIN
       The touch input device registered a new touch.

       touch.display (ALLEGRO_DISPLAY)
              The display which was touched.

       touch.id (int)
              An  identifier  for  this touch.  If supported by the device it will stay the same for events from
              the same finger until the touch ends.

       touch.x (float)
              The x coordinate of the touch in pixels.

       touch.y (float)
              The y coordinate of the touch in pixels.

       touch.dx (float)
              Movement speed in pixels in x direction.

       touch.dy (float)
              Movement speed in pixels in y direction.

       touch.primary (bool)
              Whether this is the only/first touch or an additional touch.

Name

       ALLEGRO_EVENT - Allegro 5 API

See Also

ALLEGRO_EVENT_DISPLAY_HALT_DRAWING(3alleg5)

   ALLEGRO_EVENT_DISPLAY_CONNECTED
       This  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.

       display.source (ALLEGRO_DISPLAY *)
              The display which was connected.

Since

       5.2.9

              [UnstableAPI]: This is an experimental feature and currently only works for the X11 backend.

Allegro reference manual                                                                  ALLEGRO_EVENT(3alleg5)

Synopsis

              #include <allegro5/allegro.h>

              typedef union ALLEGRO_EVENT ALLEGRO_EVENT;

See Also