-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathKeyboardInput.cpp
47 lines (37 loc) · 1.83 KB
/
KeyboardInput.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
#include "KeyboardInput.h"
#include "EmulatorSettings.h"
#include <Windows.h>
namespace VBA10
{
KeyboardInput::KeyboardInput(void)
: window(CoreWindow::GetForCurrentThread())
{
ZeroMemory(&state, sizeof(ControllerState));
}
KeyboardInput::~KeyboardInput(void)
{
this->window = nullptr;
}
const ControllerState *KeyboardInput::GetControllerState(void)
{
return &this->state;
}
void KeyboardInput::Update(void)
{
ZeroMemory(&state, sizeof(ControllerState));
if (EmulatorSettings::Current->TurboBehavior == 0)
this->state.TurboTogglePressed = (bool)(window->GetKeyState(GetTurboKeyBinding()) & CoreVirtualKeyStates::Down);
else
this->state.TurboPressed = (bool)(window->GetKeyState(GetTurboKeyBinding()) & CoreVirtualKeyStates::Down);
this->state.StartPressed = (bool)(window->GetKeyState(GetStartKeyBinding()) & CoreVirtualKeyStates::Down);
this->state.SelectPressed = (bool)(window->GetKeyState(GetSelectKeyBinding()) & CoreVirtualKeyStates::Down);
this->state.APressed = (bool)(window->GetKeyState(GetAKeyBinding()) & CoreVirtualKeyStates::Down);
this->state.BPressed = (bool)(window->GetKeyState(GetBKeyBinding()) & CoreVirtualKeyStates::Down);
this->state.LPressed = (bool)(window->GetKeyState(GetLKeyBinding()) & CoreVirtualKeyStates::Down);
this->state.RPressed = (bool)(window->GetKeyState(GetRKeyBinding()) & CoreVirtualKeyStates::Down);
this->state.LeftPressed = (bool)(window->GetKeyState(GetLeftKeyBinding()) & CoreVirtualKeyStates::Down);
this->state.RightPressed = (bool)(window->GetKeyState(GetRightKeyBinding()) & CoreVirtualKeyStates::Down);
this->state.UpPressed = (bool)(window->GetKeyState(GetUpKeyBinding()) & CoreVirtualKeyStates::Down);
this->state.DownPressed = (bool)(window->GetKeyState(GetDownKeyBinding()) & CoreVirtualKeyStates::Down);
}
}