Class JoystickButton

java.lang.Object
edu.wpi.first.wpilibj2.command.button.Trigger
org.chsrobotics.lib.input.JoystickButton
All Implemented Interfaces:
BooleanSupplier
Direct Known Subclasses:
VirtualJoystickButton

public class JoystickButton extends edu.wpi.first.wpilibj2.command.button.Trigger
Represents a hardware button on an input device which has two states.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    JoystickButton(edu.wpi.first.wpilibj.event.EventLoop pollingLoop, BooleanSupplier pressedLambda, String name, boolean isReal)
    Constructs a JoystickButton.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns a boolean of whether the button is pressed (in a true state).
    void
    invert(boolean trueIfInverted)
    Sets whether the button should be inverted (a pressed state returns false instead of true).
    boolean
    Returns whether the button is inverted (a pressed state returns false instead of true).
    boolean
    Whether this JoystickButton is a representation of physical hardware.
     

    Methods inherited from class edu.wpi.first.wpilibj2.command.button.Trigger

    and, cancelWhenActive, debounce, debounce, negate, onFalse, onTrue, or, toggleOnFalse, toggleOnTrue, toggleWhenActive, whenActive, whenActive, whenInactive, whenInactive, whileActiveContinuous, whileActiveContinuous, whileActiveOnce, whileFalse, whileTrue

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • JoystickButton

      protected JoystickButton(edu.wpi.first.wpilibj.event.EventLoop pollingLoop, BooleanSupplier pressedLambda, String name, boolean isReal)
      Constructs a JoystickButton.
      Parameters:
      pollingLoop - EventLoop used to poll the button for Trigger functionality.
      pressedLambda - Supplier of the boolean state of the button.
      name - String identifier of the index of this button in the driver station view.
      isReal - If this JoystickButton is a representation of actual hardware.
  • Method Details

    • getAsBoolean

      public boolean getAsBoolean()
      Returns a boolean of whether the button is pressed (in a true state).
      Specified by:
      getAsBoolean in interface BooleanSupplier
      Overrides:
      getAsBoolean in class edu.wpi.first.wpilibj2.command.button.Trigger
      Returns:
      Whether the button is pressed.
    • isReal

      public boolean isReal()
      Whether this JoystickButton is a representation of physical hardware.
      Returns:
      If this exists on an actual controller.
    • invert

      public void invert(boolean trueIfInverted)
      Sets whether the button should be inverted (a pressed state returns false instead of true).
      Parameters:
      trueIfInverted - Whether to invert the button.
    • isInverted

      public boolean isInverted()
      Returns whether the button is inverted (a pressed state returns false instead of true).
      Returns:
      Whether the button is inverted.
    • toString

      public String toString()
      Overrides:
      toString in class Object