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:
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
ConstructorsModifierConstructorDescriptionprotectedJoystickButton(edu.wpi.first.wpilibj.event.EventLoop pollingLoop, BooleanSupplier pressedLambda, String name, boolean isReal) Constructs a JoystickButton. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns 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).booleanReturns whether the button is inverted (a pressed state returns false instead of true).booleanisReal()Whether this JoystickButton is a representation of physical hardware.toString()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
-
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 forTriggerfunctionality.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 atruestate).- Specified by:
getAsBooleanin interfaceBooleanSupplier- Overrides:
getAsBooleanin 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
-