Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
oe::core::EventHandler Class Reference

Event handler. More...

#include <OxygenEngine/core/event_handler.h>

Public Member Functions

void addEvent (const EventType type, const EventData &data) noexcept
 Add a new event to be processed.
 
void processEvents (const bool clean_processed=true) noexcept
 Compute EventHandler state from unprocessed events + make the event list available in getProcessedEvents()
 
const EventList & getProcessedEvents () const noexcept
 Get a list of events that happened during the frame.
 
bool isKeyPressed (const key_code_t &key, const bool &strict=false) const noexcept
 Check if a keyboard key is pressed.
 
bool hasKeyChanged (const key_code_t &key) const noexcept
 Check if a keyboard key state changed this frame.
 
bool isKeyJustPressed (const key_code_t &key) const noexcept
 Check if a keyboard was just pressed this frame.
 
bool isClicked (const key_code_t &key, const bool &strict=false) const noexcept
 Check if mouse button is clicked.
 
bool isHold (const key_code_t &key) const noexcept
 Check if key or mouse button is hold.
 
void resetAllStates () noexcept
 Force all keys / buttons as released.
 
bool isEscapePressed () const noexcept
 Check if the ESC key is pressed.
 
bool isCtrlPressed () const noexcept
 Check if any of CTRL keys are pressed.
 
bool isAltPressed () const noexcept
 Check if any of ALT keys are pressed.
 
bool isShiftPressed () const noexcept
 Check if any of SHIFT keys are pressed.
 
bool isSpacePressed () const noexcept
 Check if the space bar is pressed.
 
bool isSuperPressed () const noexcept
 Check if the super key is pressed.
 
const glm::vec2 & getMouseScroll () const noexcept
 
void setMouseScroll (const glm::vec2 &scroll) noexcept
 
const glm::vec2 & getCursorPos () const noexcept
 
const glm::vec2 & getCursorOffset () const noexcept
 
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.
 
void setCursorPos (const glm::vec2 &cursor_pos) noexcept
 

Detailed Description

Event handler.

Note
The setters only update the internal state, no events are sent to the OS

Member Function Documentation

◆ addEvent()

void oe::core::EventHandler::addEvent ( const EventType  type,
const EventData data 
)
noexcept

Add a new event to be processed.

Note
You can add custom event by using EventType::CUSTOM and data.custom
Parameters
typeType of the event
dataEventData depending of the event

◆ getProcessedEvents()

const EventList & oe::core::EventHandler::getProcessedEvents ( ) const
inlinenoexcept

Get a list of events that happened during the frame.

Returns
A list of events that are received and processed with processEvents()

◆ isSuperPressed()

bool oe::core::EventHandler::isSuperPressed ( ) const
noexcept

Check if the super key is pressed.

Note
Super key refers to the key with a vendor specific icon (also known as Windows key or Command key)

◆ processEvents()

void oe::core::EventHandler::processEvents ( const bool  clean_processed = true)
noexcept

Compute EventHandler state from unprocessed events + make the event list available in getProcessedEvents()

Parameters
clean_processedRemove events already processed in getProcessedEvents()

◆ setCursorPos()

void oe::core::EventHandler::setCursorPos ( const glm::vec2 &  cursor_pos)
inlinenoexcept

Set cursor position

Note
cursor offset will be reset
Parameters
cursor_posCursor position (in pixels, relative to window)

The documentation for this class was generated from the following file: