Package org.chsrobotics.lib.input
Class JoystickButton
- java.lang.Object
-
- edu.wpi.first.wpilibj2.command.button.Trigger
-
- org.chsrobotics.lib.input.JoystickButton
-
- All Implemented Interfaces:
java.util.function.BooleanSupplier
- Direct Known Subclasses:
VirtualJoystickButton
public class JoystickButton extends edu.wpi.first.wpilibj2.command.button.TriggerRepresents a hardware button on an input device which has two states.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedJoystickButton(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 booleanget()Returns a boolean of whether the button is pressed (in atruestate).voidinvert(boolean trueIfInverted)Sets whether the button should be inverted (a pressed state returns false instead of true).booleanisInverted()Returns whether the button is inverted (a pressed state returns false instead of true).booleanisReal()Whether this JoystickButton is a representation of physical hardware.java.lang.StringtoString()-
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
-
-
-
-
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 atruestate).- Overrides:
getin classedu.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:
toStringin classjava.lang.Object
-
-