cpp-sdl2
C++ header-only SDL2 wrapper
|
Object that represent an event captured by SDL. More...
#include <event.hpp>
Classes | |
struct | EventFilter |
Event filter object. More... | |
Public Types | |
enum | State : int { State::Query = SDL_QUERY, State::Ignore = SDL_IGNORE, State::Enable = SDL_ENABLE } |
For type safety, we will use these scoped enum values instead of raw numbers like the C api. More... | |
Public Member Functions | |
Event () | |
Default ctor an event. More... | |
Event (SDL_Event const &e) | |
converting ctor to create an sdl::Event from an SDL_Event struct More... | |
operator SDL_Event () const | |
Implicit convertion to SDL_Event() More... | |
SDL_Event const * | ptr () const |
Get a pointer to an SDL_Event. More... | |
SDL_Event * | ptr () |
Get a pointer to an SDL_Event. More... | |
bool | poll () |
Pool for events, return false when there are no more events to poll. More... | |
void | wait () |
Wait until next event occur. This will stop the execution of your code until something happens. More... | |
void | wait (int timeout) |
Wait until next event occur, or until the given duration expired. More... | |
void | push () const |
Push the current event to the list of event to process. More... | |
void | peek () |
Peek the next event in the list. More... | |
bool | has_events () |
Return true if there are events in the queue. More... | |
bool | has_events (Uint32 type) |
Return true if there are events of a specific type in the queue. More... | |
bool | has_events (Uint32 minType, Uint32 maxType) |
Return true if there are events of a specific range of types in the queue. More... | |
void | pump_events () |
Pump the event loop from the OS event system. More... | |
void | flush_events (Uint32 minType, Uint32 maxType) |
Clear events of a range of types from the event queue. More... | |
void | flush_events () |
Clear all events from the event queue. More... | |
void | flush_events (Uint32 type) |
Clear events from a specific type from the event queue. More... | |
void | add_events (std::vector< Event > const &events, Uint32 minType, Uint32 maxType) |
Add events of a specific range of types to the event queue. More... | |
void | add_events (std::vector< Event > const &events) |
Add events to the queue. More... | |
void | add_events (std::vector< Event > const &events, Uint32 type) |
Add events of a specific type to the queue. More... | |
std::vector< Event > | peek_events (size_t maxEvents, Uint32 minType, Uint32 maxType) |
Peek at multiple future events. More... | |
std::vector< Event > | peek_events (size_t maxEvents) |
Peek at future events. More... | |
std::vector< Event > | peek_events (size_t maxEvents, Uint32 type) |
Peek events from a specific type. More... | |
std::vector< Event > | get_events (size_t maxEvents, Uint32 minType, Uint32 maxType) |
Get events from the queue maxEvents max number of events to get. More... | |
std::vector< Event > | get_events (size_t maxEvents) |
Get events from the queue. More... | |
std::vector< Event > | get_events (size_t maxEvents, Uint32 type) |
Get events from a specific type. More... | |
Event::State | event_state (Uint32 type) |
void | set_event_state (Uint32 type, Event::State state) |
Static Public Member Functions | |
static Event const & | ref_from (SDL_Event const &e) |
Get a const reference to an sdl::Event from an SDL_Event. More... | |
static Event & | ref_from (SDL_Event &e) |
Get a non-const reference to an sdl::Event from an SDL_Event. More... | |
static Event const & | ref_from (SDL_Event const *e) |
& ref_from(SDL_Event const* e) More... | |
static Event & | ref_from (SDL_Event *e) |
ref_from(SDL_Event& e) More... | |
Public Attributes | |
Uint32 | type |
Event type, shared with all events. More... | |
SDL_CommonEvent | common |
Common event data. More... | |
SDL_WindowEvent | window |
Window event data. More... | |
SDL_KeyboardEvent | key |
Keyboard event data. More... | |
SDL_TextEditingEvent | edit |
Text editing event data. More... | |
SDL_TextInputEvent | text |
Text input event data. More... | |
SDL_MouseMotionEvent | motion |
Mouse motion event data. More... | |
SDL_MouseButtonEvent | button |
Mouse button event data. More... | |
SDL_MouseWheelEvent | wheel |
Mouse wheel event data. More... | |
SDL_JoyAxisEvent | jaxis |
Joystick axis event data. More... | |
SDL_JoyBallEvent | jball |
Joystick ball event data. More... | |
SDL_JoyHatEvent | jhat |
Joystick hat event data. More... | |
SDL_JoyButtonEvent | jbutton |
Joystick button event data. More... | |
SDL_JoyDeviceEvent | jdevice |
Joystick device change event data. More... | |
SDL_ControllerAxisEvent | caxis |
Game Controller axis event data. More... | |
SDL_ControllerButtonEvent | cbutton |
Game Controller button event data. More... | |
SDL_ControllerDeviceEvent | cdevice |
Game Controller device event data. More... | |
SDL_AudioDeviceEvent | adevice |
Audio device event data. More... | |
SDL_QuitEvent | quit |
Quit request event data. More... | |
SDL_UserEvent | user |
Custom event data. More... | |
SDL_SysWMEvent | syswm |
System dependent window event data. More... | |
SDL_TouchFingerEvent | tfinger |
Touch finger event data. More... | |
SDL_MultiGestureEvent | mgesture |
Gesture event data. More... | |
SDL_DollarGestureEvent | dgesture |
Gesture event data. More... | |
SDL_DropEvent | drop |
Drag and drop event data. More... | |
SDL_SensorEvent | sensor |
SDL_DisplayEvent | display |
Sensor event data. More... | |
Uint8 | padding [56] |
Window event data. More... | |
Object that represent an event captured by SDL.
This union has the exact same memory layout as the SDL_Event structure. An SDL_Event and an sdl::Event object are "the same bits" in memory if they hold infos about the same event. cpp-sdl2 convert the raw SDL_Event into an sdl::Event object to add an object-oriented API around them
|
strong |
|
inline |
converting ctor to create an sdl::Event from an SDL_Event struct
|
inline |
Add events of a specific range of types to the event queue.
events | vector of events to be added |
minType | lower type boundary of the range |
maxType | upper type boundary of the range |
Definition at line 198 of file event.hpp.
Referenced by add_events().
|
inline |
Add events to the queue.
events | vector of events to be added |
Definition at line 210 of file event.hpp.
References add_events().
|
inline |
Add events of a specific type to the queue.
events | vector of events to be added |
type | type of events to be added |
Definition at line 218 of file event.hpp.
References add_events().
|
inline |
|
inline |
|
inline |
Clear all events from the event queue.
Definition at line 189 of file event.hpp.
References flush_events().
Referenced by flush_events().
|
inline |
Clear events from a specific type from the event queue.
Definition at line 192 of file event.hpp.
References flush_events().
Referenced by flush_events().
|
inline |
Get events from the queue maxEvents max number of events to get.
minType | lower bound of type range |
maxType | upper bound of type range |
Definition at line 255 of file event.hpp.
Referenced by get_events().
|
inline |
Get events from the queue.
type | The type of events to look for |
maxEvents | max number of events to get |
Definition at line 269 of file event.hpp.
References get_events().
|
inline |
Get events from a specific type.
type | The type of events to look for |
maxEvents | max number of events to get |
Definition at line 277 of file event.hpp.
References get_events().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Peek at multiple future events.
maxEvents | max number of events to get |
minType | lower bound of event type range |
maxType | upper bound of event type range |
Definition at line 227 of file event.hpp.
Referenced by peek_events().
|
inline |
|
inline |
Peek events from a specific type.
type | The type of events to look for |
Definition at line 246 of file event.hpp.
References peek_events().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
Get a const reference to an sdl::Event from an SDL_Event.
Definition at line 98 of file event.hpp.
Referenced by sdl::Event::EventFilter::call_filter().
|
inlinestatic |
Get a non-const reference to an sdl::Event from an SDL_Event.
|
inlinestatic |
|
inlinestatic |
|
inline |
|
inline |
|
inline |
SDL_AudioDeviceEvent sdl::Event::adevice |
SDL_MouseButtonEvent sdl::Event::button |
SDL_ControllerAxisEvent sdl::Event::caxis |
SDL_ControllerButtonEvent sdl::Event::cbutton |
SDL_ControllerDeviceEvent sdl::Event::cdevice |
SDL_DollarGestureEvent sdl::Event::dgesture |
SDL_TextEditingEvent sdl::Event::edit |
SDL_JoyAxisEvent sdl::Event::jaxis |
SDL_JoyBallEvent sdl::Event::jball |
SDL_JoyButtonEvent sdl::Event::jbutton |
SDL_JoyDeviceEvent sdl::Event::jdevice |
SDL_MultiGestureEvent sdl::Event::mgesture |
SDL_MouseMotionEvent sdl::Event::motion |
SDL_SysWMEvent sdl::Event::syswm |
SDL_TouchFingerEvent sdl::Event::tfinger |
Uint32 sdl::Event::type |
SDL_MouseWheelEvent sdl::Event::wheel |