-
Notifications
You must be signed in to change notification settings - Fork 0
/
Input.cpp
36 lines (29 loc) · 917 Bytes
/
Input.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
#include "Input.h"
int Input::GetVerticalAxis()
{
return (int)(bool)GetAsyncKeyState(0x57) - (int)(bool)GetAsyncKeyState(0x53); // W and S
}
int Input::GetHorizontalAxis()
{
return (int)(bool)GetAsyncKeyState(0x44) - (int)(bool)GetAsyncKeyState(0x41); // D and A
}
int Input::GetUpDownAxis()
{
return (int)(bool)GetAsyncKeyState(0x45) - (int)(bool)GetAsyncKeyState(0x51); // Q and E
}
XMFLOAT3 Input::Get3DInputVector()
{
return XMFLOAT3(Input::GetHorizontalAxis(), Input::GetUpDownAxis(), Input::GetVerticalAxis());
}
int Input::GetXAxis()
{
return (int)(bool)GetAsyncKeyState(VK_DOWN) - (int)(bool)GetAsyncKeyState(VK_UP); // Down and Up arrows
}
int Input::GetYAxis()
{
return (int)(bool)GetAsyncKeyState(VK_RIGHT) - (int)(bool)GetAsyncKeyState(VK_LEFT); // Left and Right arrows
}
XMFLOAT2 Input::GetLookInputVector()
{
return XMFLOAT2(Input::GetXAxis(), Input::GetYAxis());
}