-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyManager.cpp
More file actions
41 lines (30 loc) · 771 Bytes
/
Copy pathKeyManager.cpp
File metadata and controls
41 lines (30 loc) · 771 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
39
40
41
#include "stdafx.h"
KeyManager::KeyManager()
{
}
KeyManager::~KeyManager()
{
}
void KeyManager::Update()
{
bool CurKeyState[256];
for (int i = 0; i < 256; ++i)
{
CurKeyState[i] = GetAsyncKeyState(i) & 0x8000;
bool curkey = CurKeyState[i];
bool prevkey = PrevKeyState[i];
if (prevkey == false && curkey == false) KeyState[i] = EKEY_NONE;
else if (prevkey == false && curkey == true) KeyState[i] = EKEY_DOWN;
else if (prevkey == true && curkey == true) KeyState[i] = EKEY_PRESS;
else if (prevkey == true && curkey == false) KeyState[i] = EKEY_UP;
PrevKeyState[i] = CurKeyState[i];
}
}
INT KeyManager::GetKeyState(int nKey)
{
return KeyState[nKey];
}
void KeyManager::SetMousePos(int x, int y)
{
vMouse = Vector3((float)x, (float)y, 0.f);
}