-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathKeys.cpp
64 lines (51 loc) · 1.1 KB
/
Keys.cpp
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
// Keys.cpp: implementation of the CKeys class.
//
//////////////////////////////////////////////////////////////////////
#include "keys.h"
//////////////////////////////////////////////////////////////////////
// Statics
//////////////////////////////////////////////////////////////////////
CKeys* CKeys::m_pInstance = NULL;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CKeys::CKeys(void)
{
for (int i = 0; i < 255; i++)
m_Keys[i] = false;
for (int i = 0; i < 16; i++)
m_Buttons[i] = false;
}
CKeys::~CKeys(void)
{
}
CKeys* CKeys::GetInstance()
{
if (m_pInstance == NULL)
m_pInstance = new CKeys();
return m_pInstance;
}
void CKeys::KeyDown(int key)
{
m_Keys[key] = true;
}
void CKeys::KeyUp(int key)
{
m_Keys[key] = false;
}
bool CKeys::IsKey(int key)
{
return m_Keys[key];
}
void CKeys::ButtonDown(int button)
{
m_Buttons[button] = true;
}
void CKeys::ButtonUp(int button)
{
m_Buttons[button] = false;
}
bool CKeys::IsButton(int button)
{
return m_Buttons[button];
}