blob: 21a570aacfd72fca49d961e2f498d387f1bdf734 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include "key_watcher.h"
KeyWatcher::KeyWatcher(GLFWwindow* handle, int key):
_handle(handle),
_key(key),
_last_state(glfwGetKey(_handle, _key))
{ }
bool KeyWatcher::wasClicked() {
switch ( glfwGetKey(_handle, _key) ) {
case GLFW_RELEASE:
_last_state = GLFW_RELEASE;
return false;
case GLFW_PRESS:
if ( _last_state == GLFW_RELEASE ) {
_last_state = GLFW_PRESS;
return true;
} else {
return false;
}
default:
return false;
}
}
|