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 buttons
= new HashMap
<Integer
, JoystickButton
>();
18 IntStream
.rangeClosed(1, getButtonCount()).forEach((b
) -> {
19 buttons
.put(b
, new JoystickButton(this, b
));
23 public void whenPressed(int button
, Command c
) {
24 buttons
.get(button
).whenPressed(c
);
27 public void whenReleased(int button
, Command c
) {
28 buttons
.get(button
).whenReleased(c
);
31 public void whileHeld(int button
, Command c
) {
32 buttons
.get(button
).whileHeld(c
);
35 public boolean get(int button
) {
36 return getRawButton(button
);