-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInput.cpp
210 lines (167 loc) · 3.57 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#include "WPILib.h"
#include "Input.h"
#include "DriverStationLCD.h"
#include <assert.h>
Input::Input()
: right_stick(2),
left_stick(1),
arcade_stick(1),
dseio(DriverStation::GetInstance()->GetEnhancedIO())
{
}
void Input::Initialize()
{
//dseio = &(DriverStation::GetInstance()->GetEnhancedIO());
}
bool Input::ShouldManualDriveArm()
{
return right_stick.GetRawButton(6) && right_stick.GetRawButton(11);
}
double Input::GetKickPower()
{
return dseio.GetAnalogIn(1) / 3.3; // Normalized.
}
float Input::GetArcadeLeft()
{
float left = arcade_stick.GetY() + arcade_stick.GetX();
return left;
}
float Input::GetArcadeRight()
{
float right = arcade_stick.GetY() - arcade_stick.GetX();
return right;
}
bool Input::ShouldKick()
{
return right_stick.GetTrigger();
}
float Input::GetLeftDrive()
{
return left_stick.GetY();
}
float Input::GetRightDrive()
{
return right_stick.GetY();
}
bool Input::MagicButton()
{
return false;//dseio->GetButton(0);
}
UINT16 Input::GetAllButtons()
{
return dseio.GetButtons();
}
bool Input::ScorpButton()
{
return !(dseio.GetDigital(7) != 0);
}
bool Input::ClimbButton()
{
return !(dseio.GetDigital(1) != 0);
}
bool Input::shouldReverse()
{
return !dseio.GetDigital(5);
//return false;
}
bool Input::GetDigitalIn(UINT32 channel)
{
return !dseio.GetDigital(channel); // This is just for testing.
}
bool Input::shouldFullSuck(){
return !dseio.GetDigital(3);
//return false;
}
bool Input::ShouldResetWheelEncoders()
{
return false;
}
bool Input::ShouldTarget()
{
//assert(GetLevel() == 6);
if(GetLevel()==6 || GetLevel() == 10){
return left_stick.GetTrigger();
}
else
return false;
}
bool Input::ShouldExtendClimber()
{
//return right_stick.GetRawButton(3);
return this->ScorpButton();
//return false;
}
bool Input::ShouldStopExtendingClimber()
{
return right_stick.GetRawButton(6);
}
bool Input::ShouldClimb()
{
return right_stick.GetRawButton(11);
}
bool Input::ShouldStopClimbing()
{
return !right_stick.GetRawButton(11);
}
bool Input::ShouldStartClimb()
{
return this->ClimbButton();
}
bool Input::ShouldResetClimber()
{
return (right_stick.GetRawButton(8) && right_stick.GetRawButton(9));
}
bool Input::ShouldArmKicker()
{
//return right_stick.GetRawButton(4);
//return false;
return dseio.GetDigital(6) == 0;
}
bool Input::ShouldStopArmingKicker()
{
return right_stick.GetRawButton(7);
}
bool Input::ShouldLaunchKicker()
{
//return right_stick.GetRawButton(5);
//return right_stick.GetRawButton(5);
//return false;
return dseio.GetDigital(8) == 0;
}
bool Input::ShouldClimbUp()
{
return right_stick.GetRawButton(11);
}
bool Input::ShouldClimbDown()
{
return right_stick.GetRawButton(10);
}
bool Input::ShouldWindUp()
{
return right_stick.GetRawButton(6);
}
bool Input::ShouldWindDown()
{
return right_stick.GetRawButton(7);
}
bool Input::ShouldResetKicker()
{
return ( right_stick.GetRawButton(8) && right_stick.GetRawButton(9) );
}
// THIS IS FOR TESTING ONLY
// When we're done with our modules, we'll write functions that avoid raw joystiq exposure.
/*Joystick * Input::GetStick(int stick)
{
if(stick == 0)
return (Joystick*)&left_stick;
else if(stick == 1)
return (Joystick*)&right_stick;
else
return (Joystick*)&arcade_stick;
// else
//dslcd->Printf(DriverStationLCD::kUser_Line1, 1, "!ERROR Joystick not Recognised");
}*/
//bool Input::ShouldTarget()
//{
// return right_stick.GetTrigger();
//}