Classes | Public Types | Public Attributes | List of all members
cpp3ds::Event Class Reference

Defines a system event and its parameters. More...

#include <Event.hpp>


struct  JoystickMoveEvent
 Joystick axis move event parameters (JoystickMoved) More...
struct  KeyEvent
 Keyboard event parameters (KeyPressed, KeyReleased) More...
struct  SensorEvent
 Sensor event parameters (SensorChanged) More...
struct  SliderEvent
 Slider event parameters (Slider3DChanged, SliderVolumeChanged) More...
struct  TouchEvent
 Touch events parameters (TouchBegan, TouchMoved, TouchEnded) More...

Public Types

enum  EventType {
 Enumeration of the different types of events. More...

Public Attributes

EventType type
 Type of the event. More...
union {
   KeyEvent   key
 Key event parameters (Event::KeyPressed, Event::KeyReleased) More...
   JoystickMoveEvent   joystickMove
 Joystick move event parameters (Event::JoystickMoved) More...
   TouchEvent   touch
 Touch events parameters (Event::TouchBegan, Event::TouchMoved, Event::TouchEnded) More...
   SensorEvent   sensor
 Sensor event parameters (Event::SensorChanged) More...
   SliderEvent   slider

Detailed Description

Defines a system event and its parameters.

cpp3ds::Event holds all the informations about a system event that just happened.

Events are retrieved using the cpp3ds::Window::pollEvent and cpp3ds::Window::waitEvent functions.

A cpp3ds::Event instance contains the type of the event (mouse moved, key pressed, window closed, ...) as well as the details about this particular event. Please note that the event parameters are defined in a union, which means that only the member matching the type of the event will be properly filled; all other members will have undefined values and must not be read if the type of the event doesn't match. For example, if you received a KeyPressed event, then you must read the event.key member, all other members such as event.MouseMove or event.text will have undefined values.

Usage example:

while (window.pollEvent(event))
// Request for closing the window
if (event.type == cpp3ds::Event::Closed)
// The escape key was pressed
if ((event.type == cpp3ds::Event::KeyPressed) && (event.key.code == cpp3ds::Keyboard::Escape))
// The window was resized
if (event.type == cpp3ds::Event::Resized)
doSomethingWithTheNewSize(event.size.width, event.size.height);
// etc ...

Definition at line 15 of file Event.hpp.

Member Enumeration Documentation

Enumeration of the different types of events.


A key was pressed (data in event.key)


A key was released (data in event.key)


The joystick moved along an axis (data in event.joystickMove)


A touch event began (data in event.touch)


A touch moved (data in event.touch)


A touch event ended (data in event.touch)


A sensor value changed (data in event.sensor)


Keep last – the total number of event types.

Definition at line 67 of file Event.hpp.

Member Data Documentation

JoystickMoveEvent cpp3ds::Event::joystickMove

Joystick move event parameters (Event::JoystickMoved)

Definition at line 89 of file Event.hpp.

KeyEvent cpp3ds::Event::key

Key event parameters (Event::KeyPressed, Event::KeyReleased)

Definition at line 88 of file Event.hpp.

SensorEvent cpp3ds::Event::sensor

Sensor event parameters (Event::SensorChanged)

Definition at line 91 of file Event.hpp.

TouchEvent cpp3ds::Event::touch

Touch events parameters (Event::TouchBegan, Event::TouchMoved, Event::TouchEnded)

Definition at line 90 of file Event.hpp.

EventType cpp3ds::Event::type

Type of the event.

Definition at line 85 of file Event.hpp.

The documentation for this class was generated from the following file: