forked from terminal29/Simple-OpenVR-Driver-Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathKey.cpp
More file actions
38 lines (34 loc) · 1008 Bytes
/
Key.cpp
File metadata and controls
38 lines (34 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#include <windows.h>
#endif
#include "Key.hpp"
namespace Key {
bool isPressed(KeyEnum key)
{
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
switch (key) {
case UP:
return GetAsyncKeyState(VK_UP) != 0;
case LEFT:
return GetAsyncKeyState(VK_LEFT) != 0;
case DOWN:
return GetAsyncKeyState(VK_DOWN) != 0;
case RIGHT:
return GetAsyncKeyState(VK_RIGHT) != 0;
case W:
return GetAsyncKeyState(0x57) != 0;
case A:
return GetAsyncKeyState(0x41) != 0;
case S:
return GetAsyncKeyState(0x53) != 0;
case D:
return GetAsyncKeyState(0x44) != 0;
case E:
return GetAsyncKeyState(0x45) != 0;
}
#else
(void)key;
#endif
return false;
}
}; // namespace Key