-
Notifications
You must be signed in to change notification settings - Fork 0
/
Joystick.cpp
57 lines (47 loc) · 901 Bytes
/
Joystick.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
#include "Joystick.h"
Joystick::Joystick(int xAxisPinId, int yAxisPinId, int microswitchPinId) : StateMachine()
{
m_xAxis = new JoystickAxis(xAxisPinId);
m_yAxis = new JoystickAxis(yAxisPinId);
if (microswitchPinId > -1)
{
m_microswitch = new MicroSwitch(microswitchPinId);
}
else
{
m_microswitch = 0;
}
}
Joystick::~Joystick()
{
delete m_xAxis;
delete m_yAxis;
if (m_microswitch != 0)
{
delete m_microswitch;
}
}
void Joystick::Update(long updateInterval)
{
m_xAxis->Update(updateInterval);
m_yAxis->Update(updateInterval);
m_microswitch->Update(updateInterval);
};
void Joystick::Reset()
{
m_xAxis->Reset();
m_yAxis->Reset();
m_microswitch->Reset();
};
int Joystick::GetXAxis()
{
return m_xAxis->GetState();
}
int Joystick::GetYAxis()
{
return m_yAxis->GetState();
}
int Joystick::GetSwitch()
{
return m_microswitch->GetState();
}