Class CommandGenericHID

java.lang.Object
org.wpilib.command3.button.CommandGenericHID

public final class CommandGenericHID extends Object
A version of GenericHID with Trigger factories for command-based.
See Also:
  • Constructor Details

    • CommandGenericHID

      public CommandGenericHID(Scheduler scheduler, int port)
      Construct an instance of a device.
      Parameters:
      scheduler - The scheduler that should execute the triggered commands.
      port - The port index on the Driver Station that the device is plugged into.
    • CommandGenericHID

      public CommandGenericHID(Scheduler scheduler, GenericHID hid)
      Construct an instance of a device with a GenericHID object.
      Parameters:
      scheduler - The scheduler that should execute the triggered commands.
      hid - The GenericHID object to use for this command HID.
    • CommandGenericHID

      public CommandGenericHID(GenericHID hid)
      Construct an instance of a device with a GenericHID object.
      Parameters:
      hid - The GenericHID object to use for this command HID.
    • CommandGenericHID

      public CommandGenericHID(int port)
      Construct an instance of a device.
      Parameters:
      port - The port index on the Driver Station that the device is plugged into.
  • Method Details

    • getCommandGenericHID

      public static CommandGenericHID getCommandGenericHID(Scheduler scheduler, int port)
      Gets the CommandGenericHID object for the given scheduler and port. CommandGenericHID objects are cached, so this will always return the same object for the same scheduler and port.
      Parameters:
      scheduler - The scheduler that should execute the triggered commands.
      port - The port index on the Driver Station that the device is plugged into.
      Returns:
      The CommandGenericHID object for the given scheduler and port.
    • getCommandGenericHID

      public static CommandGenericHID getCommandGenericHID(int port)
      Gets the CommandGenericHID object for the given port using the default scheduler. CommandGenericHID objects are cached, so this will always return the same object for the same port.
      Parameters:
      port - The port index on the Driver Station that the device is plugged into.
      Returns:
      The CommandGenericHID object for the given port.
    • getHID

      public GenericHID getHID()
      Get the underlying GenericHID object.
      Returns:
      the wrapped GenericHID object
    • button

      public Trigger button(int button)
      Constructs an event instance around this button's digital signal.
      Parameters:
      button - the button index
      Returns:
      an event instance representing the button's digital signal attached to the default scheduler button loop.
      See Also:
    • button

      public Trigger button(int button, EventLoop loop)
      Constructs an event instance around this button's digital signal.
      Parameters:
      button - the button index
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance representing the button's digital signal attached to the given loop.
    • pov

      public Trigger pov(POVDirection angle)
      Constructs a Trigger instance based around this angle of the default (index 0) POV on the HID, attached to the default command scheduler button loop.
      Parameters:
      angle - POV angle
      Returns:
      a Trigger instance based around this angle of a POV on the HID.
    • pov

      public Trigger pov(int pov, POVDirection angle, EventLoop loop)
      Constructs a Trigger instance based around this angle of a POV on the HID.
      Parameters:
      pov - index of the POV to read (starting at 0). Defaults to 0.
      angle - POV angle
      loop - the event loop instance to attach the event to. Defaults to the default command scheduler button loop.
      Returns:
      a Trigger instance based around this angle of a POV on the HID.
    • povUp

      public Trigger povUp()
      Constructs a Trigger instance based around the 0 degree angle (up) of the default (index 0) POV on the HID, attached to the default command scheduler button loop.
      Returns:
      a Trigger instance based around the 0 degree angle of a POV on the HID.
    • povUpRight

      public Trigger povUpRight()
      Constructs a Trigger instance based around the 45 degree angle (right up) of the default (index 0) POV on the HID, attached to the default command scheduler button loop.
      Returns:
      a Trigger instance based around the 45 degree angle of a POV on the HID.
    • povRight

      public Trigger povRight()
      Constructs a Trigger instance based around the 90 degree angle (right) of the default (index 0) POV on the HID, attached to the default command scheduler button loop.
      Returns:
      a Trigger instance based around the 90 degree angle of a POV on the HID.
    • povDownRight

      public Trigger povDownRight()
      Constructs a Trigger instance based around the 135 degree angle (right down) of the default (index 0) POV on the HID, attached to the default command scheduler button loop.
      Returns:
      a Trigger instance based around the 135 degree angle of a POV on the HID.
    • povDown

      public Trigger povDown()
      Constructs a Trigger instance based around the 180 degree angle (down) of the default (index 0) POV on the HID, attached to the default command scheduler button loop.
      Returns:
      a Trigger instance based around the 180 degree angle of a POV on the HID.
    • povDownLeft

      public Trigger povDownLeft()
      Constructs a Trigger instance based around the 225 degree angle (down left) of the default (index 0) POV on the HID, attached to the default command scheduler button loop.
      Returns:
      a Trigger instance based around the 225 degree angle of a POV on the HID.
    • povLeft

      public Trigger povLeft()
      Constructs a Trigger instance based around the 270 degree angle (left) of the default (index 0) POV on the HID, attached to the default command scheduler button loop.
      Returns:
      a Trigger instance based around the 270 degree angle of a POV on the HID.
    • povUpLeft

      public Trigger povUpLeft()
      Constructs a Trigger instance based around the 315 degree angle (left up) of the default (index 0) POV on the HID, attached to the default command scheduler button loop.
      Returns:
      a Trigger instance based around the 315 degree angle of a POV on the HID.
    • povCenter

      public Trigger povCenter()
      Constructs a Trigger instance based around the center (not pressed) position of the default (index 0) POV on the HID, attached to the default command scheduler button loop.
      Returns:
      a Trigger instance based around the center position of a POV on the HID.
    • axisLessThan

      public Trigger axisLessThan(int axis, double threshold)
      Constructs a Trigger instance that is true when the axis value is less than threshold, attached to the default command scheduler button loop.
      Parameters:
      axis - The axis to read, starting at 0
      threshold - The value below which this trigger should return true.
      Returns:
      a Trigger instance that is true when the axis value is less than the provided threshold.
    • axisLessThan

      public Trigger axisLessThan(int axis, double threshold, EventLoop loop)
      Constructs a Trigger instance that is true when the axis value is less than threshold, attached to the given loop.
      Parameters:
      axis - The axis to read, starting at 0
      threshold - The value below which this trigger should return true.
      loop - the event loop instance to attach the trigger to
      Returns:
      a Trigger instance that is true when the axis value is less than the provided threshold.
    • axisGreaterThan

      public Trigger axisGreaterThan(int axis, double threshold)
      Constructs a Trigger instance that is true when the axis value is less than threshold, attached to the default command scheduler button loop.
      Parameters:
      axis - The axis to read, starting at 0
      threshold - The value above which this trigger should return true.
      Returns:
      a Trigger instance that is true when the axis value is greater than the provided threshold.
    • axisGreaterThan

      public Trigger axisGreaterThan(int axis, double threshold, EventLoop loop)
      Constructs a Trigger instance that is true when the axis value is greater than threshold, attached to the given loop.
      Parameters:
      axis - The axis to read, starting at 0
      threshold - The value above which this trigger should return true.
      loop - the event loop instance to attach the trigger to.
      Returns:
      a Trigger instance that is true when the axis value is greater than the provided threshold.
    • axisMagnitudeGreaterThan

      public Trigger axisMagnitudeGreaterThan(int axis, double threshold, EventLoop loop)
      Constructs a Trigger instance that is true when the axis magnitude value is greater than threshold, attached to the given loop.
      Parameters:
      axis - The axis to read, starting at 0
      threshold - The value above which this trigger should return true.
      loop - the event loop instance to attach the trigger to.
      Returns:
      a Trigger instance that is true when the axis magnitude value is greater than the provided threshold.
    • axisMagnitudeGreaterThan

      public Trigger axisMagnitudeGreaterThan(int axis, double threshold)
      Constructs a Trigger instance that is true when the axis magnitude value is greater than threshold, attached to the default command scheduler button loop.
      Parameters:
      axis - The axis to read, starting at 0
      threshold - The value above which this trigger should return true.
      Returns:
      a Trigger instance that is true when the deadbanded axis value is active (non-zero).
    • getRawAxis

      public double getRawAxis(int axis)
      Get the value of the axis.
      Parameters:
      axis - The axis to read, starting at 0.
      Returns:
      The value of the axis.
    • setRumble

      public void setRumble(GenericHID.RumbleType type, double value)
      Set the rumble output for the HID. The DS currently supports 2 rumble values, left rumble and right rumble.
      Parameters:
      type - Which rumble value to set
      value - The normalized value (0 to 1) to set the rumble to
    • isConnected

      public boolean isConnected()
      Get if the HID is connected.
      Returns:
      true if the HID is connected