Brunot
Loading...
Searching...
No Matches
Keys.h
Go to the documentation of this file.
1
14// ____ __ __ __
15// /\__ _\/\ \ /\ \/\ \
16// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
17// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
18// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
19// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
20// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
21
22
23
24#pragma once
25
26#include "System/opengl.h"
27
32class Keys
33{
34public:
35
36 Keys();
37
38 auto update() -> void;
39 auto showMenu() -> void;
40
42 auto getInputMap() const -> const std::unordered_map<int, std::string>&;
43
45 auto getEnabled() const -> bool;
47 auto setEnabled(bool newState) -> void;
48
49
51 static auto keyCallback(GLFWwindow* window, int pressedKey, int scancode, int action, int mods) -> void;
52
54 static auto sendKeyPressedMessage(unsigned int GLFWKey) -> void;
55
56
58 static constexpr auto getKeyDeviceID() -> int
59 {
60 return keyDeviceID;
61 }
62
63private:
64
66 std::unordered_map<int, std::string> keyMap;
67
69 bool enabled;
70
72 static constexpr auto keyDeviceID = -1;
73};
std::unordered_map< int, std::string > keyMap
A map that takes GLFW mouse button codes and maps them to input event names.
Definition Keys.h:66
auto update() -> void
Definition Keys.cpp:81
auto getInputMap() const -> const std::unordered_map< int, std::string > &
Returns the map of glfw mouse button codes.
Definition Keys.cpp:85
static constexpr auto getKeyDeviceID() -> int
Used to keep our use of the Key input device ID consistent.
Definition Keys.h:58
static auto sendKeyPressedMessage(unsigned int GLFWKey) -> void
Callback used by GLFW whenever a button on the keyboard is pressed/released. Broadcasts a message on ...
Definition Keys.cpp:134
bool enabled
If this is off, we don't do anything on key press.
Definition Keys.h:69
static constexpr auto keyDeviceID
ID representing all key input done.
Definition Keys.h:72
auto showMenu() -> void
Definition Keys.cpp:90
auto setEnabled(bool newState) -> void
Sets whether input from the keyboard is accepted or not.
Definition Keys.cpp:102
auto getEnabled() const -> bool
Returns if key input is currently enabled or not.
Definition Keys.cpp:97
Keys()
Definition Keys.cpp:38
static auto keyCallback(GLFWwindow *window, int pressedKey, int scancode, int action, int mods) -> void
Registers which keys are pressed.
Definition Keys.cpp:110