Skip to content

Module: event

Synopsis

#include <core/event.h>

Poll user input and system events.

Enums

event_type

Which kind of event has been reported.

Enumerator Description
EVENT_CLICKDOWN Mouse click down, see event_click
EVENT_CLICKUP Mouse click released, see event_click
EVENT_KEYDOWN Single key down, see event_key
EVENT_KEYUP Single key released, see event_key
EVENT_MOUSE Mouse moved, see event_mouse
EVENT_QUIT Quit request

Unions

event

Union that store every kind of event.

The union along with every sub structures that are defined all have the enum event_type as first field which means that you can access the union's type field directly.

Depending on the type field, access only the appropriate sub structure that describe the event. See below structures that describe events.

Field Access Type
type (-) enum event_type
key (+) struct event_key
mouse (+) struct event_mouse
click (+) struct event_click

type

Which kind of event happened.

key, mouse, click

Access to the element details depending on the type.

Structs

event_key

Describe a keyboard key that was pressed or released.

Field Access Type
type (-) enum event_type
key (+) enum key

type

Set to EVENT_KEYDOWN or EVENT_KEYUP.

key

Which key, see key for more information.

event_mouse

Describe a mouse motion.

Field Access Type
type (-) enum event_type
buttons (+) enum mouse_button
x (+) int
y (+) int

type

Set to EVENT_MOUSE.

buttons

OR'ed values of buttons currently pressed, see mouse for more information.

x, y

New absolute coordinates.

event_click

Describe a mouse click or release.

Field Access Type
type (-) enum event_type
button (+) enum mouse_button
x (+) int
y (+) int

type

Set to EVENT_CLICKDOWN or EVENT_CLICKUP.

button

Unique button pressed or released.

x, y

Absolute coordinates.

Functions

event_poll

Fetch the next event into ev or return false if there are not.

bool
event_poll(union event *ev)