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

Classes

struct  Event
 
struct  State
 

Public Member Functions

void update ()
 Reset the state and events and update them from the eventQueue.
 
void submitKeyDown (Key key, double timestamp)
 Queue key down event for being processed in the next update.
 
void submitKeyUp (Key key, double timestamp)
 Queue key up event for being processed in the next update.
 
void submitChar (std::string ch, double timestamp)
 Queue char event for being processed in the next update.
 
void submitReset (double timestamp)
 Queue reset event for being processed in the next update.
 
bool isKeyDown (Key key) const
 
bool isKeyUp (Key key) const
 
bool hasChar (std::string_view ch) const
 
bool wasKeyPressed (Key key) const
 Return true if the key was pressed in the last frame, false otherwise.
 
bool wasKeyReleased (Key key) const
 Return true if the key was released in the last frame, false otherwise.
 
const StategetState () const
 Get the previous frame's keyboard state. Updated at the beginning of each new frame.
 
const std::vector< Event > & getEvents () const
 Get the previous frame's event list. Updated at the beginning of each new frame.
 

Private Attributes

State state
 
std::vector< Eventevents
 
std::vector< EventeventQueue
 

Detailed Description

Definition at line 46 of file Keyboard.h.

Member Function Documentation

◆ getEvents()

const std::vector< Event > & Cogs::Keyboard::getEvents ( ) const
inline

Get the previous frame's event list. Updated at the beginning of each new frame.

Definition at line 88 of file Keyboard.h.

Referenced by Cogs::Core::EventBasedInput::updateState().

◆ getState()

const State & Cogs::Keyboard::getState ( ) const
inline

Get the previous frame's keyboard state. Updated at the beginning of each new frame.

Definition at line 86 of file Keyboard.h.

◆ hasChar()

bool Cogs::Keyboard::hasChar ( std::string_view  ch) const
inline

Definition at line 80 of file Keyboard.h.

◆ isKeyDown()

bool Cogs::Keyboard::isKeyDown ( Key  key) const
inline

Definition at line 78 of file Keyboard.h.

◆ isKeyUp()

bool Cogs::Keyboard::isKeyUp ( Key  key) const
inline

Definition at line 79 of file Keyboard.h.

◆ submitChar()

void Cogs::Keyboard::submitChar ( std::string  ch,
double  timestamp 
)

Queue char event for being processed in the next update.

Definition at line 47 of file Keyboard.cpp.

◆ submitKeyDown()

void Cogs::Keyboard::submitKeyDown ( Key  key,
double  timestamp 
)

Queue key down event for being processed in the next update.

Definition at line 39 of file Keyboard.cpp.

◆ submitKeyUp()

void Cogs::Keyboard::submitKeyUp ( Key  key,
double  timestamp 
)

Queue key up event for being processed in the next update.

Definition at line 43 of file Keyboard.cpp.

◆ submitReset()

void Cogs::Keyboard::submitReset ( double  timestamp)

Queue reset event for being processed in the next update.

Definition at line 51 of file Keyboard.cpp.

◆ update()

void Cogs::Keyboard::update ( )

Reset the state and events and update them from the eventQueue.

Definition at line 3 of file Keyboard.cpp.

References Cogs::Keyboard::State::chars, and Cogs::Keyboard::State::keysDown.

◆ wasKeyPressed()

bool Cogs::Keyboard::wasKeyPressed ( Key  key) const

Return true if the key was pressed in the last frame, false otherwise.

Definition at line 55 of file Keyboard.cpp.

◆ wasKeyReleased()

bool Cogs::Keyboard::wasKeyReleased ( Key  key) const

Return true if the key was released in the last frame, false otherwise.

Definition at line 61 of file Keyboard.cpp.

Member Data Documentation

◆ eventQueue

std::vector<Event> Cogs::Keyboard::eventQueue
private

Definition at line 94 of file Keyboard.h.

◆ events

std::vector<Event> Cogs::Keyboard::events
private

Definition at line 92 of file Keyboard.h.

◆ state

State Cogs::Keyboard::state
private

Definition at line 91 of file Keyboard.h.


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