Class PS4ControllerSim

java.lang.Object
edu.wpi.first.wpilibj.simulation.GenericHIDSim
edu.wpi.first.wpilibj.simulation.PS4ControllerSim

public class PS4ControllerSim extends GenericHIDSim
Class to control a simulated PS4 controller.
  • Field Summary

    Fields inherited from class edu.wpi.first.wpilibj.simulation.GenericHIDSim

    m_port
  • Constructor Summary

    Constructors
    Constructor
    Description
    PS4ControllerSim(int port)
    Constructs from a joystick port number.
    Constructs from a PS4Controller object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    setCircleButton(boolean value)
    Change the value of the circle button on the controller.
    void
    setCrossButton(boolean value)
    Change the value of the cross button on the controller.
    void
    setL1Button(boolean value)
    Change the value of the left trigger 1 button on the controller.
    void
    setL2Axis(double value)
    Change the value of the left trigger 2 axis on the controller.
    void
    setL2Button(boolean value)
    Change the value of the left trigger 2 button on the controller.
    void
    setL3Button(boolean value)
    Change the value of the L3 (left stick) button on the controller.
    void
    setLeftX(double value)
    Change the left X value of the controller's joystick.
    void
    setLeftY(double value)
    Change the left Y value of the controller's joystick.
    void
    setOptionsButton(boolean value)
    Change the value of the options button on the controller.
    void
    setPSButton(boolean value)
    Change the value of the PlayStation button on the controller.
    void
    setR1Button(boolean value)
    Change the value of the right trigger 1 button on the controller.
    void
    setR2Axis(double value)
    Change the value of the right trigger 2 axis on the controller.
    void
    setR2Button(boolean value)
    Change the value of the right trigger 2 button on the controller.
    void
    setR3Button(boolean value)
    Change the value of the R3 (right stick) button on the controller.
    void
    setRightX(double value)
    Change the right X value of the controller's joystick.
    void
    setRightY(double value)
    Change the right Y value of the controller's joystick.
    void
    setShareButton(boolean value)
    Change the value of the share button on the controller.
    void
    setSquareButton(boolean value)
    Change the value of the square button on the controller.
    void
    setTouchpad(boolean value)
    Deprecated, for removal: This API element is subject to removal in a future version.
    void
    setTouchpadButton(boolean value)
    Change the value of the touchpad button on the controller.
    void
    setTriangleButton(boolean value)
    Change the value of the triangle button on the controller.

    Methods inherited from class java.lang.Object

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

    • PS4ControllerSim

      public PS4ControllerSim(PS4Controller joystick)
      Constructs from a PS4Controller object.
      Parameters:
      joystick - controller to simulate
    • PS4ControllerSim

      public PS4ControllerSim(int port)
      Constructs from a joystick port number.
      Parameters:
      port - port number
  • Method Details

    • setLeftX

      public void setLeftX(double value)
      Change the left X value of the controller's joystick.
      Parameters:
      value - the new value
    • setLeftY

      public void setLeftY(double value)
      Change the left Y value of the controller's joystick.
      Parameters:
      value - the new value
    • setRightX

      public void setRightX(double value)
      Change the right X value of the controller's joystick.
      Parameters:
      value - the new value
    • setRightY

      public void setRightY(double value)
      Change the right Y value of the controller's joystick.
      Parameters:
      value - the new value
    • setL2Axis

      public void setL2Axis(double value)
      Change the value of the left trigger 2 axis on the controller.
      Parameters:
      value - the new value
    • setR2Axis

      public void setR2Axis(double value)
      Change the value of the right trigger 2 axis on the controller.
      Parameters:
      value - the new value
    • setSquareButton

      public void setSquareButton(boolean value)
      Change the value of the square button on the controller.
      Parameters:
      value - the new value
    • setCrossButton

      public void setCrossButton(boolean value)
      Change the value of the cross button on the controller.
      Parameters:
      value - the new value
    • setCircleButton

      public void setCircleButton(boolean value)
      Change the value of the circle button on the controller.
      Parameters:
      value - the new value
    • setTriangleButton

      public void setTriangleButton(boolean value)
      Change the value of the triangle button on the controller.
      Parameters:
      value - the new value
    • setL1Button

      public void setL1Button(boolean value)
      Change the value of the left trigger 1 button on the controller.
      Parameters:
      value - the new value
    • setR1Button

      public void setR1Button(boolean value)
      Change the value of the right trigger 1 button on the controller.
      Parameters:
      value - the new value
    • setL2Button

      public void setL2Button(boolean value)
      Change the value of the left trigger 2 button on the controller.
      Parameters:
      value - the new value
    • setR2Button

      public void setR2Button(boolean value)
      Change the value of the right trigger 2 button on the controller.
      Parameters:
      value - the new value
    • setShareButton

      public void setShareButton(boolean value)
      Change the value of the share button on the controller.
      Parameters:
      value - the new value
    • setOptionsButton

      public void setOptionsButton(boolean value)
      Change the value of the options button on the controller.
      Parameters:
      value - the new value
    • setL3Button

      public void setL3Button(boolean value)
      Change the value of the L3 (left stick) button on the controller.
      Parameters:
      value - the new value
    • setR3Button

      public void setR3Button(boolean value)
      Change the value of the R3 (right stick) button on the controller.
      Parameters:
      value - the new value
    • setPSButton

      public void setPSButton(boolean value)
      Change the value of the PlayStation button on the controller.
      Parameters:
      value - the new value
    • setTouchpadButton

      public void setTouchpadButton(boolean value)
      Change the value of the touchpad button on the controller.
      Parameters:
      value - the new value
    • setTouchpad

      @Deprecated(since="2025", forRemoval=true) public void setTouchpad(boolean value)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use setTouchpadButton(boolean) instead. This function is deprecated for removal to make function names consistent to allow the HID classes to be automatically generated.
      Change the value of the touchpad button on the controller.
      Parameters:
      value - the new value