-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinputclass.cpp
80 lines (60 loc) · 1.19 KB
/
inputclass.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "inputclass.h"
InputClass::InputClass()
{
}
InputClass::InputClass(const InputClass& other)
{
}
InputClass::~InputClass()
{
}
void InputClass::Initialize()
{
// Initialize all the keys to being released and not pressed.
for (int i = 0; i < 256; i++)
{
m_keys[i] = false;
}
//initialize the mouse
for (int i = 0; i < 2; i++)
{
m_mouse.m_buttons[i] = false;
m_mouse.m_moved[i] = 0;
}
return;
}
void InputClass::KeyDown(unsigned int input)
{
// If a key is pressed then save that state in the key array.
m_keys[input] = true;
return;
}
void InputClass::KeyUp(unsigned int input)
{
// If a key is released then clear that state in the key array.
m_keys[input] = false;
return;
}
bool InputClass::IsKeyDown(unsigned int key)
{
// Return what state the key is in (pressed/not pressed).
return m_keys[key];
}
void InputClass::SetMouseClicked(bool set)
{
m_mouse.m_buttons[0] = set;
}
bool InputClass::GetMouseClicked()
{
return m_mouse.m_buttons[0];
}
void InputClass::SetMousePosition(int x, int y)
{
m_mouse.m_moved[0] = x;
m_mouse.m_moved[1] = y;
}
int InputClass::GetMousePosition(int axis)
{
if (axis != 0 && axis != 1) return 0;
return m_mouse.m_moved[axis];
}