-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKeyState.cpp
More file actions
53 lines (46 loc) · 1.14 KB
/
Copy pathKeyState.cpp
File metadata and controls
53 lines (46 loc) · 1.14 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
#include "KeyState.h"
#include "InputManager.h"
constexpr KeyState NextKeyState(KeyState current, bool isDown)
{
switch (current)
{
case KeyState::Idle:
case KeyState::Released:
return isDown ? KeyState::Down : KeyState::Idle;
case KeyState::Down:
case KeyState::Pressed:
return isDown ? KeyState::Pressed : KeyState::Released;
default:
return KeyState::Idle;
}
}
void KeyboardState::Update()
{
for (unsigned int i = 0; i < KEYBOARD_COUNT; ++i)
{
bool isDown = InputManagement->m_curKeyStates.Test(i);
KeyState current = GetKeyState(i);
SetKeyState(i, NextKeyState(current, isDown));
}
}
void MouseState::Update()
{
for (size_t i = 0; i < MOUSE_COUNT; ++i)
{
bool isDown = InputManagement->m_curMouseState.Test(i);
KeyState current = GetKeyState(i);
SetKeyState(i, NextKeyState(current, isDown));
}
}
void PadState::Update()
{
for (int padNum = 0; padNum < MAX_CONTROLLER; ++padNum)
{
for (size_t btn = 0; btn < GAMEPAD_KEY_COUNT; ++btn)
{
bool isDown = InputManagement->m_curPadState[padNum].Test(btn);
KeyState current = GetKeyState(padNum, btn);
SetKeyState(padNum, btn, NextKeyState(current, isDown));
}
}
}