Commit | Line | Data |
---|---|---|
b449387d LH |
1 | package org.usfirst.frc.team3501.robot; |
2 | ||
3 | import java.util.HashMap; | |
4 | import java.util.stream.IntStream; | |
5 | ||
6 | import edu.wpi.first.wpilibj.buttons.JoystickButton; | |
7 | import edu.wpi.first.wpilibj.command.Command; | |
8 | ||
9 | public class Joystick extends edu.wpi.first.wpilibj.Joystick { | |
10 | ||
11 | private HashMap<Integer, JoystickButton> buttons; | |
12 | ||
13 | public Joystick(int port) { | |
14 | super(port); | |
15 | ||
16 | IntStream.rangeClosed(1, 12).forEach((b) -> { | |
17 | buttons.put(b, new JoystickButton(this, b)); | |
18 | }); | |
19 | } | |
20 | ||
21 | public void whenPressed(int button, Command c) { | |
22 | buttons.get(button).whenPressed(c); | |
23 | } | |
24 | ||
25 | public void whenReleased(int button, Command c) { | |
26 | buttons.get(button).whenReleased(c); | |
27 | } | |
d24e8611 LH |
28 | |
29 | public void whileHeld(int button, Command c) { | |
30 | buttons.get(button).whileHeld(c); | |
31 | } | |
b449387d | 32 | } |