1#ifndef OE_CORE_EVENT_HANDLER_H
2#define OE_CORE_EVENT_HANDLER_H
5#include <unordered_map>
51 bool isKeyPressed(
const key_code_t& key,
const bool& strict =
false) const noexcept;
69 bool isClicked(
const key_code_t& key,
const bool& strict =
false) const noexcept;
74 bool isHold(const key_code_t& key) const noexcept;
113 const glm::vec2& getMouseScroll() const noexcept
115 return _mouse_scroll;
118 void setMouseScroll(
const glm::vec2& scroll)
noexcept
120 _mouse_scroll = scroll;
123 const glm::vec2& getCursorPos() const noexcept
128 const glm::vec2& getCursorOffset() const noexcept
130 return _cursor_offset;
136 void forceState(
const key_code_t& key,
const int& state,
const bool& isMouse =
false) noexcept;
146 _last_cursor_pos = cursor_pos;
147 _cursor_pos = cursor_pos;
153 EventList _raw_events;
155 std::unordered_map<key_code_t, int> _key_status;
156 std::unordered_map<key_code_t, int> _real_key_status;
158 std::unordered_map<key_code_t, bool> _switched_key_status;
160 std::unordered_map<key_code_t, int> _mouse_buttons_status;
161 std::unordered_map<key_code_t, int> _real_mouse_buttons_status;
163 glm::vec2 _mouse_scroll = glm::vec2(0.0);
164 glm::vec2 _cursor_pos = glm::vec2(0.0);
166 glm::vec2 _last_cursor_pos = glm::vec2(0.0);
167 glm::vec2 _cursor_offset = glm::vec2(0.0);
168 bool _first_cursor_move =
true;
Event handler.
Definition event_handler.h:18
void setCursorPos(const glm::vec2 &cursor_pos) noexcept
Definition event_handler.h:144
bool isShiftPressed() const noexcept
Check if any of SHIFT keys are pressed.
bool isCtrlPressed() const noexcept
Check if any of CTRL keys are pressed.
bool isSuperPressed() const noexcept
Check if the super key is pressed.
bool hasKeyChanged(const key_code_t &key) const noexcept
Check if a keyboard key state changed this frame.
bool isClicked(const key_code_t &key, const bool &strict=false) const noexcept
Check if mouse button is clicked.
void forceState(const key_code_t &key, const int &state, const bool &isMouse=false) noexcept
Force key or mouse button status, ignoring the real status.
bool isEscapePressed() const noexcept
Check if the ESC key is pressed.
bool isKeyJustPressed(const key_code_t &key) const noexcept
Check if a keyboard was just pressed this frame.
Definition event_handler.h:61
void resetAllStates() noexcept
Force all keys / buttons as released.
void addEvent(const EventType type, const EventData &data) noexcept
Add a new event to be processed.
bool isKeyPressed(const key_code_t &key, const bool &strict=false) const noexcept
Check if a keyboard key is pressed.
void processEvents(const bool clean_processed=true) noexcept
Compute EventHandler state from unprocessed events + make the event list available in getProcessedEve...
bool isSpacePressed() const noexcept
Check if the space bar is pressed.
bool isHold(const key_code_t &key) const noexcept
Check if key or mouse button is hold.
const EventList & getProcessedEvents() const noexcept
Get a list of events that happened during the frame.
Definition event_handler.h:43
bool isAltPressed() const noexcept
Check if any of ALT keys are pressed.
Core functionality (windows, event handler, logger, ...)
Definition args.h:10
EventType
Definition event_type.h:10
Definition event_type.h:205