Class JoystickAxis


  • public class JoystickAxis
    extends java.lang.Object
    Represents a hardware axis on an input device which has a value in [-1,1] (inclusive).
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected JoystickAxis​(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
      void addDeadband​(double magnitude)
      Adds a deadband to the axis such that axis absolute values below this will be returned as 0.
      double getValue()
      Returns the current value of the axis, with deadband applied.
      boolean isInverted()
      Returns whether the axis is inverted (polarity switched).
      boolean isReal()
      Whether this JoystickAxis is a representation of physical hardware.
      void setInverted​(boolean trueIfInverted)
      Sets whether the axis should be inverted (polarity switched).
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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:
        toString in class java.lang.Object