Cogs.Foundation
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Attributes | List of all members
Cogs::Keyboard Class Reference

#include <Keyboard.h>

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
 

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.

◆ getState()

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

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

◆ hasChar()

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

◆ isKeyDown()

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

◆ isKeyUp()

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

◆ submitChar()

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

Queue char event for being processed in the next update.

◆ submitKeyDown()

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

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

◆ submitKeyUp()

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

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

◆ submitReset()

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

Queue reset event for being processed in the next update.

◆ update()

void Cogs::Keyboard::update ( )

◆ wasKeyPressed()

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

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

◆ wasKeyReleased()

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

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

Member Data Documentation

◆ eventQueue

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

Referenced by update().

◆ events

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

Referenced by update().

◆ state

State Cogs::Keyboard::state
private

Referenced by update().


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