Cogs.Core
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Cogs::Core::EventBasedInput Class Reference

Event based input handler. More...

#include <EventBasedInput.h>

Public Member Functions

void updateState (const Cogs::Keyboard &keyboard, const Cogs::Mouse &mouse)
 
std::span< const InputEventevents () const
 Return new input events from last frame.
 

Private Member Functions

void handleMouseEvent (const Cogs::Mouse::Event &mouseEvent)
 
void handleKeyboardEvent (const Cogs::Keyboard::Event &keyboardEvent)
 

Private Attributes

KeyboardModifiers modifiers = KeyboardModifiers::None
 Current modifiers state.
 
std::vector< InputEventnewEvents
 New list of input events.
 

Detailed Description

Event based input handler.

Gets events from the Input system. Calculates current keyboard modifier state for later keyboard and mouse events. Applications calls UpdateState first for each rendering frame to get new input events. Then the new events are looped through using the events() method.

Definition at line 64 of file EventBasedInput.h.

Member Function Documentation

◆ events()

std::span< const InputEvent > Cogs::Core::EventBasedInput::events ( ) const
inline

Return new input events from last frame.

Definition at line 74 of file EventBasedInput.h.

References newEvents.

◆ handleKeyboardEvent()

void Cogs::Core::EventBasedInput::handleKeyboardEvent ( const Cogs::Keyboard::Event keyboardEvent)
private

Seems to be some kind of lost focus. Reset Keyboard modifiers etc in state.

Definition at line 47 of file EventBasedInput.cpp.

References Cogs::Keyboard::Event::data, Cogs::Core::InputEvent::inputEventType, Cogs::Core::Keyboard, Cogs::Core::Reset, Cogs::Keyboard::Event::timestamp_ms, and Cogs::Keyboard::Event::type.

Referenced by updateState().

◆ handleMouseEvent()

void Cogs::Core::EventBasedInput::handleMouseEvent ( const Cogs::Mouse::Event mouseEvent)
private

Definition at line 37 of file EventBasedInput.cpp.

◆ updateState()

void Cogs::Core::EventBasedInput::updateState ( const Cogs::Keyboard keyboard,
const Cogs::Mouse mouse 
)

Update keyboard state at each frame before accessing events. Problem if leaving Keyboard focus and Press/release Modifier ? TBD

Definition at line 4 of file EventBasedInput.cpp.

References Cogs::Keyboard::getEvents(), handleKeyboardEvent(), and newEvents.

Member Data Documentation

◆ modifiers

KeyboardModifiers Cogs::Core::EventBasedInput::modifiers = KeyboardModifiers::None
private

Current modifiers state.

Definition at line 82 of file EventBasedInput.h.

◆ newEvents

std::vector<InputEvent> Cogs::Core::EventBasedInput::newEvents
private

New list of input events.

Definition at line 85 of file EventBasedInput.h.

Referenced by events(), and updateState().


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