29#ifndef NOMLIB_SYSTEM_EVENT_HANDLER_HPP
30#define NOMLIB_SYSTEM_EVENT_HANDLER_HPP
35#include "nomlib/config.hpp"
36#include "nomlib/system/Event.hpp"
52 typedef EventHandler self_type;
54 enum JoystickHandlerType
57 SDL_JOYSTICK_EVENT_HANDLER,
58 GAME_CONTROLLER_EVENT_HANDLER,
69 EventHandler&
operator =(
const EventHandler& rhs) =
delete;
94 JoystickHandlerType joystick_event_type()
const;
148 bool pop_event(
Event& ev);
156 void process_joystick_event(
const SDL_Event* ev);
157 void process_game_controller_event(
const SDL_Event* ev);
164 std::vector<std::unique_ptr<event_watcher>> event_watchers_;
170 void* joystick_event_handler_ =
nullptr;
171 JoystickHandlerType joystick_event_type_ = NO_EVENT_HANDLER;
174Event create_key_press(int32 sym, uint16 mod, uint8 repeat);
175Event create_key_release(int32 sym, uint16 mod, uint8 repeat);
176Event create_mouse_button_click(uint8 button, uint8 clicks, uint32 window_id);
177Event create_mouse_button_release(uint8 button, uint8 clicks, uint32 window_id);
179Event create_joystick_button_press(JoystickID
id, uint8 button);
180Event create_joystick_button_release(JoystickID
id, uint8 button);
182Event create_joystick_hat_motion(JoystickID
id, uint8 hat, uint8 value);
184Event create_game_controller_button_press(JoystickID
id, uint8 button);
185Event create_game_controller_button_release(JoystickID
id, uint8 button);
187Event create_user_event(int32 code,
void* data1,
void* data2, uint32 window_id);
189Event create_quit_event(
void* data1,
void* data2);
void flush_events(Event::EventType type)
Clear events from the queue.
EventHandler & operator=(const EventHandler &rhs)=delete
Disabled copy assignment operator.
void flush_events()
Clear the events queue.
EventHandler(const EventHandler &rhs)=delete
Disabled copy constructor.
void process_event(const SDL_Event *ev)
Enumerate the available events from the underlying platform.
bool enable_game_controller_polling()
Initialize game controller events polling.
void process_events()
Enumerate the available events from the underlying platform.
void append_event_watch(const event_filter &filter, void *data)
Add an event listener.
bool poll_event(Event &ev)
Enumerate the available events.
void flush_event(Event::EventType type)
Clear an event from the queue.
JoystickEventHandler * joystick_event_handler() const
Get a non-owned pointer to the joystick device event handler.
void disable_game_controller_polling()
Shutdown the game controller events polling subsystem.
nom::size_type num_events() const
Get the total number of enqueued events.
GameControllerEventHandler * game_controller_event_handler() const
Get a non-owned pointer to the game controller device event handler.
void remove_event_watchers()
Erase all event watchers.
nom::size_type max_events_count_
The maximum number of events processed per queue cycle – i.e.: one frame of the game's update loop.
void disable_joystick_polling()
Shutdown the joystick events polling subsystem.
void push_event(const Event &ev)
Enqueue an event.
void remove_event_watch(const event_filter &filter)
Erase an event listener.
bool enable_joystick_polling()
Initialize joystick events polling.
std::deque< Event > events_
Enqueued events.
nom::size_type num_event_watchers() const
Get the total number of event watchers.
Internal management of hot-pluggable joystick devices handling.
Internal management of hot-pluggable joystick devices handling.