Class CommandDualShock4Controller

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

public class CommandDualShock4Controller extends Object
A version of DualShock4Controller with Trigger factories for command-based.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct an instance of a controller.
    CommandDualShock4Controller(Scheduler scheduler, int port)
    Construct an instance of a controller.
    Construct an instance of a controller.
    Construct an instance of a controller.
  • Method Summary

    Modifier and Type
    Method
    Description
    Constructs a Trigger instance around the Circle button's digital signal.
    Constructs a Trigger instance around the Circle button's digital signal.
    Constructs a Trigger instance around the Cross button's digital signal.
    Constructs a Trigger instance around the Cross button's digital signal.
    Constructs a Trigger instance around the Dpad Down button's digital signal.
    Constructs a Trigger instance around the Dpad Down button's digital signal.
    Constructs a Trigger instance around the Dpad Left button's digital signal.
    Constructs a Trigger instance around the Dpad Left button's digital signal.
    Constructs a Trigger instance around the Dpad Right button's digital signal.
    Constructs a Trigger instance around the Dpad Right button's digital signal.
    Constructs a Trigger instance around the Dpad Up button's digital signal.
    Constructs a Trigger instance around the Dpad Up button's digital signal.
    Get the wrapped controller object.
    Get the underlying CommandGenericHID object.
    double
    Get the L 2 value of the controller.
    double
    Get the Left X value of the controller.
    double
    Get the Left Y value of the controller.
    double
    Get the R 2 value of the controller.
    double
    Get the Right X value of the controller.
    double
    Get the Right Y value of the controller.
    L1()
    Constructs a Trigger instance around the L 1 button's digital signal.
    L1(EventLoop loop)
    Constructs a Trigger instance around the L 1 button's digital signal.
    L2()
    Constructs a Trigger instance around the axis value of the L 2.
    L2(double threshold)
    Constructs a Trigger instance around the axis value of the L 2.
    L2(double threshold, EventLoop loop)
    Constructs a Trigger instance around the axis value of the L 2.
    L3()
    Constructs a Trigger instance around the L 3 button's digital signal.
    L3(EventLoop loop)
    Constructs a Trigger instance around the L 3 button's digital signal.
    Constructs a Trigger instance around the Options button's digital signal.
    Constructs a Trigger instance around the Options button's digital signal.
    PS()
    Constructs a Trigger instance around the PS button's digital signal.
    PS(EventLoop loop)
    Constructs a Trigger instance around the PS button's digital signal.
    R1()
    Constructs a Trigger instance around the R 1 button's digital signal.
    R1(EventLoop loop)
    Constructs a Trigger instance around the R 1 button's digital signal.
    R2()
    Constructs a Trigger instance around the axis value of the R 2.
    R2(double threshold)
    Constructs a Trigger instance around the axis value of the R 2.
    R2(double threshold, EventLoop loop)
    Constructs a Trigger instance around the axis value of the R 2.
    R3()
    Constructs a Trigger instance around the R 3 button's digital signal.
    R3(EventLoop loop)
    Constructs a Trigger instance around the R 3 button's digital signal.
    Constructs a Trigger instance around the Share button's digital signal.
    Constructs a Trigger instance around the Share button's digital signal.
    Constructs a Trigger instance around the Square button's digital signal.
    Constructs a Trigger instance around the Square button's digital signal.
    Constructs a Trigger instance around the Touchpad button's digital signal.
    Constructs a Trigger instance around the Touchpad button's digital signal.
    Constructs a Trigger instance around the Triangle button's digital signal.
    Constructs a Trigger instance around the Triangle button's digital signal.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CommandDualShock4Controller

      public CommandDualShock4Controller(int port)
      Construct an instance of a controller. Commands bound to buttons on the controller will be scheduled on the default scheduler using its default event loop.
      Parameters:
      port - The port index on the Driver Station that the controller is plugged into.
    • CommandDualShock4Controller

      public CommandDualShock4Controller(DualShock4Controller controller)
      Construct an instance of a controller. Commands bound to buttons on the controller will be scheduled on the default scheduler using its default event loop.
      Parameters:
      controller - The DualShock4Controller object to use for this controller.
    • CommandDualShock4Controller

      public CommandDualShock4Controller(Scheduler scheduler, int port)
      Construct an instance of a controller. Commands bound to buttons on the controller will be scheduled on the given scheduler using its default event loop.
      Parameters:
      scheduler - The scheduler that should execute the triggered commands.
      port - The port index on the Driver Station that the controller is plugged into.
    • CommandDualShock4Controller

      public CommandDualShock4Controller(Scheduler scheduler, DualShock4Controller controller)
      Construct an instance of a controller. Commands bound to buttons on the controller will be scheduled on the given scheduler using its default event loop.
      Parameters:
      scheduler - The scheduler that should execute the triggered commands.
      controller - The DualShock4Controller object to use for this controller.
  • Method Details

    • getHID

      public CommandGenericHID getHID()
      Get the underlying CommandGenericHID object.
      Returns:
      the wrapped CommandGenericHID object
    • getController

      public DualShock4Controller getController()
      Get the wrapped controller object.
      Returns:
      the wrapped controller object
    • cross

      public Trigger cross()
      Constructs a Trigger instance around the Cross button's digital signal.
      Returns:
      a Trigger instance representing the Cross button's digital signal attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
      See Also:
    • cross

      public Trigger cross(EventLoop loop)
      Constructs a Trigger instance around the Cross button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      a Trigger instance representing the Cross button's digital signal attached to the given loop.
    • circle

      public Trigger circle()
      Constructs a Trigger instance around the Circle button's digital signal.
      Returns:
      a Trigger instance representing the Circle button's digital signal attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
      See Also:
    • circle

      public Trigger circle(EventLoop loop)
      Constructs a Trigger instance around the Circle button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      a Trigger instance representing the Circle button's digital signal attached to the given loop.
    • square

      public Trigger square()
      Constructs a Trigger instance around the Square button's digital signal.
      Returns:
      a Trigger instance representing the Square button's digital signal attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
      See Also:
    • square

      public Trigger square(EventLoop loop)
      Constructs a Trigger instance around the Square button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      a Trigger instance representing the Square button's digital signal attached to the given loop.
    • triangle

      public Trigger triangle()
      Constructs a Trigger instance around the Triangle button's digital signal.
      Returns:
      a Trigger instance representing the Triangle button's digital signal attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
      See Also:
    • triangle

      public Trigger triangle(EventLoop loop)
      Constructs a Trigger instance around the Triangle button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      a Trigger instance representing the Triangle button's digital signal attached to the given loop.
    • share

      public Trigger share()
      Constructs a Trigger instance around the Share button's digital signal.
      Returns:
      a Trigger instance representing the Share button's digital signal attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
      See Also:
    • share

      public Trigger share(EventLoop loop)
      Constructs a Trigger instance around the Share button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      a Trigger instance representing the Share button's digital signal attached to the given loop.
    • PS

      public Trigger PS()
      Constructs a Trigger instance around the PS button's digital signal.
      Returns:
      a Trigger instance representing the PS button's digital signal attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
      See Also:
    • PS

      public Trigger PS(EventLoop loop)
      Constructs a Trigger instance around the PS button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      a Trigger instance representing the PS button's digital signal attached to the given loop.
    • options

      public Trigger options()
      Constructs a Trigger instance around the Options button's digital signal.
      Returns:
      a Trigger instance representing the Options button's digital signal attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
      See Also:
    • options

      public Trigger options(EventLoop loop)
      Constructs a Trigger instance around the Options button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      a Trigger instance representing the Options button's digital signal attached to the given loop.
    • L3

      public Trigger L3()
      Constructs a Trigger instance around the L 3 button's digital signal.
      Returns:
      a Trigger instance representing the L 3 button's digital signal attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
      See Also:
    • L3

      public Trigger L3(EventLoop loop)
      Constructs a Trigger instance around the L 3 button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      a Trigger instance representing the L 3 button's digital signal attached to the given loop.
    • R3

      public Trigger R3()
      Constructs a Trigger instance around the R 3 button's digital signal.
      Returns:
      a Trigger instance representing the R 3 button's digital signal attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
      See Also:
    • R3

      public Trigger R3(EventLoop loop)
      Constructs a Trigger instance around the R 3 button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      a Trigger instance representing the R 3 button's digital signal attached to the given loop.
    • L1

      public Trigger L1()
      Constructs a Trigger instance around the L 1 button's digital signal.
      Returns:
      a Trigger instance representing the L 1 button's digital signal attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
      See Also:
    • L1

      public Trigger L1(EventLoop loop)
      Constructs a Trigger instance around the L 1 button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      a Trigger instance representing the L 1 button's digital signal attached to the given loop.
    • R1

      public Trigger R1()
      Constructs a Trigger instance around the R 1 button's digital signal.
      Returns:
      a Trigger instance representing the R 1 button's digital signal attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
      See Also:
    • R1

      public Trigger R1(EventLoop loop)
      Constructs a Trigger instance around the R 1 button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      a Trigger instance representing the R 1 button's digital signal attached to the given loop.
    • dpadUp

      public Trigger dpadUp()
      Constructs a Trigger instance around the Dpad Up button's digital signal.
      Returns:
      a Trigger instance representing the Dpad Up button's digital signal attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
      See Also:
    • dpadUp

      public Trigger dpadUp(EventLoop loop)
      Constructs a Trigger instance around the Dpad Up button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      a Trigger instance representing the Dpad Up button's digital signal attached to the given loop.
    • dpadDown

      public Trigger dpadDown()
      Constructs a Trigger instance around the Dpad Down button's digital signal.
      Returns:
      a Trigger instance representing the Dpad Down button's digital signal attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
      See Also:
    • dpadDown

      public Trigger dpadDown(EventLoop loop)
      Constructs a Trigger instance around the Dpad Down button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      a Trigger instance representing the Dpad Down button's digital signal attached to the given loop.
    • dpadLeft

      public Trigger dpadLeft()
      Constructs a Trigger instance around the Dpad Left button's digital signal.
      Returns:
      a Trigger instance representing the Dpad Left button's digital signal attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
      See Also:
    • dpadLeft

      public Trigger dpadLeft(EventLoop loop)
      Constructs a Trigger instance around the Dpad Left button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      a Trigger instance representing the Dpad Left button's digital signal attached to the given loop.
    • dpadRight

      public Trigger dpadRight()
      Constructs a Trigger instance around the Dpad Right button's digital signal.
      Returns:
      a Trigger instance representing the Dpad Right button's digital signal attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
      See Also:
    • dpadRight

      public Trigger dpadRight(EventLoop loop)
      Constructs a Trigger instance around the Dpad Right button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      a Trigger instance representing the Dpad Right button's digital signal attached to the given loop.
    • touchpad

      public Trigger touchpad()
      Constructs a Trigger instance around the Touchpad button's digital signal.
      Returns:
      a Trigger instance representing the Touchpad button's digital signal attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
      See Also:
    • touchpad

      public Trigger touchpad(EventLoop loop)
      Constructs a Trigger instance around the Touchpad button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      a Trigger instance representing the Touchpad button's digital signal attached to the given loop.
    • L2

      public Trigger L2(double threshold, EventLoop loop)
      Constructs a Trigger instance around the axis value of the L 2. The returned trigger will be true when the axis value is greater than threshold.
      Parameters:
      threshold - the minimum axis value for the returned Trigger to be true. This value should be in the range [0, 1] where 0 is the unpressed state of the axis.
      loop - the event loop instance to attach the Trigger to.
      Returns:
      a Trigger instance that is true when the L 2 axis exceeds the provided threshold, attached to the given event loop
    • L2

      public Trigger L2(double threshold)
      Constructs a Trigger instance around the axis value of the L 2. The returned trigger will be true when the axis value is greater than threshold.
      Parameters:
      threshold - the minimum axis value for the returned Trigger to be true. This value should be in the range [0, 1] where 0 is the unpressed state of the axis.
      Returns:
      a Trigger instance that is true when the L 2 axis exceeds the provided threshold, attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
    • L2

      public Trigger L2()
      Constructs a Trigger instance around the axis value of the L 2. The returned trigger will be true when the axis value is greater than 0.5.
      Returns:
      a Trigger instance that is true when the L 2 axis exceeds 0.5, attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
    • R2

      public Trigger R2(double threshold, EventLoop loop)
      Constructs a Trigger instance around the axis value of the R 2. The returned trigger will be true when the axis value is greater than threshold.
      Parameters:
      threshold - the minimum axis value for the returned Trigger to be true. This value should be in the range [0, 1] where 0 is the unpressed state of the axis.
      loop - the event loop instance to attach the Trigger to.
      Returns:
      a Trigger instance that is true when the R 2 axis exceeds the provided threshold, attached to the given event loop
    • R2

      public Trigger R2(double threshold)
      Constructs a Trigger instance around the axis value of the R 2. The returned trigger will be true when the axis value is greater than threshold.
      Parameters:
      threshold - the minimum axis value for the returned Trigger to be true. This value should be in the range [0, 1] where 0 is the unpressed state of the axis.
      Returns:
      a Trigger instance that is true when the R 2 axis exceeds the provided threshold, attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
    • R2

      public Trigger R2()
      Constructs a Trigger instance around the axis value of the R 2. The returned trigger will be true when the axis value is greater than 0.5.
      Returns:
      a Trigger instance that is true when the R 2 axis exceeds 0.5, attached to the default scheduler event loop on the scheduler passed to the controller's constructor, or the default scheduler if a scheduler was not explicitly provided.
    • getLeftX

      public double getLeftX()
      Get the Left X value of the controller.
      Returns:
      The axis value.
    • getLeftY

      public double getLeftY()
      Get the Left Y value of the controller.
      Returns:
      The axis value.
    • getRightX

      public double getRightX()
      Get the Right X value of the controller.
      Returns:
      The axis value.
    • getRightY

      public double getRightY()
      Get the Right Y value of the controller.
      Returns:
      The axis value.
    • getL2

      public double getL2()
      Get the L 2 value of the controller.
      Returns:
      The axis value.
    • getR2

      public double getR2()
      Get the R 2 value of the controller.
      Returns:
      The axis value.