-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeyManager.cpp
More file actions
75 lines (57 loc) · 1.02 KB
/
keyManager.cpp
File metadata and controls
75 lines (57 loc) · 1.02 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
#include "stdafx.h"
#include "keyManager.h"
keyManager::keyManager()
{
}
keyManager::~keyManager()
{
}
HRESULT keyManager::init()
{
//처음에 모든 키 상태는 눌려지지 않은 것으로 초기화 해둔다
for (int i = 0; i < KEYMAX; i++)
{
this->getKeyUp().set(i, false);
}
return S_OK;
}
void keyManager::release()
{
}
bool keyManager::isOnceKeyDown(int key)
{
if (GetAsyncKeyState(key) & 0x8000)
{
if (!this->getKeyDown()[key])
{
this->setKeyDown(key, true);
return true;
}
}
else this->setKeyDown(key, false);
return false;
}
bool keyManager::isOnceKeyUp(int key)
{
if (GetAsyncKeyState(key) & 0x8000) this->setKeyUp(key, true);
else
{
if (this->getKeyUp()[key])
{
this->setKeyUp(key, false);
return true;
}
}
return false;
}
bool keyManager::isStayKeyDown(int key)
{
if (GetAsyncKeyState(key) & 0x8000) return true;
return false;
}
bool keyManager::isToggleKey(int key)
{
//GetASyncKeyState는 비동기 방식이라 토글이 안먹힘(씹힘)
if (GetKeyState(key) & 0x0001) return true;
return false;
}