Package org.chsrobotics.lib.input
Class JoystickAxis
java.lang.Object
org.chsrobotics.lib.input.JoystickAxis
Represents a hardware axis on an input device which has a value in [-1,1] (inclusive).
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJoystickAxis(Supplier<Double> valueLambda, String name, boolean isReal) Constructs a JoystickAxis. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDeadband(double magnitude) Adds a deadband to the axis such that axis absolute values below this will be returned as 0.doublegetValue()Returns the current value of the axis, with deadband applied.booleanReturns whether the axis is inverted (polarity switched).booleanisReal()Whether this JoystickAxis is a representation of physical hardware.voidsetInverted(boolean trueIfInverted) Sets whether the axis should be inverted (polarity switched).toString()
-
Constructor Details
-
JoystickAxis
Constructs a JoystickAxis.- Parameters:
valueLambda- Supplier of the value of the axis, in [-1,1] (inclusive).name- String identifier of the index of this axis in the driver station view.isReal- If this JoystickAxis is a representation of actual hardware.
-
-
Method Details
-
getValue
public double getValue()Returns the current value of the axis, with deadband applied.- Returns:
- Value of the axis, in [-1,1] (inclusive).
-
addDeadband
public void addDeadband(double magnitude) Adds a deadband to the axis such that axis absolute values below this will be returned as 0.- Parameters:
magnitude- The minimum absolute value required for the controller to not return 0.
-
setInverted
public void setInverted(boolean trueIfInverted) Sets whether the axis should be inverted (polarity switched).- Parameters:
trueIfInverted- If the axis should be inverted.
-
isInverted
public boolean isInverted()Returns whether the axis is inverted (polarity switched).- Returns:
- True if the axis is inverted.
-
isReal
public boolean isReal()Whether this JoystickAxis is a representation of physical hardware.- Returns:
- If this exists on an actual controller.
-
toString
-