-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathInput.cpp
More file actions
39 lines (29 loc) · 794 Bytes
/
Copy pathInput.cpp
File metadata and controls
39 lines (29 loc) · 794 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
#include "hacklib/Input.h"
#include <Windows.h>
using namespace hl;
void Input::update()
{
for (size_t i = 0; i < m_status.size(); i++)
{
bool keyDown = GetAsyncKeyState(static_cast<int>(i)) < 0;
if (keyDown && !m_status[i].isDown)
m_status[i].state = InputState::WentDown;
else if (!keyDown && m_status[i].isDown)
m_status[i].state = InputState::WentUp;
else
m_status[i].state = InputState::Idle;
m_status[i].isDown = keyDown;
}
}
bool Input::isDown(int vkey) const
{
return m_status[vkey].isDown;
}
bool Input::wentDown(int vkey) const
{
return m_status[vkey].state == InputState::WentDown;
}
bool Input::wentUp(int vkey) const
{
return m_status[vkey].state == InputState::WentUp;
}