Our team developed a short extension of the Joystick class implementing a couple of useful methods for cases like this.
One of those is a "getToggleButton(int buttonNumber)" that you can use just like getRawButton() in Joystick, the difference being that the return value of the method starts off false and alternates between true and false with each press of the button.
The code is up in our github repo, here's a
link to the specific class (robovikingStick)
Hope that helps!
- Ron
Team #2607 controls mentor