WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
wpi::cmd::CommandGenericHID Class Reference

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

#include <wpi/commands2/button/CommandGenericHID.hpp>

Inheritance diagram for wpi::cmd::CommandGenericHID:
wpi::cmd::CommandGamepad wpi::cmd::CommandJoystick wpi::cmd::CommandNiDsPS4Controller wpi::cmd::CommandNiDsPS5Controller wpi::cmd::CommandNiDsStadiaController wpi::cmd::CommandNiDsXboxController

Public Member Functions

 CommandGenericHID (int port)
 Construct an instance of a device.
wpi::GenericHIDGetHID ()
 Get the underlying GenericHID object.
Trigger Button (int button, wpi::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs an event instance around this button's digital signal.
Trigger POV (wpi::DriverStation::POVDirection angle, wpi::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around this angle of a POV on the HID.
Trigger POV (int pov, wpi::DriverStation::POVDirection angle, wpi::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around this angle of a POV on the HID.
Trigger POVUp (wpi::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around the up direction of the default (index 0) POV on the HID.
Trigger POVUpRight (wpi::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around the up right direction of the default (index 0) POV on the HID.
Trigger POVRight (wpi::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around the right direction of the default (index 0) POV on the HID.
Trigger POVDownRight (wpi::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around the down right direction of the default (index 0) POV on the HID.
Trigger POVDown (wpi::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around the down direction of the default (index 0) POV on the HID.
Trigger POVDownLeft (wpi::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around the down left direction of the default (index 0) POV on the HID.
Trigger POVLeft (wpi::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around the left direction of the default (index 0) POV on the HID.
Trigger POVUpLeft (wpi::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
 Constructs a Trigger instance based around the up left direction of the default (index 0) POV on the HID.
Trigger POVCenter (wpi::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, wpi::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, wpi::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, wpi::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 (wpi::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 wpi::GenericHID with Trigger factories for command-based.

See also
GenericHID

Constructor & Destructor Documentation

◆ CommandGenericHID()

wpi::cmd::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 wpi::cmd::CommandGenericHID::AxisGreaterThan ( int axis,
double threshold,
wpi::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 wpi::cmd::CommandGenericHID::AxisLessThan ( int axis,
double threshold,
wpi::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 wpi::cmd::CommandGenericHID::AxisMagnitudeGreaterThan ( int axis,
double threshold,
wpi::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 wpi::cmd::CommandGenericHID::Button ( int button,
wpi::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()

wpi::GenericHID & wpi::cmd::CommandGenericHID::GetHID ( )

Get the underlying GenericHID object.

Returns
the wrapped GenericHID object

◆ IsConnected()

bool wpi::cmd::CommandGenericHID::IsConnected ( ) const

Get if the HID is connected.

Returns
true if the HID is connected

◆ POV() [1/2]

Trigger wpi::cmd::CommandGenericHID::POV ( int pov,
wpi::DriverStation::POVDirection angle,
wpi::EventLoop * loop = CommandScheduler::GetInstance().GetDefaultButtonLoop() ) const

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

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.
Returns
a Trigger instance based around this angle of a POV on the HID.

◆ POV() [2/2]

Trigger wpi::cmd::CommandGenericHID::POV ( wpi::DriverStation::POVDirection angle,
wpi::EventLoop * loop = CommandScheduler::GetInstance().GetDefaultButtonLoop() ) const

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

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

◆ POVCenter()

Trigger wpi::cmd::CommandGenericHID::POVCenter ( wpi::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 wpi::cmd::CommandGenericHID::POVDown ( wpi::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs a Trigger instance based around the down direction 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 down direction of a POV on the HID.

◆ POVDownLeft()

Trigger wpi::cmd::CommandGenericHID::POVDownLeft ( wpi::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs a Trigger instance based around the down left direction 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 down left direction of a POV on the HID.

◆ POVDownRight()

Trigger wpi::cmd::CommandGenericHID::POVDownRight ( wpi::EventLoop * loop = CommandScheduler::GetInstance().GetDefaultButtonLoop()) const

Constructs a Trigger instance based around the down right direction of the default (index 0) POV on the HID.

Returns
a Trigger instance based around the down right direction of a POV on the HID.

◆ POVLeft()

Trigger wpi::cmd::CommandGenericHID::POVLeft ( wpi::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs a Trigger instance based around the left direction 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 left direction of a POV on the HID.

◆ POVRight()

Trigger wpi::cmd::CommandGenericHID::POVRight ( wpi::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs a Trigger instance based around the right direction 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 right direction of a POV on the HID.

◆ POVUp()

Trigger wpi::cmd::CommandGenericHID::POVUp ( wpi::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs a Trigger instance based around the up direction 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 up direction of a POV on the HID.

◆ POVUpLeft()

Trigger wpi::cmd::CommandGenericHID::POVUpLeft ( wpi::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs a Trigger instance based around the up left direction 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 up left direction of a POV on the HID.

◆ POVUpRight()

Trigger wpi::cmd::CommandGenericHID::POVUpRight ( wpi::EventLoop * loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const

Constructs a Trigger instance based around the up right direction 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 up right direction of a POV on the HID.

◆ SetRumble()

void wpi::cmd::CommandGenericHID::SetRumble ( wpi::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: