16ed17c47527bb4e051eb3e038258fa8bfa4e547
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / OI.java
1 package org.usfirst.frc.team3501.robot;
2
3 import org.usfirst.frc.team3501.robot.commands.driving.BrakeCANTalons;
4 import org.usfirst.frc.team3501.robot.commands.driving.CoastCANTalons;
5
6 import org.usfirst.frc.team3501.robot.commands.driving.ToggleGear;
7 import org.usfirst.frc.team3501.robot.commands.intake.ReverseIntakeContinuous;
8 import org.usfirst.frc.team3501.robot.commands.intake.RunIntakeContinuous;
9 import org.usfirst.frc.team3501.robot.commands.shooter.DecreaseShootingSpeed;
10 import org.usfirst.frc.team3501.robot.commands.shooter.IncreaseShootingSpeed;
11 import org.usfirst.frc.team3501.robot.commands.shooter.ReverseIndexWheelContinuous;
12 import org.usfirst.frc.team3501.robot.commands.shooter.RunFlyWheelContinuous;
13 import org.usfirst.frc.team3501.robot.commands.shooter.RunIndexWheelContinuous;
14 import org.usfirst.frc.team3501.robot.commands.shooter.ToggleIndexerPiston;
15 import org.usfirst.frc.team3501.robot.utils.ChangeCameraView;
16
17 import edu.wpi.first.wpilibj.Joystick;
18 import edu.wpi.first.wpilibj.buttons.Button;
19 import edu.wpi.first.wpilibj.buttons.JoystickButton;
20
21 public class OI /* implements KeyListener */ {
22 private static OI oi;
23 public static Joystick leftJoystick;
24 public static Joystick rightJoystick;
25
26 public static Button runIndexWheel;
27 public static Button reverseIndexWheel;
28 public static Button toggleFlyWheel;
29
30 public static Button toggleGear;
31
32 public static Button runIntake;
33 public static Button reverseIntake;
34
35 public static Button increaseShooterSpeed;
36 public static Button decreaseShooterSpeed;
37
38 private static Button changeCam;
39
40 private static Button togglePiston;
41 private static Button toggleDriveTrainPiston;
42
43 public static Button brakeCANTalons;
44 public static Button coastCANTalons;
45
46 public OI() {
47
48 leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT);
49 rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT);
50
51 runIndexWheel = new JoystickButton(rightJoystick,
52 Constants.OI.RUN_INDEXWHEEL_PORT);
53 runIndexWheel.whileHeld(new RunIndexWheelContinuous());
54
55 reverseIndexWheel = new JoystickButton(rightJoystick,
56 Constants.OI.REVERSE_INDEXWHEEL_PORT);
57 reverseIndexWheel.whileHeld(new ReverseIndexWheelContinuous());
58
59 toggleFlyWheel = new JoystickButton(rightJoystick,
60 Constants.OI.TOGGLE_FLYWHEEL_PORT);
61 toggleFlyWheel.toggleWhenPressed(new RunFlyWheelContinuous());
62
63 toggleGear = new JoystickButton(leftJoystick,
64 Constants.OI.TOGGLE_GEAR_PORT);
65 toggleGear.whenPressed(new ToggleGear());
66
67 runIntake = new JoystickButton(leftJoystick, Constants.OI.RUN_INTAKE_PORT);
68 runIntake.whileHeld(new RunIntakeContinuous());
69
70 reverseIntake = new JoystickButton(leftJoystick,
71 Constants.OI.REVERSE_INTAKE_PORT);
72 reverseIntake.whileHeld(new ReverseIntakeContinuous());
73
74 increaseShooterSpeed = new JoystickButton(leftJoystick,
75 Constants.OI.INCREASE_SHOOTER_SPEED_PORT);
76 increaseShooterSpeed.whenPressed(new IncreaseShootingSpeed());
77
78 decreaseShooterSpeed = new JoystickButton(leftJoystick,
79 Constants.OI.DECREASE_SHOOTER_SPEED_PORT);
80 decreaseShooterSpeed.whenPressed(new DecreaseShootingSpeed());
81
82 changeCam = new JoystickButton(rightJoystick,
83 Constants.OI.CHANGE_CAMERA_VIEW);
84 changeCam.toggleWhenPressed(new ChangeCameraView());
85
86 togglePiston = new JoystickButton(rightJoystick,
87 Constants.Shooter.TOGGLE_INDEXER);
88 togglePiston.whenPressed(new ToggleIndexerPiston());
89
90 toggleDriveTrainPiston = new JoystickButton(rightJoystick,
91 Constants.DriveTrain.TOGGLE_DRIVE_PISTON);
92 toggleDriveTrainPiston.whenPressed(new ToggleGear());
93
94 brakeCANTalons = new JoystickButton(rightJoystick,
95 Constants.OI.BRAKE_CANTALONS_PORT);
96 brakeCANTalons.whenPressed(new BrakeCANTalons());
97
98 coastCANTalons = new JoystickButton(rightJoystick,
99 Constants.OI.COAST_CANTALONS_PORT);
100 coastCANTalons.whenPressed(new CoastCANTalons());
101 }
102
103 public static OI getOI() {
104 if (oi == null)
105 oi = new OI();
106 return oi;
107 }
108
109 /*
110 * @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() ==
111 * KeyEvent.VK_Z) { // Robot.swapCameraFeed();
112 * Robot.getShooter().runIndexWheel(); } }
113 *
114 * @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() ==
115 * KeyEvent.VK_Z) { // Robot.swapCameraFeed();
116 * Robot.getShooter().stopIndexWheel(); } }
117 *
118 * @Override public void keyTyped(KeyEvent e) { }
119 */
120 }