Programmer_24 [2:17 PM]
hey

Apiza [2:17 PM]
Hello!

Programmer_24 [2:19 PM]
How can I see if the user pressed a key

Apiza [2:20 PM]
Are you asking about al_key_down?

Programmer_24 [2:21 PM]
yes
also what does al_wait_for_event do?
what arguments does it take and what does it return

Apiza [2:22 PM]
al_key_down returns true if the key specified was held down in the state specified.
bool al_key_down(const ALLEGRO_KEYBOARD_STATE *state, int keycode)

Programmer_24 [2:22 PM]
what are the keycodes for up, down, left, and right arrowkeys

Apiza [2:23 PM]
al_wait_for_event waits until the event queue specified is non-empty. If ret_eventis not NULL, the first event in the queue will be copied into ret_event and removed from the queue. If ret_event is NULL the first event is left at the head of the queue.
void al_wait_for_event(ALLEGRO_EVENT_QUEUE *queue, ALLEGRO_EVENT *ret_event)
ALLEGRO_KEY_LEFT, ALLEGRO_KEY_RIGHT, ALLEGRO_KEY_UP, ALLEGRO_KEY_DOWN

Programmer_24 [2:25 PM]
when a user presses a key, is a corresponding event placed in the event queue?

Apiza [2:25 PM]
I believe so

Programmer_24 [2:26 PM]
Well I'll do an experiment and let you know :slightly_smiling_face:
what states can allegro_keyboard_state be in

Apiza [2:30 PM]
ALLEGRO_KEYBOARD_STATE is a structure that is used to hold a "snapshot" of a keyboard's state at a particular instant. It contains the following publically readable fields: display - points to the display that had keyboard focus at the time the state was saved. If no display was focused, this points to NULL.
You cannot read the state of keys directly. Use the function al_key_down.

Programmer_24 [2:36 PM]
what's the event type for a key press

Apiza [2:37 PM]
Are you asking about al_get_keyboard_event_source?

Programmer_24 [2:37 PM]
I don't know. What does that do?

Apiza [2:38 PM]
The method retrieves the keyboard event source. All keyboard events are generated by this event source.
Returns NULL if the keyboard subsystem was not installed.
ALLEGRO_EVENT_SOURCE *al_get_keyboard_event_source(void)

Programmer_24 [2:45 PM]
what is the keyboard event type called

Apiza [2:46 PM]
Are you asking about one of the following?ALLEGRO_EVENT_KEY_DOWN, ALLEGRO_EVENT_KEY_UP, ALLEGRO_EVENT_KEY_CHAR

Programmer_24 [2:49 PM]
what is ALLEGRO_EVENT_KEY_LEFT

Apiza [2:50 PM]
I’m not sure I understand

Programmer_24 [2:52 PM]
what is ALLEGRO_EVENT_KEY_DOWN

Apiza [2:53 PM]
ALLEGRO_EVENT_KEY_DOWN represents a 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.

Programmer_24 [2:54 PM]
what are the possible events

Apiza [2:55 PM]
ALLEGRO_EVENT_JOYSTICK_AXIS
ALLEGRO_EVENT_JOYSTICK_BUTTON_DOWN
ALLEGRO_EVENT_JOYSTICK_BUTTON_UP
ALLEGRO_EVENT_JOYSTICK_CONFIGURATION
ALLEGRO_EVENT_KEY_DOWN
ALLEGRO_EVENT_KEY_UP
ALLEGRO_EVENT_KEY_CHAR
ALLEGRO_EVENT_MOUSE_AXES
ALLEGRO_EVENT_MOUSE_BUTTON_DOWN
ALLEGRO_EVENT_MOUSE_BUTTON_UP
ALLEGRO_EVENT_MOUSE_WARPED
ALLEGRO_EVENT_MOUSE_ENTER_DISPLAY
ALLEGRO_EVENT_MOUSE_LEAVE_DISPLAY
ALLEGRO_EVENT_TOUCH_BEGIN
ALLEGRO_EVENT_TOUCH_END
ALLEGRO_EVENT_TOUCH_MOVE
ALLEGRO_EVENT_TOUCH_CANCEL
ALLEGRO_EVENT_TIMER
ALLEGRO_EVENT_DISPLAY_EXPOSE
ALLEGRO_EVENT_DISPLAY_RESIZE
ALLEGRO_EVENT_DISPLAY_CLOSE
ALLEGRO_EVENT_DISPLAY_LOST
ALLEGRO_EVENT_DISPLAY_FOUND
ALLEGRO_EVENT_DISPLAY_SWITCH_OUT
ALLEGRO_EVENT_DISPLAY_SWITCH_IN
ALLEGRO_EVENT_DISPLAY_ORIENTATION
ALLEGRO_EVENT_DISPLAY_HALT_DRAWING
ALLEGRO_EVENT_DISPLAY_RESUME_DRAWING
ALLEGRO_EVENT_DISPLAY_CONNECTED
ALLEGRO_EVENT_DISPLAY_DISCONNECTED

Programmer_24 [3:00 PM]
what is ALLEGRO_EVENT

Apiza [3:00 PM]
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.

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

Programmer_24 [3:01 PM]
tell me about ALLEGRO_EVENT_KEY_DOWN

Apiza [3:02 PM]
ALLEGRO_EVENT_KEY_DOWN represents a keyboard key was pressed.

Programmer_24 [3:09 PM]
if I have an ALLEGRO_EVENT called ev, should ev.type == ALLEGRO_EVENT_KEY_DOWN return true when I press a key?

Apiza [3:10 PM]
I’m not sure I understand
Are you interested in al_get_keyboard_state or al_key_down?

Programmer_24 [3:11 PM]
no
tell me about al_get_keyboard_state

Apiza [3:12 PM]
This method saves the state of the keyboard specified at the time the function is called into the structure pointed to by ret_state.
void al_get_keyboard_state(ALLEGRO_KEYBOARD_STATE *ret_state)

Programmer_24 [3:13 PM]
how can I check to see if my keyboard is generating events

Apiza [3:14 PM]
Are you asking about al_get_keyboard_event_source?

Programmer_24 [3:17 PM]
yes

Apiza [3:18 PM]
The method retrieves the keyboard event source. All keyboard events are generated by this event source.
Returns NULL if the keyboard subsystem was not installed.
ALLEGRO_EVENT_SOURCE *al_get_keyboard_event_source(void)

Programmer_24 [3:19 PM]
when I call al_get_keyboard_event_source, the assertion 'new_keyboard_driver' fails

Apiza [3:19 PM]
Are you asking about al_install_keyboard?

Programmer_24 [3:19 PM]
what is al_get_keyboard

Apiza [3:20 PM]
I’m not sure I understand

Programmer_24 [3:20 PM]
tell me about al_install_keyboard

Apiza [3:20 PM]
This method installs a keyboard driver. Returns true if successful. If a driver was already installed, nothing happens and true is returned.
bool al_install_keyboard(void)

Programmer_24 [3:26 PM]
what is they type of ALLEGRO_EVENT_SOURCE

Apiza [3:26 PM]
typedef struct ALLEGRO_EVENT_SOURCE ALLEGRO_EVENT_SOURCE;

Programmer_24 [3:27 PM]
what are the fields of ALLEGRO_EVENT_SOURCE

Apiza [3:27 PM]
An event source is any object which can generate events. For example, an ALLEGRO_DISPLAY can generate events, and you can get the ALLEGRO_EVENT_SOURCE pointer from an ALLEGRO_DISPLAY with al_get_display_event_source.

You may create your own "user" event sources that emit custom events.

Programmer_24 [3:29 PM]
what is ALLEGRO_KEYBOARD

Apiza [3:29 PM]
Are you asking about ALLEGRO_KEYBOARD_STATE?

Programmer_24 [3:30 PM]
no
tell me about al_keyboard_state
nevermind
tell me about al_key_down

Apiza [3:32 PM]
Returns true if the key specified was held down in the state specified.
bool al_key_down(const ALLEGRO_KEYBOARD_STATE *state, int keycode)