-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyStater.cpp
More file actions
76 lines (71 loc) · 1.3 KB
/
Copy pathKeyStater.cpp
File metadata and controls
76 lines (71 loc) · 1.3 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "KeyStater.h"
KeyStater::KeyStater()
{
GetKeyboardState(curStates);
for (int i = 0; i < 256; i++)
{
oldStates[i] = curStates[i];
}
GetCursorPos(&curs);
ScreenToClient(thiswindow, &curs);
}
KeyStater::~KeyStater()
{
}
void KeyStater::Update()
{
for (int i = 0; i < 256; i++)
{
oldStates[i] = curStates[i];
}
GetKeyboardState(curStates);
GetCursorPos(&curs);
ScreenToClient(thiswindow, &curs);
}
void KeyStater::Debug()
{
if (IsPressed(VK_F5))
showDebug = !showDebug;
if (showDebug)
{
for (int i = 0; i < 16; i++)
{
for (int a = 0; a < 16; a++)
{
char keyhold[10];
_itoa_s(curStates[(i * 16) + a], keyhold, 10);
//DrawString(keyhold, i * 20, (a * 20) + 40, SColour(125, 125, 125, 255)); CREATE DRAWSTRING FUNC
}
}
}
}
bool KeyStater::IsUp(int key)
{
if (curStates[key] < 2 && oldStates[key] < 2)
return true;
return false;
}
bool KeyStater::IsDown(int key)
{
if (curStates[key] > 2 && oldStates[key] > 2)
return true;
return false;
}
bool KeyStater::IsToggledOn(int key)
{
if (curStates[key] == 1)
return true;
return false;
}
bool KeyStater::IsPressed(int key)
{
if (curStates[key] > 2 && oldStates[key] < 2)
return true;
return false;
}
bool KeyStater::IsReleased(int key)
{
if (curStates[key] < 2 && oldStates[key] > 2)
return true;
return false;
}