Package org.chsrobotics.lib.input
Class JoystickAxis
- java.lang.Object
-
- org.chsrobotics.lib.input.JoystickAxis
-
public class JoystickAxis extends java.lang.ObjectRepresents a hardware axis on an input device which has a value in [-1,1] (inclusive).
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedJoystickAxis(java.util.function.Supplier<java.lang.Double> valueLambda, java.lang.String name, boolean isReal)Constructs a JoystickAxis.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDeadband(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.booleanisInverted()Returns 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).java.lang.StringtoString()
-
-
-
Constructor Detail
-
JoystickAxis
protected JoystickAxis(java.util.function.Supplier<java.lang.Double> valueLambda, java.lang.String name, boolean isReal)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 Detail
-
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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-