Commit | Line | Data |
---|---|---|
38a404b3 KZ |
1 | package org.usfirst.frc.team3501.robot; |
2 | ||
e7bf265c RR |
3 | import java.awt.event.KeyAdapter; |
4 | import java.awt.event.KeyEvent; | |
5 | ||
6 | import javax.swing.JButton; | |
7 | ||
9dc69158 | 8 | import org.usfirst.frc.team3501.robot.commands.climber.ToggleWinch; |
7935bf26 | 9 | import org.usfirst.frc.team3501.robot.commands.driving.ToggleGear; |
cef1f36d RR |
10 | import org.usfirst.frc.team3501.robot.commands.intake.ReverseIntakeContinuous; |
11 | import org.usfirst.frc.team3501.robot.commands.intake.RunIntakeContinuous; | |
5e93f308 CZ |
12 | import org.usfirst.frc.team3501.robot.commands.shooter.DecreaseShootingSpeed; |
13 | import org.usfirst.frc.team3501.robot.commands.shooter.IncreaseShootingSpeed; | |
cef1f36d RR |
14 | import org.usfirst.frc.team3501.robot.commands.shooter.ReverseIndexWheelContinuous; |
15 | import org.usfirst.frc.team3501.robot.commands.shooter.RunFlyWheelContinuous; | |
16 | import org.usfirst.frc.team3501.robot.commands.shooter.RunIndexWheelContinuous; | |
7935bf26 | 17 | |
38a404b3 | 18 | import edu.wpi.first.wpilibj.Joystick; |
de8c65d3 SG |
19 | import edu.wpi.first.wpilibj.buttons.Button; |
20 | import edu.wpi.first.wpilibj.buttons.JoystickButton; | |
38a404b3 KZ |
21 | |
22 | public class OI { | |
cca02549 | 23 | private static OI oi; |
38a404b3 KZ |
24 | public static Joystick leftJoystick; |
25 | public static Joystick rightJoystick; | |
83fa645c | 26 | public static Button toggleWinch; |
38a404b3 | 27 | |
cef1f36d RR |
28 | public static Button runIndexWheel; |
29 | public static Button reverseIndexWheel; | |
e7bf265c RR |
30 | // public static Button toggleFlyWheel; |
31 | public static JButton toggleFlyWheel; | |
2291f7b3 | 32 | |
7935bf26 AD |
33 | public static Button toggleGear; |
34 | ||
cef1f36d RR |
35 | public static Button runIntake; |
36 | public static Button reverseIntake; | |
37 | ||
5e93f308 CZ |
38 | public static Button increaseShooterSpeed; |
39 | public static Button decreaseShooterSpeed; | |
40 | ||
e7bf265c RR |
41 | // private static Key a; |
42 | ||
38a404b3 KZ |
43 | public OI() { |
44 | leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT); | |
45 | rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT); | |
cef1f36d | 46 | |
5e93f308 CZ |
47 | runIndexWheel = new JoystickButton(rightJoystick, |
48 | Constants.OI.RUN_INDEXWHEEL_PORT); | |
cef1f36d RR |
49 | runIndexWheel.whileHeld(new RunIndexWheelContinuous()); |
50 | ||
aec45ad9 | 51 | reverseIndexWheel = new JoystickButton(rightJoystick, |
cef1f36d RR |
52 | Constants.OI.REVERSE_INDEXWHEEL_PORT); |
53 | reverseIndexWheel.whileHeld(new ReverseIndexWheelContinuous()); | |
54 | ||
e7bf265c RR |
55 | /* |
56 | * toggleFlyWheel = new JoystickButton(rightJoystick, | |
57 | * Constants.OI.TOGGLE_FLYWHEEL_PORT); toggleFlyWheel.toggleWhenPressed(new | |
58 | * RunFlyWheelContinuous()); | |
59 | */ | |
60 | ||
61 | toggleFlyWheel = new JButton(); | |
62 | toggleFlyWheel.addKeyListener(new KeyAdapter() { | |
63 | RunFlyWheelContinuous runflywheel = new RunFlyWheelContinuous(); | |
64 | ||
65 | /*** | |
66 | * Starts the run index wheel continuous function | |
67 | */ | |
68 | @Override | |
69 | public void keyPressed(KeyEvent e) { | |
70 | if (e.getKeyCode() == KeyEvent.VK_0) { | |
71 | runflywheel.start(); | |
72 | } | |
73 | } | |
74 | ||
75 | /*** | |
76 | * Ends the run index wheel continuous function | |
77 | */ | |
78 | @Override | |
79 | public void keyReleased(KeyEvent e) { | |
80 | if (e.getKeyCode() == KeyEvent.VK_0) { | |
81 | runflywheel.cancel(); | |
82 | } | |
83 | } | |
84 | ||
85 | }); | |
cef1f36d | 86 | |
7935bf26 AD |
87 | toggleGear = new JoystickButton(leftJoystick, |
88 | Constants.OI.TOGGLE_GEAR_PORT); | |
89 | toggleGear.whenPressed(new ToggleGear()); | |
cef1f36d | 90 | |
aec45ad9 | 91 | runIntake = new JoystickButton(leftJoystick, Constants.OI.RUN_INTAKE_PORT); |
cef1f36d RR |
92 | runIntake.whileHeld(new RunIntakeContinuous()); |
93 | ||
94 | reverseIntake = new JoystickButton(leftJoystick, | |
95 | Constants.OI.REVERSE_INTAKE_PORT); | |
96 | reverseIntake.whileHeld(new ReverseIntakeContinuous()); | |
97 | ||
98 | toggleWinch = new JoystickButton(leftJoystick, | |
99 | Constants.OI.TOGGLE_WINCH_PORT); | |
25ef99e6 | 100 | toggleWinch.whenPressed(new ToggleWinch()); |
5e93f308 CZ |
101 | |
102 | increaseShooterSpeed = new JoystickButton(leftJoystick, | |
103 | Constants.OI.INCREASE_SHOOTER_SPEED_PORT); | |
104 | increaseShooterSpeed.whenPressed(new IncreaseShootingSpeed()); | |
105 | ||
106 | decreaseShooterSpeed = new JoystickButton(leftJoystick, | |
107 | Constants.OI.DECREASE_SHOOTER_SPEED_PORT); | |
108 | decreaseShooterSpeed.whenPressed(new DecreaseShootingSpeed()); | |
38a404b3 | 109 | } |
cf086549 SG |
110 | |
111 | public static OI getOI() { | |
112 | if (oi == null) | |
113 | oi = new OI(); | |
114 | return oi; | |
cca02549 | 115 | } |
38a404b3 | 116 | } |