WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
frc2::CommandGenericHID Class Reference

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

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

Inheritance diagram for frc2::CommandGenericHID:
frc2::CommandJoystick frc2::CommandPS4Controller frc2::CommandPS5Controller frc2::CommandStadiaController frc2::CommandXboxController

Public Member Functions

 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::GenericHID with Trigger factories for command-based.

See also
GenericHID

Constructor & Destructor Documentation

◆ CommandGenericHID()

frc2::CommandGenericHID::CommandGenericHID ( int port)
explicit

Construct an instance of a device.

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

Member Function Documentation

◆ AxisGreaterThan()

Trigger frc2::CommandGenericHID::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.

Parameters
axisThe axis to read, starting at 0.
thresholdThe value below which this trigger should return true.
loopthe event loop instance to attach the event to. Defaults to the default command scheduler button loop.
Returns
a Trigger instance that is true when the axis value is greater than the provided threshold.

◆ AxisLessThan()

Trigger frc2::CommandGenericHID::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.

Parameters
axisThe axis to read, starting at 0.
thresholdThe value below which this trigger should return true.
loopthe event loop instance to attach the event to. Defaults to the default command scheduler button loop.
Returns
a Trigger instance that is true when the axis value is less than the provided threshold.

◆ AxisMagnitudeGreaterThan()

Trigger frc2::CommandGenericHID::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.

Parameters
axisThe axis to read, starting at 0
thresholdThe value above which this trigger should return true.
loopthe 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.

◆ Button()

Trigger frc2::CommandGenericHID::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.

◆ GetHID()

frc::GenericHID & frc2::CommandGenericHID::GetHID ( )

Get the underlying GenericHID object.

Returns
the wrapped GenericHID object

◆ IsConnected()

bool frc2::CommandGenericHID::IsConnected ( ) const

Get if the HID is connected.

Returns
true if the HID is connected

◆ POV() [1/2]

Trigger frc2::CommandGenericHID::POV ( int angle,
frc::EventLoop * loop = CommandScheduler::GetInstance().GetDefaultButtonLoop() ) const

Constructs a Trigger instance based around this angle of a POV on the HID.

The POV angles start at 0 in the up direction, and increase clockwise (eg right is 90, upper-left is 315).

Parameters
loopthe event loop instance to attach the event to. Defaults to the default command scheduler button loop.
anglePOV angle in degrees, or -1 for the center / not pressed.
Returns
a Trigger instance based around this angle of a POV on the HID.

◆ POV() [2/2]

Trigger frc2::CommandGenericHID::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.

The POV angles start at 0 in the up direction, and increase clockwise (eg right is 90, upper-left is 315).

Parameters
loopthe event loop instance to attach the event to. Defaults to the default command scheduler button loop.
povindex of the POV to read (starting at 0). Defaults to 0.
anglePOV angle in degrees, or -1 for the center / not pressed.
Returns
a Trigger instance based around this angle of a POV on the HID.

◆ POVCenter()

Trigger frc2::CommandGenericHID::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.

Parameters
loopthe event loop instance to attach the event to. Defaults to the default command scheduler button loop.
Returns
a Trigger instance based around the center position of a POV on the HID.

◆ POVDown()

Trigger frc2::CommandGenericHID::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.

Parameters
loopthe event loop instance to attach the event to. Defaults to the default command scheduler button loop.
Returns
a Trigger instance based around the 180 degree angle of a POV on the HID.

◆ POVDownLeft()

Trigger frc2::CommandGenericHID::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.

Parameters
loopthe event loop instance to attach the event to. Defaults to the default command scheduler button loop.
Returns
a Trigger instance based around the 225 degree angle of a POV on the HID.

◆ POVDownRight()

Trigger frc2::CommandGenericHID::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.

Returns
a Trigger instance based around the 135 degree angle of a POV on the HID.

◆ POVLeft()

Trigger frc2::CommandGenericHID::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.

Parameters
loopthe event loop instance to attach the event to. Defaults to the default command scheduler button loop.
Returns
a Trigger instance based around the 270 degree angle of a POV on the HID.

◆ POVRight()

Trigger frc2::CommandGenericHID::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.

Parameters
loopthe event loop instance to attach the event to. Defaults to the default command scheduler button loop.
Returns
a Trigger instance based around the 90 degree angle of a POV on the HID.

◆ POVUp()

Trigger frc2::CommandGenericHID::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.

Parameters
loopthe event loop instance to attach the event to. Defaults to the default command scheduler button loop.
Returns
a Trigger instance based around the 0 degree angle of a POV on the HID.

◆ POVUpLeft()

Trigger frc2::CommandGenericHID::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.

Parameters
loopthe event loop instance to attach the event to. Defaults to the default command scheduler button loop.
Returns
a Trigger instance based around the 315 degree angle of a POV on the HID.

◆ POVUpRight()

Trigger frc2::CommandGenericHID::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.

Parameters
loopthe event loop instance to attach the event to. Defaults to the default command scheduler button loop.
Returns
a Trigger instance based around the 45 degree angle of a POV on the HID.

◆ SetRumble()

void frc2::CommandGenericHID::SetRumble ( frc::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
typeWhich rumble value to set
valueThe normalized value (0 to 1) to set the rumble to

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