- cpp3ds
- Event
Defines a system event and its parameters. More...
#include <Event.hpp>
Classes | |
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 { KeyPressed, KeyReleased, JoystickMoved, TouchBegan, TouchMoved, TouchEnded, TouchSwiped, SensorChanged, Slider3DChanged, SliderVolumeChanged, Count } |
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 | |
}; | |
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:
Enumeration of the different types of events.
JoystickMoveEvent cpp3ds::Event::joystickMove |
Joystick move event parameters (Event::JoystickMoved)
KeyEvent cpp3ds::Event::key |
Key event parameters (Event::KeyPressed, Event::KeyReleased)
SensorEvent cpp3ds::Event::sensor |
Sensor event parameters (Event::SensorChanged)
TouchEvent cpp3ds::Event::touch |
Touch events parameters (Event::TouchBegan, Event::TouchMoved, Event::TouchEnded)