2#include "../FoundationBase.h"
19 Zero, One, Two, Three, Four,
20 Five, Six, Seven, Eight, Nine,
22 Left, Right, Up, Down,
24 Shift, LeftShift, RightShift,
25 Control, LeftControl, RightControl,
26 Alt, LeftAlt, RightAlt,
34 Insert, Delete, Backspace,
51 bool keysDown[
static_cast<size_t>(Key::Count)] = {};
67 std::variant<Key, std::string>
data;
72 void submitKeyDown(Key key,
double timestamp);
73 void submitKeyUp(Key key,
double timestamp);
74 void submitChar(std::string ch,
double timestamp);
75 void submitReset(
double timestamp);
78 bool isKeyDown(Key key)
const {
return state.keysDown[
static_cast<size_t>(key)]; }
79 bool isKeyUp(Key key)
const {
return !isKeyDown(key); }
80 bool hasChar(std::string_view ch)
const {
return state.chars.find(ch) != std::string::npos; }
81 bool wasKeyPressed(Key key)
const;
82 bool wasKeyReleased(Key key)
const;
88 const std::vector<Event>&
getEvents()
const {
return events; }
92 std::vector<Event> events;
94 std::vector<Event> eventQueue;
const State & getState() 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.
@ Zero
Disable all color writes.
Contains all Cogs related functionality.
std::variant< Key, std::string > data
Data associated with the event: Key for Press and Release events, std::string for AddChar events and ...
double timestamp_ms
Timestamp in miliseconds.
std::string chars
List of characters generated by the keyboard this frame.