Class JoystickButton

  • All Implemented Interfaces:
    java.util.function.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​(java.util.function.Supplier<java.lang.Boolean> pressedLambda, java.lang.String name, boolean isReal)
      Constructs a JoystickButton.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean get()
      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 isInverted()
      Returns whether the button is inverted (a pressed state returns false instead of true).
      boolean isReal()
      Whether this JoystickButton is a representation of physical hardware.
      java.lang.String toString()  
      • Methods inherited from class edu.wpi.first.wpilibj2.command.button.Trigger

        and, cancelWhenActive, debounce, debounce, getAsBoolean, negate, or, toggleWhenActive, toggleWhenActive, whenActive, whenActive, whenActive, whenInactive, whenInactive, whenInactive, whileActiveContinuous, whileActiveContinuous, whileActiveContinuous, whileActiveOnce, whileActiveOnce
      • Methods inherited from class java.lang.Object

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

      • JoystickButton

        protected JoystickButton​(java.util.function.Supplier<java.lang.Boolean> pressedLambda,
                                 java.lang.String name,
                                 boolean isReal)
        Constructs a JoystickButton.
        Parameters:
        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 Detail

      • get

        public boolean get()
        Returns a boolean of whether the button is pressed (in a true state).
        Overrides:
        get 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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object