WPILibC++ 2025.3.1
Loading...
Searching...
No Matches
frc2::CommandXboxController Class Reference

A version of frc::XboxController with Trigger factories for command-based. More...

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

Inheritance diagram for frc2::CommandXboxController:
frc2::CommandGenericHID

Public Member Functions

 CommandXboxController (int port)
 Construct an instance of a controller.
 
frc::XboxControllerGetHID ()
 Get the underlying GenericHID object.
 
Trigger A (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance around the A button's digital signal.
 
Trigger B (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance around the B button's digital signal.
 
Trigger X (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance around the X button's digital signal.
 
Trigger Y (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance around the Y button's digital signal.
 
Trigger LeftBumper (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance around the left bumper button's digital signal.
 
Trigger RightBumper (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance around the right bumper button's digital signal.
 
Trigger Back (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance around the back button's digital signal.
 
Trigger Start (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance around the start button's digital signal.
 
Trigger LeftStick (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance around the left stick button's digital signal.
 
Trigger RightStick (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance around the right stick button's digital signal.
 
Trigger LeftTrigger (double threshold=0.5, frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance around the axis value of the left trigger.
 
Trigger RightTrigger (double threshold=0.5, frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance around the axis value of the right trigger.
 
double GetLeftX () const
 Get the X axis value of left side of the controller.
 
double GetRightX () const
 Get the X axis value of right side of the controller.
 
double GetLeftY () const
 Get the Y axis value of left side of the controller.
 
double GetRightY () const
 Get the Y axis value of right side of the controller.
 
double GetLeftTriggerAxis () const
 Get the left trigger axis value of the controller.
 
double GetRightTriggerAxis () const
 Get the right trigger axis value of the controller.
 
- Public Member Functions inherited from frc2::CommandGenericHID
 CommandGenericHID (int port)
 Construct an instance of a device.
 
frc::GenericHIDGetHID ()
 Get the underlying GenericHID object.
 
Trigger Button (int button, frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs an event instance around this button's digital signal.
 
Trigger POV (int angle, frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around this angle of a POV on the HID.
 
Trigger POV (int pov, int angle, frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around this angle of a POV on the HID.
 
Trigger POVUp (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around the 0 degree angle (up) of the default (index 0) POV on the HID.
 
Trigger POVUpRight (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around the 45 degree angle (right up) of the default (index 0) POV on the HID.
 
Trigger POVRight (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around the 90 degree angle (right) of the default (index 0) POV on the HID.
 
Trigger POVDownRight (frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around the 135 degree angle (right down) of the default (index 0) POV on the HID.
 
Trigger POVDown (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around the 180 degree angle (down) of the default (index 0) POV on the HID.
 
Trigger POVDownLeft (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around the 225 degree angle (down left) of the default (index 0) POV on the HID.
 
Trigger POVLeft (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around the 270 degree angle (left) of the default (index 0) POV on the HID.
 
Trigger POVUpLeft (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around the 315 degree angle (left up) of the default (index 0) POV on the HID.
 
Trigger POVCenter (frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around the center (not pressed) position of the default (index 0) POV on the HID.
 
Trigger AxisLessThan (int axis, double threshold, frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
 Constructs a Trigger instance that is true when the axis value is less than threshold, attached to the default command scheduler button loop.
 
Trigger AxisGreaterThan (int axis, double threshold, frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
 Constructs a Trigger instance that is true when the axis value is greater than threshold, attached to the default command scheduler button loop.
 
Trigger AxisMagnitudeGreaterThan (int axis, double threshold, frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
 Constructs a Trigger instance that is true when the axis magnitude value is greater than threshold, attached to the given loop.
 
void SetRumble (frc::GenericHID::RumbleType type, double value)
 Set the rumble output for the HID.
 
bool IsConnected () const
 Get if the HID is connected.
 

Detailed Description

A version of frc::XboxController with Trigger factories for command-based.

See also
frc::XboxController

Constructor & Destructor Documentation

◆ CommandXboxController()

frc2::CommandXboxController::CommandXboxController ( int port)
explicit

Construct an instance of a controller.

Parameters
portThe port index on the Driver Station that the controller is plugged into.

Member Function Documentation

◆ A()

Trigger frc2::CommandXboxController::A ( frc::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs a Trigger instance around the A button's digital signal.

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

◆ B()

Trigger frc2::CommandXboxController::B ( frc::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs a Trigger instance around the B button's digital signal.

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

◆ Back()

Trigger frc2::CommandXboxController::Back ( frc::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs a Trigger instance around the back button's digital signal.

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

◆ GetHID()

frc::XboxController & frc2::CommandXboxController::GetHID ( )

Get the underlying GenericHID object.

Returns
the wrapped GenericHID object

◆ GetLeftTriggerAxis()

double frc2::CommandXboxController::GetLeftTriggerAxis ( ) const

Get the left trigger axis value of the controller.

Note that this axis is bound to the range of [0, 1] as opposed to the usual [-1, 1].

Returns
The axis value.

◆ GetLeftX()

double frc2::CommandXboxController::GetLeftX ( ) const

Get the X axis value of left side of the controller.

Right is positive.

Returns
The axis value.

◆ GetLeftY()

double frc2::CommandXboxController::GetLeftY ( ) const

Get the Y axis value of left side of the controller.

Back is positive.

Returns
The axis value.

◆ GetRightTriggerAxis()

double frc2::CommandXboxController::GetRightTriggerAxis ( ) const

Get the right trigger axis value of the controller.

Note that this axis is bound to the range of [0, 1] as opposed to the usual [-1, 1].

Returns
The axis value.

◆ GetRightX()

double frc2::CommandXboxController::GetRightX ( ) const

Get the X axis value of right side of the controller.

Right is positive.

Returns
The axis value.

◆ GetRightY()

double frc2::CommandXboxController::GetRightY ( ) const

Get the Y axis value of right side of the controller.

Back is positive.

Returns
The axis value.

◆ LeftBumper()

Trigger frc2::CommandXboxController::LeftBumper ( frc::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs a Trigger instance around the left bumper button's digital signal.

Parameters
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
a Trigger instance representing the left bumper button's digital signal attached to the given loop.

◆ LeftStick()

Trigger frc2::CommandXboxController::LeftStick ( frc::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs a Trigger instance around the left stick button's digital signal.

Parameters
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
a Trigger instance representing the left stick button's digital signal attached to the given loop.

◆ LeftTrigger()

Trigger frc2::CommandXboxController::LeftTrigger ( double threshold = 0.5,
frc::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop() ) const

Constructs a Trigger instance around the axis value of the left trigger.

The returned Trigger will be true when the axis value is greater than threshold.

Parameters
thresholdthe 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. Defaults to 0.5.
loopthe event loop instance to attach the Trigger to. Defaults to the CommandScheduler's default loop.
Returns
a Trigger instance that is true when the left trigger's axis exceeds the provided threshold, attached to the given loop

◆ RightBumper()

Trigger frc2::CommandXboxController::RightBumper ( frc::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs a Trigger instance around the right bumper button's digital signal.

Parameters
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
a Trigger instance representing the right bumper button's digital signal attached to the given loop.

◆ RightStick()

Trigger frc2::CommandXboxController::RightStick ( frc::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs a Trigger instance around the right stick button's digital signal.

Parameters
loopthe event loop instance to attach the event to. Defaults to the CommandScheduler's default loop.
Returns
a Trigger instance representing the right stick button's digital signal attached to the given loop.

◆ RightTrigger()

Trigger frc2::CommandXboxController::RightTrigger ( double threshold = 0.5,
frc::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop() ) const

Constructs a Trigger instance around the axis value of the right trigger.

The returned Trigger will be true when the axis value is greater than threshold.

Parameters
thresholdthe 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. Defaults to 0.5.
loopthe event loop instance to attach the Trigger to. Defaults to the CommandScheduler's default loop.
Returns
a Trigger instance that is true when the right trigger's axis exceeds the provided threshold, attached to the given loop

◆ Start()

Trigger frc2::CommandXboxController::Start ( frc::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs a Trigger instance around the start button's digital signal.

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

◆ X()

Trigger frc2::CommandXboxController::X ( frc::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs a Trigger instance around the X button's digital signal.

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

◆ Y()

Trigger frc2::CommandXboxController::Y ( frc::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs a Trigger instance around the Y button's digital signal.

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

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