This repository has been archived by the owner on Aug 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
OI.cpp
123 lines (101 loc) · 4.27 KB
/
OI.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
/**
* @file OI.cpp
* @brief Implementation of the Operater Interface
* @author Nyle Rodgers
*/
#include "OI.h"
#include "Commands/Shoot.h"
#include "Commands/ToggleClimber.h"
#include "Commands/SpinHalfRotation.h"
#include "Commands/ControlLights.h"
#include "Commands/ToggleFlashlight.h"
#ifndef USE_PISTON_ARTICULATOR
#include "Commands/SetShooterArticulator.h"
#else
#ifdef PRIMARY_CONTROLS_ARTICULATOR
#include "Commands/ToggleArticulator.h"
#endif
#endif
#include "RobotMap.h"
/**
* Initilize the Operator Interface.
*
* @author Nyle Rodgers
* @author William Kunkel
*/
OI::OI():
// Joysticks
#ifdef USE_PS3_CONTROLLER
primaryJoystick( new Joystick(1) ),
#else
leftPrimaryJoystick( new Joystick(1) ),
rightPrimaryJoystick( new Joystick(2) ),
#endif
secondaryJoystick( new Joystick(3) ),
// Primary driver controls
#ifdef USE_PS3_CONTROLLER
lowSpeedButton( new JoystickButton( primaryJoystick, PS3_SQUARE ) ),
halfSpeedButton( new JoystickButton( primaryJoystick, PS3_TRIANGLE ) ),
fullSpeedButton( new JoystickButton( primaryJoystick, PS3_CIRCLE ) ),
quarterTurnSpeedButton( new JoystickButton( primaryJoystick, PS3_LEFT ) ),
halfTurnSpeedButton( new JoystickButton( primaryJoystick, PS3_UP ) ),
fullTurnSpeedButton( new JoystickButton( primaryJoystick, PS3_RIGHT ) ),
turn180Button( new JoystickButton( primaryJoystick, PS3_R1 ) ),
toggleClimberButton( new JoystickButton( primaryJoystick, PS3_L1 ) ),
#else
lowSpeedButton( new JoystickButton( leftPrimaryJoystick, 2 ) ),
halfSpeedButton( new JoystickButton( leftPrimaryJoystick, 1 ) ),
fullSpeedButton( new JoystickButton( rightPrimaryJoystick, 1 ) ),
quarterTurnSpeedButton( new JoystickButton( rightPrimaryJoystick, 4 ) ),
halfTurnSpeedButton( new JoystickButton( rightPrimaryJoystick, 3 ) ),
fullTurnSpeedButton( new JoystickButton( rightPrimaryJoystick, 5 ) ),
turn180Button( new JoystickButton( rightPrimaryJoystick, 2 ) ),
toggleClimberButton( new JoystickButton( rightPrimaryJoystick, 10 ) ),
#ifdef USE_PISTON_ARTICULATOR
#ifdef PRIMARY_CONTROLS_ARTICULATOR
toggleArticulatorButton( new JoystickButton( leftPrimaryJoystick, 7) ),
#endif
#endif
#endif
// Secondary driver controls
#ifdef USE_GAMECUBE_CONTROLLER
fireButton( new JoystickButton( secondaryJoystick, GC_A ) ),
stopShooterButton( new JoystickButton( secondaryJoystick, GC_B )),
lowSetpointButton( new JoystickButton( secondaryJoystick, GC_LEFT ) ),
midSetpointButton( new JoystickButton( secondaryJoystick, GC_UP ) ),
highSetpointButton( new JoystickButton( secondaryJoystick, GC_RIGHT ) ),
increaseSetpointButton( new JoystickButton( secondaryJoystick, GC_Y) ),
decreaseSetpointButton( new JoystickButton( secondaryJoystick, GC_X) ),
toggleRedButton( new JoystickButton( secondaryJoystick, GC_L ) ),
toggleGreenButton( new JoystickButton( secondaryJoystick, GC_R ) ),
toggleBlueButton( new JoystickButton( secondaryJoystick, GC_Z ) ),
liftResetButton( new JoystickButton( secondaryJoystick, 0 ) )
#else
fireButton( new JoystickButton( secondaryJoystick, 1 ) ),
stopShooterButton( new JoystickButton( secondaryJoystick, 2 )),
lowSetpointButton( new JoystickButton( secondaryJoystick, 4 ) ),
midSetpointButton( new JoystickButton( secondaryJoystick, 3 ) ),
highSetpointButton( new JoystickButton( secondaryJoystick, 5 ) ),
increaseSetpointButton( new JoystickButton( secondaryJoystick, 11) ),
decreaseSetpointButton( new JoystickButton( secondaryJoystick, 10) ),
toggleRedButton( new JoystickButton( secondaryJoystick, 0 ) ),
toggleGreenButton( new JoystickButton( secondaryJoystick, 0 ) ),
toggleBlueButton( new JoystickButton( secondaryJoystick, 0 ) ),
liftResetButton( new JoystickButton( secondaryJoystick, 0 ) )
#endif
{
toggleClimberButton->WhenPressed( new ToggleClimber() );
#ifdef USE_PISTON_ARTICULATOR
#ifdef PRIMARY_CONTROLS_ARTICULATOR
toggleArticulatorButton->WhenPressed( new ToggleArticulator() );
#endif
#endif
turn180Button->WhenPressed( new SpinHalfRotation() );
toggleRedButton->WhenPressed( new ControlLights(ControlLights::RED) );
toggleBlueButton->WhenPressed( new ControlLights(ControlLights::BLUE) );
toggleGreenButton->WhenPressed( new ControlLights(ControlLights::GREEN) );
fireButton->WhenPressed( new Shoot() );
#ifndef USE_PISTON_ARTICULATOR
liftResetButton->WhenPressed( new SetShooterArticulator( 0.0 ) );
#endif
}