WPILibC++ 2024.3.2
frc2::CommandPS4Controller Class Reference

A version of PS4Controller with Trigger factories for command-based. More...

#include <frc2/command/button/CommandPS4Controller.h>

Inheritance diagram for frc2::CommandPS4Controller:
frc::PS4Controller frc::GenericHID

Public Member Functions

Trigger Button (int button, frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs an event instance around this button's digital signal. More...
 
Trigger Square (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs an event instance around the square button's digital signal. More...
 
Trigger Cross (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs an event instance around the cross button's digital signal. More...
 
Trigger Circle (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs an event instance around the circle button's digital signal. More...
 
Trigger Triangle (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs an event instance around the triangle button's digital signal. More...
 
Trigger L1 (frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
 Constructs an event instance around the L1 button's digital signal. More...
 
Trigger R1 (frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
 Constructs an event instance around the R1 button's digital signal. More...
 
Trigger L2 (frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
 Constructs an event instance around the L2 button's digital signal. More...
 
Trigger R2 (frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
 Constructs an event instance around the R2 button's digital signal. More...
 
Trigger Options (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs an event instance around the options button's digital signal. More...
 
Trigger L3 (frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
 Constructs an event instance around the L3 button's digital signal. More...
 
Trigger R3 (frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
 Constructs an event instance around the R3 button's digital signal. More...
 
Trigger PS (frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
 Constructs an event instance around the PS button's digital signal. More...
 
Trigger Touchpad (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs an event instance around the touchpad's digital signal. More...
 
- Public Member Functions inherited from frc::PS4Controller
 PS4Controller (int port)
 Construct an instance of an PS4 controller. More...
 
 ~PS4Controller () override=default
 
 PS4Controller (PS4Controller &&)=default
 
PS4Controlleroperator= (PS4Controller &&)=default
 
double GetLeftX () const
 Get the X axis value of left side of the controller. More...
 
double GetRightX () const
 Get the X axis value of right side of the controller. More...
 
double GetLeftY () const
 Get the Y axis value of left side of the controller. More...
 
double GetRightY () const
 Get the Y axis value of right side of the controller. More...
 
double GetL2Axis () const
 Get the L2 axis value of the controller. More...
 
double GetR2Axis () const
 Get the R2 axis value of the controller. More...
 
bool GetSquareButton () const
 Read the value of the Square button on the controller. More...
 
bool GetSquareButtonPressed ()
 Whether the Square button was pressed since the last check. More...
 
bool GetSquareButtonReleased ()
 Whether the Square button was released since the last check. More...
 
BooleanEvent Square (EventLoop *loop) const
 Constructs an event instance around the square button's digital signal. More...
 
bool GetCrossButton () const
 Read the value of the Cross button on the controller. More...
 
bool GetCrossButtonPressed ()
 Whether the Cross button was pressed since the last check. More...
 
bool GetCrossButtonReleased ()
 Whether the Cross button was released since the last check. More...
 
BooleanEvent Cross (EventLoop *loop) const
 Constructs an event instance around the cross button's digital signal. More...
 
bool GetCircleButton () const
 Read the value of the Circle button on the controller. More...
 
bool GetCircleButtonPressed ()
 Whether the Circle button was pressed since the last check. More...
 
bool GetCircleButtonReleased ()
 Whether the Circle button was released since the last check. More...
 
BooleanEvent Circle (EventLoop *loop) const
 Constructs an event instance around the circle button's digital signal. More...
 
bool GetTriangleButton () const
 Read the value of the Triangle button on the controller. More...
 
bool GetTriangleButtonPressed ()
 Whether the Triangle button was pressed since the last check. More...
 
bool GetTriangleButtonReleased ()
 Whether the Triangle button was released since the last check. More...
 
BooleanEvent Triangle (EventLoop *loop) const
 Constructs an event instance around the triangle button's digital signal. More...
 
bool GetL1Button () const
 Read the value of the L1 button on the controller. More...
 
bool GetL1ButtonPressed ()
 Whether the L1 button was pressed since the last check. More...
 
bool GetL1ButtonReleased ()
 Whether the L1 button was released since the last check. More...
 
BooleanEvent L1 (EventLoop *loop) const
 Constructs an event instance around the L1 button's digital signal. More...
 
bool GetR1Button () const
 Read the value of the R1 button on the controller. More...
 
bool GetR1ButtonPressed ()
 Whether the R1 button was pressed since the last check. More...
 
bool GetR1ButtonReleased ()
 Whether the R1 button was released since the last check. More...
 
BooleanEvent R1 (EventLoop *loop) const
 Constructs an event instance around the R1 button's digital signal. More...
 
bool GetL2Button () const
 Read the value of the L2 button on the controller. More...
 
bool GetL2ButtonPressed ()
 Whether the L2 button was pressed since the last check. More...
 
bool GetL2ButtonReleased ()
 Whether the L2 button was released since the last check. More...
 
BooleanEvent L2 (EventLoop *loop) const
 Constructs an event instance around the L2 button's digital signal. More...
 
bool GetR2Button () const
 Read the value of the R2 button on the controller. More...
 
bool GetR2ButtonPressed ()
 Whether the R2 button was pressed since the last check. More...
 
bool GetR2ButtonReleased ()
 Whether the R2 button was released since the last check. More...
 
BooleanEvent R2 (EventLoop *loop) const
 Constructs an event instance around the R2 button's digital signal. More...
 
bool GetShareButton () const
 Read the value of the Share button on the controller. More...
 
bool GetShareButtonPressed ()
 Whether the Share button was pressed since the last check. More...
 
bool GetShareButtonReleased ()
 Whether the Share button was released since the last check. More...
 
BooleanEvent Share (EventLoop *loop) const
 Constructs an event instance around the share button's digital signal. More...
 
bool GetOptionsButton () const
 Read the value of the Options button on the controller. More...
 
bool GetOptionsButtonPressed ()
 Whether the Options button was pressed since the last check. More...
 
bool GetOptionsButtonReleased ()
 Whether the Options button was released since the last check. More...
 
BooleanEvent Options (EventLoop *loop) const
 Constructs an event instance around the options button's digital signal. More...
 
bool GetL3Button () const
 Read the value of the L3 button (pressing the left analog stick) on the controller. More...
 
bool GetL3ButtonPressed ()
 Whether the L3 (left stick) button was pressed since the last check. More...
 
bool GetL3ButtonReleased ()
 Whether the L3 (left stick) button was released since the last check. More...
 
BooleanEvent L3 (EventLoop *loop) const
 Constructs an event instance around the L3 button's digital signal. More...
 
bool GetR3Button () const
 Read the value of the R3 button (pressing the right analog stick) on the controller. More...
 
bool GetR3ButtonPressed ()
 Whether the R3 (right stick) button was pressed since the last check. More...
 
bool GetR3ButtonReleased ()
 Whether the R3 (right stick) button was released since the last check. More...
 
BooleanEvent R3 (EventLoop *loop) const
 Constructs an event instance around the R3 button's digital signal. More...
 
bool GetPSButton () const
 Read the value of the PS button on the controller. More...
 
bool GetPSButtonPressed ()
 Whether the PS button was pressed since the last check. More...
 
bool GetPSButtonReleased ()
 Whether the PS button was released since the last check. More...
 
BooleanEvent PS (EventLoop *loop) const
 Constructs an event instance around the PS button's digital signal. More...
 
bool GetTouchpad () const
 Read the value of the touchpad button on the controller. More...
 
bool GetTouchpadPressed ()
 Whether the touchpad was pressed since the last check. More...
 
bool GetTouchpadReleased ()
 Whether the touchpad was released since the last check. More...
 
BooleanEvent Touchpad (EventLoop *loop) const
 Constructs an event instance around the touchpad's digital signal. More...
 
- Public Member Functions inherited from frc::GenericHID
 GenericHID (int port)
 
virtual ~GenericHID ()=default
 
 GenericHID (GenericHID &&)=default
 
GenericHIDoperator= (GenericHID &&)=default
 
bool GetRawButton (int button) const
 Get the button value (starting at button 1). More...
 
bool GetRawButtonPressed (int button)
 Whether the button was pressed since the last check. More...
 
bool GetRawButtonReleased (int button)
 Whether the button was released since the last check. More...
 
BooleanEvent Button (int button, EventLoop *loop) const
 Constructs an event instance around this button's digital signal. More...
 
double GetRawAxis (int axis) const
 Get the value of the axis. More...
 
int GetPOV (int pov=0) const
 Get the angle in degrees of a POV on the HID. More...
 
BooleanEvent POV (int angle, EventLoop *loop) const
 Constructs a BooleanEvent instance based around this angle of a POV on the HID. More...
 
BooleanEvent POV (int pov, int angle, EventLoop *loop) const
 Constructs a BooleanEvent instance based around this angle of a POV on the HID. More...
 
BooleanEvent POVUp (EventLoop *loop) const
 Constructs a BooleanEvent instance based around the 0 degree angle (up) of the default (index 0) POV on the HID. More...
 
BooleanEvent POVUpRight (EventLoop *loop) const
 Constructs a BooleanEvent instance based around the 45 degree angle (right up) of the default (index 0) POV on the HID. More...
 
BooleanEvent POVRight (EventLoop *loop) const
 Constructs a BooleanEvent instance based around the 90 degree angle (right) of the default (index 0) POV on the HID. More...
 
BooleanEvent POVDownRight (EventLoop *loop) const
 Constructs a BooleanEvent instance based around the 135 degree angle (right down) of the default (index 0) POV on the HID. More...
 
BooleanEvent POVDown (EventLoop *loop) const
 Constructs a BooleanEvent instance based around the 180 degree angle (down) of the default (index 0) POV on the HID. More...
 
BooleanEvent POVDownLeft (EventLoop *loop) const
 Constructs a BooleanEvent instance based around the 225 degree angle (down left) of the default (index 0) POV on the HID. More...
 
BooleanEvent POVLeft (EventLoop *loop) const
 Constructs a BooleanEvent instance based around the 270 degree angle (left) of the default (index 0) POV on the HID. More...
 
BooleanEvent POVUpLeft (EventLoop *loop) const
 Constructs a BooleanEvent instance based around the 315 degree angle (left up) of the default (index 0) POV on the HID. More...
 
BooleanEvent POVCenter (EventLoop *loop) const
 Constructs a BooleanEvent instance based around the center (not pressed) of the default (index 0) POV on the HID. More...
 
BooleanEvent AxisLessThan (int axis, double threshold, EventLoop *loop) const
 Constructs an event instance that is true when the axis value is less than threshold. More...
 
BooleanEvent AxisGreaterThan (int axis, double threshold, EventLoop *loop) const
 Constructs an event instance that is true when the axis value is greater than threshold. More...
 
int GetAxisCount () const
 Get the number of axes for the HID. More...
 
int GetPOVCount () const
 Get the number of POVs for the HID. More...
 
int GetButtonCount () const
 Get the number of buttons for the HID. More...
 
bool IsConnected () const
 Get if the HID is connected. More...
 
GenericHID::HIDType GetType () const
 Get the type of the HID. More...
 
std::string GetName () const
 Get the name of the HID. More...
 
int GetAxisType (int axis) const
 Get the axis type of a joystick axis. More...
 
int GetPort () const
 Get the port number of the HID. More...
 
void SetOutput (int outputNumber, bool value)
 Set a single HID output value for the HID. More...
 
void SetOutputs (int value)
 Set all output values for the HID. More...
 
void SetRumble (RumbleType type, double value)
 Set the rumble output for the HID. More...
 

Additional Inherited Members

- Public Types inherited from frc::GenericHID
enum  RumbleType { kLeftRumble , kRightRumble , kBothRumble }
 Represents a rumble output on the Joystick. More...
 
enum  HIDType {
  kUnknown = -1 , kXInputUnknown = 0 , kXInputGamepad = 1 , kXInputWheel = 2 ,
  kXInputArcadeStick = 3 , kXInputFlightStick = 4 , kXInputDancePad = 5 , kXInputGuitar = 6 ,
  kXInputGuitar2 = 7 , kXInputDrumKit = 8 , kXInputGuitar3 = 11 , kXInputArcadePad = 19 ,
  kHIDJoystick = 20 , kHIDGamepad = 21 , kHIDDriving = 22 , kHIDFlight = 23 ,
  kHID1stPerson = 24
}
 USB HID interface type. More...
 

Detailed Description

A version of PS4Controller with Trigger factories for command-based.

See also
PS4Controller

Member Function Documentation

◆ Button()

Trigger frc2::CommandPS4Controller::Button ( int  button,
frc::EventLoop loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop() 
) const

Constructs an event instance around this button's digital signal.

Parameters
buttonthe button index
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
an event instance representing the button's digital signal attached to the given loop.

◆ Circle()

Trigger frc2::CommandPS4Controller::Circle ( frc::EventLoop loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs an event instance around the circle button's digital signal.

Parameters
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
an event instance representing the circle button's digital signal attached to the given loop.

◆ Cross()

Trigger frc2::CommandPS4Controller::Cross ( frc::EventLoop loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs an event instance around the cross button's digital signal.

Parameters
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
an event instance representing the cross button's digital signal attached to the given loop.

◆ L1()

Trigger frc2::CommandPS4Controller::L1 ( frc::EventLoop loop = CommandScheduler::GetInstance().GetDefaultButtonLoop()) const

Constructs an event instance around the L1 button's digital signal.

Parameters
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
an event instance representing the L1 button's digital signal attached to the given loop.

◆ L2()

Trigger frc2::CommandPS4Controller::L2 ( frc::EventLoop loop = CommandScheduler::GetInstance().GetDefaultButtonLoop()) const

Constructs an event instance around the L2 button's digital signal.

Parameters
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
an event instance representing the L2 button's digital signal attached to the given loop.

◆ L3()

Trigger frc2::CommandPS4Controller::L3 ( frc::EventLoop loop = CommandScheduler::GetInstance().GetDefaultButtonLoop()) const

Constructs an event instance around the L3 button's digital signal.

Parameters
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
an event instance representing the L3 button's digital signal attached to the given loop.

◆ Options()

Trigger frc2::CommandPS4Controller::Options ( frc::EventLoop loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs an event instance around the options button's digital signal.

Parameters
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
an event instance representing the options button's digital signal attached to the given loop.

◆ PS()

Trigger frc2::CommandPS4Controller::PS ( frc::EventLoop loop = CommandScheduler::GetInstance().GetDefaultButtonLoop()) const

Constructs an event instance around the PS button's digital signal.

Parameters
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
an event instance representing the PS button's digital signal attached to the given loop.

◆ R1()

Trigger frc2::CommandPS4Controller::R1 ( frc::EventLoop loop = CommandScheduler::GetInstance().GetDefaultButtonLoop()) const

Constructs an event instance around the R1 button's digital signal.

Parameters
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
an event instance representing the R1 button's digital signal attached to the given loop.

◆ R2()

Trigger frc2::CommandPS4Controller::R2 ( frc::EventLoop loop = CommandScheduler::GetInstance().GetDefaultButtonLoop()) const

Constructs an event instance around the R2 button's digital signal.

Parameters
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
an event instance representing the R2 button's digital signal attached to the given loop.

◆ R3()

Trigger frc2::CommandPS4Controller::R3 ( frc::EventLoop loop = CommandScheduler::GetInstance().GetDefaultButtonLoop()) const

Constructs an event instance around the R3 button's digital signal.

Parameters
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
an event instance representing the R3 button's digital signal attached to the given loop.

◆ Square()

Trigger frc2::CommandPS4Controller::Square ( frc::EventLoop loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs an event instance around the square button's digital signal.

Parameters
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
an event instance representing the square button's digital signal attached to the given loop.

◆ Touchpad()

Trigger frc2::CommandPS4Controller::Touchpad ( frc::EventLoop loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs an event instance around the touchpad's digital signal.

Parameters
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
an event instance representing the touchpad's digital signal attached to the given loop.

◆ Triangle()

Trigger frc2::CommandPS4Controller::Triangle ( frc::EventLoop loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs an event instance around the triangle button's digital signal.

Parameters
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
an event instance representing the triangle button's digital signal attached to the given loop.

The documentation for this class was generated from the following file: