1#ifndef OE_CORE_EVENT_HANDLER_H
2#define OE_CORE_EVENT_HANDLER_H
8#include <unordered_map>
12#include "event_type.h"
55 bool isKeyPressed(
const key_code_t& key,
const bool& strict =
false) const noexcept;
73 bool isClicked(
const key_code_t& key,
const bool& strict =
false) const noexcept;
78 bool isHold(const key_code_t& key) const noexcept;
117 const glm::vec2& getMouseScroll() const noexcept
119 return _mouse_scroll;
122 void setMouseScroll(
const glm::vec2& scroll)
noexcept
124 _mouse_scroll = scroll;
127 const glm::vec2& getCursorPos() const noexcept
132 const glm::vec2& getCursorOffset() const noexcept
134 return _cursor_offset;
140 void forceState(
const key_code_t& key,
const int& state,
const bool& isMouse =
false) noexcept;
150 _last_cursor_pos = cursor_pos;
151 _cursor_pos = cursor_pos;
157 EventList _raw_events;
159 std::unordered_map<key_code_t, int> _key_status;
160 std::unordered_map<key_code_t, int> _real_key_status;
162 std::unordered_map<key_code_t, bool> _switched_key_status;
164 std::unordered_map<key_code_t, int> _mouse_buttons_status;
165 std::unordered_map<key_code_t, int> _real_mouse_buttons_status;
167 glm::vec2 _mouse_scroll = glm::vec2(0.0);
168 glm::vec2 _cursor_pos = glm::vec2(0.0);
170 glm::vec2 _last_cursor_pos = glm::vec2(0.0);
171 glm::vec2 _cursor_offset = glm::vec2(0.0);
172 bool _first_cursor_move =
true;
Event handler.
Definition event_handler.h:22
void setCursorPos(const glm::vec2 &cursor_pos) noexcept
Definition event_handler.h:148
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:65
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:47
bool isAltPressed() const noexcept
Check if any of ALT keys are pressed.
Core functionality (windows, event handler, logger, ...)
Definition cursor.h:8
EventType
Definition event_type.h:9
Definition event_type.h:201