Hymn to Beauty
C++ 3D Engine
Input.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <json/json.h>
4#include <vector>
5
6namespace Utility {
7class Window;
8}
9
10#if !ANDROID
11struct GLFWwindow;
12#endif
13
16class Input {
17 public:
19 struct Button {
21 char action[255];
22
24 int key;
25
27 int state;
28 };
29
31 std::vector<Button*> buttons;
32
34
37 static Input& GetInstance();
38
40
43 void SetWindow(Utility::Window* window);
44
46
50 bool CheckButton(int index) const;
51
53
56 Json::Value Save() const;
57
59
62 void Load(const Json::Value& buttonsNode);
63
64 private:
65#if !ANDROID
66 GLFWwindow* window;
67#endif
68
69 Input() {}
70
71 Input(Input const&) = delete;
72 void operator=(Input const&) = delete;
73};
Definition: Input.hpp:16
Json::Value Save() const
Save the buttons to a JSON value.
Definition: Input.cpp:37
void Load(const Json::Value &buttonsNode)
Load buttons from JSON node.
Definition: Input.cpp:50
void SetWindow(Utility::Window *window)
Set the window to check for input against.
Definition: Input.cpp:16
std::vector< Button * > buttons
The buttons to register.
Definition: Input.hpp:31
bool CheckButton(int index) const
Check if a button was activated this frame.
Definition: Input.cpp:22
static Input & GetInstance()
Get the input singleton instance.
Definition: Input.cpp:11
Definition: Window.hpp:14
Definition: ResourceView.hpp:12
The information needed to identify a button.
Definition: Input.hpp:19
int key
The GLFW key to press.
Definition: Input.hpp:24
char action[255]
A string describing the action, e.g "Fire".
Definition: Input.hpp:21
int state
The GLFW state of that key.
Definition: Input.hpp:27