1 package org
.usfirst
.frc
.team3501
.robot
;
3 import java
.util
.HashMap
;
4 import java
.util
.stream
.IntStream
;
6 import edu
.wpi
.first
.wpilibj
.buttons
.JoystickButton
;
7 import edu
.wpi
.first
.wpilibj
.command
.Command
;
9 public class Joystick
extends edu
.wpi
.first
.wpilibj
.Joystick
{
11 private HashMap
<Integer
, JoystickButton
> buttons
;
13 public Joystick(int port
) {
16 IntStream
.rangeClosed(1, 12).forEach((b
) -> {
17 buttons
.put(b
, new JoystickButton(this, b
));
21 public void whenPressed(int button
, Command c
) {
22 buttons
.get(button
).whenPressed(c
);
25 public void whenReleased(int button
, Command c
) {
26 buttons
.get(button
).whenReleased(c
);
29 public void whileHeld(int button
, Command c
) {
30 buttons
.get(button
).whileHeld(c
);
33 public boolean get(int button
) {
34 return getRawButton(button
);