Hymn to Beauty
C++ 3D Engine
InputManager.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5#include <glm/vec2.hpp>
6
7#if !ANDROID
8struct GLFWwindow;
9#endif
10
11namespace Utility {
12class Window;
13}
14
18 friend class Hub;
19
20 public:
22 enum Button {
38 W,
39 E,
40 R,
42 };
43
45 enum Device {
49 };
50
52 void Update();
53
55
58 double GetCursorX() const;
59
61
64 double GetCursorY() const;
65
67
70 glm::vec2 GetCursorXY() const;
71
73
76 bool GetScrollUp() const;
77
79
82 bool GetScrollDown() const;
83
85
92 void AssignButton(Button button, Device device, int index);
93
95
99 bool Pressed(Button button) const;
100
102
107 bool Triggered(Button button) const;
108
110
113 void CharacterCallback(unsigned int codePoint);
114
116
119 void ScrollCallback(double yOffset);
120
121 private:
124 InputManager(InputManager const&) = delete;
125 void operator=(InputManager const&) = delete;
126
127#if !ANDROID
128 GLFWwindow* glfwWindow;
129#endif
130
131 // Bindings
132 struct Binding {
133 Button button;
134 Device device;
135 int index;
136 };
137 std::vector<Binding> bindings;
138
139 // Data
140 struct ButtonData {
141 bool down = false;
142 bool released = false;
143 bool triggered = false;
144 };
145
146 // Button data.
147 ButtonData buttonData[BUTTONS];
148
149 double cursorX = 0.0;
150 double cursorY = 0.0;
151 double lastScroll = 0.0;
152 double scroll = 0.0;
153
154 std::string text = "", tempText = "";
155};
Singleton class that holds all subsystems.
Definition: Managers.hpp:16
Definition: InputManager.hpp:17
Button
Button codes.
Definition: InputManager.hpp:22
@ ZOOM
Zoom to entity.
Definition: InputManager.hpp:35
@ CONTROL
Control key.
Definition: InputManager.hpp:26
@ BACKWARD
Move backward.
Definition: InputManager.hpp:32
@ WINDOWMODE
Toggle window mode.
Definition: InputManager.hpp:25
@ FOCUS
Focus on selected object.
Definition: InputManager.hpp:37
@ R
Key for activating the scale operation in widget.
Definition: InputManager.hpp:40
@ PROFILE
Show profiling information.
Definition: InputManager.hpp:24
@ NEW
Create new hymn.
Definition: InputManager.hpp:27
@ RIGHT
Move right.
Definition: InputManager.hpp:34
@ BUTTONS
Total number of inputs.
Definition: InputManager.hpp:41
@ SAVE
Save opened hymn.
Definition: InputManager.hpp:29
@ LEFT
Move left.
Definition: InputManager.hpp:33
@ SELECT
Select object.
Definition: InputManager.hpp:36
@ W
Key for activating the translation operation in widget.
Definition: InputManager.hpp:38
@ E
Key for activating the rotation operation in widget.
Definition: InputManager.hpp:39
@ PLAYTEST
Start/stop playtesting the game.
Definition: InputManager.hpp:23
@ OPEN
Open existing hymn.
Definition: InputManager.hpp:28
@ CAMERA
Move camera.
Definition: InputManager.hpp:30
@ FORWARD
Move forward.
Definition: InputManager.hpp:31
double GetCursorY() const
Get cursor's vertical position.
Definition: InputManager.cpp:93
bool GetScrollUp() const
Get whether user has moved scroll wheel up.
Definition: InputManager.cpp:101
glm::vec2 GetCursorXY() const
Get cursor's coordinates.
Definition: InputManager.cpp:97
void AssignButton(Button button, Device device, int index)
Assign a button binding.
Definition: InputManager.cpp:109
bool GetScrollDown() const
Get whether user has moved scroll wheel down.
Definition: InputManager.cpp:105
void Update()
Update input state.
Definition: InputManager.cpp:47
bool Pressed(Button button) const
Gets whether a button is currently down.
Definition: InputManager.cpp:118
bool Triggered(Button button) const
Gets whether a button was just pressed.
Definition: InputManager.cpp:122
Device
Input device codes.
Definition: InputManager.hpp:45
@ MOUSE
Mouse buttons.
Definition: InputManager.hpp:47
@ INPUT_DEVICES
Number of input devices.
Definition: InputManager.hpp:48
@ KEYBOARD
Keyboard input.
Definition: InputManager.hpp:46
double GetCursorX() const
Get cursor's horizontal position.
Definition: InputManager.cpp:89
void CharacterCallback(unsigned int codePoint)
GLFW character callback.
Definition: InputManager.cpp:126
void ScrollCallback(double yOffset)
GLFW scrolling callback.
Definition: InputManager.cpp:130
Definition: Window.hpp:14
Definition: ResourceView.hpp:12