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