Update README.md
[tar-legacy.git] / MCDV / GLFWUtil.hpp
1 #pragma once
2 #include <GLFW\glfw3.h>
3
4 class util_keyHandler {
5 private:
6 GLFWwindow* windowHandle;
7 int* states_previous_frame = new int[GLFW_KEY_LAST]; // About a kb
8
9 public:
10
11 bool getKeyDown(int key) {
12
13 if ((states_previous_frame[key] != GLFW_PRESS) && (glfwGetKey(this->windowHandle, key) == GLFW_PRESS)) {
14 states_previous_frame[key] = glfwGetKey(this->windowHandle, key);
15 return true;
16 }
17
18 states_previous_frame[key] = glfwGetKey(this->windowHandle, key);
19
20 return false;
21 }
22
23 bool getKey(int key) {
24 if (glfwGetKey(this->windowHandle, key) == GLFW_PRESS)
25 return true;
26
27 return false;
28 }
29
30 util_keyHandler(GLFWwindow* window) {
31 this->windowHandle = window;
32 }
33 };