Event Pump

The a5ses event system is designed to be as simple to use for a beginner as the C Allegro API for built-in events and allow complex user event systems to be used along-side them effortlessly.

The first step to using the event system is to create a queue:

a5::Event_Queue queue;

Once a queue is created you can register event sources with it. Once a source is registered to a queue it recieves events that the source emits. A source can be registered with many queues and they will all recieve a copy of the event.
A list of a5ses objects that can be used as event sources follows:

To register an event with a5ses you simply use the Register member function.

a5::Keyboard keyboard; // Create a keyboard object
queue.Register(keyboard); // Register it with our event queue

The simplest way to interact with an Event_Queue is via Event_Reader:

a5::Event_Reader event(queue);

To retrieve events from the queue you can use Next(), which will check for events and immediately return, or WaitNext(), which waits until an event arrives before returning. WaitNext() is usually the best option as it avoids a busy loop:

event.WaitNext();

Once WaitNext has been called event is guaranteed to have a valid event within it that can be accessed via Get() or any of the functions in this family. It also allows the type of the event to be checked against the built in events.
The following code will print a message to the console when a user presses down a key.

switch (event.SubType())
{
	case a5::Keyboard::Event::Down:
		std::cout << "User pressed a button!" << std::endl;
		break;
}

Events also come with data that can be easily accessed via the Event_Reader object:

switch (event.SubType())
{
	case a5::Keyboard::Event::Down:
		if (event.Keyboard().keycode == a5::Keyboard::Key::Escape)
			std::exit(0);
		break;
}

That concludes built-in events. User events are handled quite differently and a tutorial will be written shortly.
A reference of the built in event Type IDs and members follows:

SubType()Type()Event Members
Display::Event::CloseDisplay::Event::Type int x;
int y;
int width;
int height;
Display::Event::Resize
Display::Event::Expose
Display::Event::Lost
Display::Event::Found
Display::Event::SwitchOut
Display::Event::SwitchIn
Keyboard::Event::DownDisplay::Event::Type ALLEGRO_DISPLAY *display;
Keyboard::Key::KeyCode keycode;
Keyboard::Modifier::KeyMod modifier;
unsigned int unichar;
Keyboard::Event::Repeat
Keyboard::Event::Up
Mouse::Event::MoveMouse::Event::Type ALLEGRO_DISPLAY *display;
Keyboard::Key::KeyCode keycode;
int w;
int x;
int y;
int z;
int dw;
int dx;
int dy;
int dz;
Mouse::Button button;
Mouse::Event::Down
Mouse::Event::Up
Mouse::Event::Warp
Mouse::Event::Enter
Mouse::Event::Leave
Timer::Event::TypeTimer::Event::Type -