Class CommandGenericHID
java.lang.Object
edu.wpi.first.wpilibj2.command.button.CommandGenericHID
- Direct Known Subclasses:
CommandJoystick
,CommandPS4Controller
,CommandPS5Controller
,CommandStadiaController
,CommandXboxController
A version of
GenericHID
with Trigger
factories for command-based.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaxisGreaterThan
(int axis, double threshold) Constructs a Trigger instance that is true when the axis value is less thanthreshold
, attached tothe default command scheduler button loop
.axisGreaterThan
(int axis, double threshold, EventLoop loop) Constructs a Trigger instance that is true when the axis value is greater thanthreshold
, attached to the given loop.axisLessThan
(int axis, double threshold) Constructs a Trigger instance that is true when the axis value is less thanthreshold
, attached tothe default command scheduler button loop
.axisLessThan
(int axis, double threshold, EventLoop loop) Constructs a Trigger instance that is true when the axis value is less thanthreshold
, attached to the given loop.axisMagnitudeGreaterThan
(int axis, double threshold) Constructs a Trigger instance that is true when the axis magnitude value is greater thanthreshold
, attached tothe default command scheduler button loop
.axisMagnitudeGreaterThan
(int axis, double threshold, EventLoop loop) Constructs a Trigger instance that is true when the axis magnitude value is greater thanthreshold
, attached to the given loop.button
(int button) Constructs an event instance around this button's digital signal.Constructs an event instance around this button's digital signal.getHID()
Get the underlying GenericHID object.double
getRawAxis
(int axis) Get the value of the axis.boolean
Get if the HID is connected.pov
(int angle) Constructs a Trigger instance based around this angle of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.Constructs a Trigger instance based around this angle of a POV on the HID.Constructs a Trigger instance based around the center (not pressed) position of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.povDown()
Constructs a Trigger instance based around the 180 degree angle (down) of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.Constructs a Trigger instance based around the 225 degree angle (down left) of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.Constructs a Trigger instance based around the 135 degree angle (right down) of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.povLeft()
Constructs a Trigger instance based around the 270 degree angle (left) of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.povRight()
Constructs a Trigger instance based around the 90 degree angle (right) of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.povUp()
Constructs a Trigger instance based around the 0 degree angle (up) of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.Constructs a Trigger instance based around the 315 degree angle (left up) of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.Constructs a Trigger instance based around the 45 degree angle (right up) of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.void
setRumble
(GenericHID.RumbleType type, double value) Set the rumble output for the HID.
-
Constructor Details
-
CommandGenericHID
Construct an instance of a device.- Parameters:
port
- The port index on the Driver Station that the device is plugged into.
-
-
Method Details
-
getHID
Get the underlying GenericHID object.- Returns:
- the wrapped GenericHID object
-
button
Constructs an event instance around this button's digital signal.- Parameters:
button
- the button index- Returns:
- an event instance representing the button's digital signal attached to the
default scheduler button loop
. - See Also:
-
button
Constructs an event instance around this button's digital signal.- Parameters:
button
- the button indexloop
- the event loop instance to attach the event to.- Returns:
- an event instance representing the button's digital signal attached to the given loop.
-
pov
Constructs a Trigger instance based around this angle of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.The POV angles start at 0 in the up direction, and increase clockwise (e.g. right is 90, upper-left is 315).
- Parameters:
angle
- POV 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
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 (e.g. right is 90, upper-left is 315).
- Parameters:
pov
- index of the POV to read (starting at 0). Defaults to 0.angle
- POV angle in degrees, or -1 for the center / not pressed.loop
- the event loop instance to attach the event to. Defaults tothe default command scheduler button loop
.- Returns:
- a Trigger instance based around this angle of a POV on the HID.
-
povUp
Constructs a Trigger instance based around the 0 degree angle (up) of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.- Returns:
- a Trigger instance based around the 0 degree angle of a POV on the HID.
-
povUpRight
Constructs a Trigger instance based around the 45 degree angle (right up) of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.- Returns:
- a Trigger instance based around the 45 degree angle of a POV on the HID.
-
povRight
Constructs a Trigger instance based around the 90 degree angle (right) of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.- Returns:
- a Trigger instance based around the 90 degree angle of a POV on the HID.
-
povDownRight
Constructs a Trigger instance based around the 135 degree angle (right down) of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.- Returns:
- a Trigger instance based around the 135 degree angle of a POV on the HID.
-
povDown
Constructs a Trigger instance based around the 180 degree angle (down) of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.- Returns:
- a Trigger instance based around the 180 degree angle of a POV on the HID.
-
povDownLeft
Constructs a Trigger instance based around the 225 degree angle (down left) of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.- Returns:
- a Trigger instance based around the 225 degree angle of a POV on the HID.
-
povLeft
Constructs a Trigger instance based around the 270 degree angle (left) of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.- Returns:
- a Trigger instance based around the 270 degree angle of a POV on the HID.
-
povUpLeft
Constructs a Trigger instance based around the 315 degree angle (left up) of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.- Returns:
- a Trigger instance based around the 315 degree angle of a POV on the HID.
-
povCenter
Constructs a Trigger instance based around the center (not pressed) position of the default (index 0) POV on the HID, attached tothe default command scheduler button loop
.- Returns:
- a Trigger instance based around the center position of a POV on the HID.
-
axisLessThan
Constructs a Trigger instance that is true when the axis value is less thanthreshold
, attached tothe default command scheduler button loop
.- Parameters:
axis
- The axis to read, starting at 0threshold
- The value below which this trigger should return true.- Returns:
- a Trigger instance that is true when the axis value is less than the provided threshold.
-
axisLessThan
Constructs a Trigger instance that is true when the axis value is less thanthreshold
, attached to the given loop.- Parameters:
axis
- The axis to read, starting at 0threshold
- The value below which this trigger should return true.loop
- the event loop instance to attach the trigger to- Returns:
- a Trigger instance that is true when the axis value is less than the provided threshold.
-
axisGreaterThan
Constructs a Trigger instance that is true when the axis value is less thanthreshold
, attached tothe default command scheduler button loop
.- Parameters:
axis
- The axis to read, starting at 0threshold
- The value above which this trigger should return true.- Returns:
- a Trigger instance that is true when the axis value is greater than the provided threshold.
-
axisGreaterThan
Constructs a Trigger instance that is true when the axis value is greater thanthreshold
, attached to the given loop.- Parameters:
axis
- The axis to read, starting at 0threshold
- The value above which this trigger should return true.loop
- the event loop instance to attach the trigger to.- Returns:
- a Trigger instance that is true when the axis value is greater than the provided threshold.
-
axisMagnitudeGreaterThan
Constructs a Trigger instance that is true when the axis magnitude value is greater thanthreshold
, attached to the given loop.- Parameters:
axis
- The axis to read, starting at 0threshold
- The value above which this trigger should return true.loop
- the 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.
-
axisMagnitudeGreaterThan
Constructs a Trigger instance that is true when the axis magnitude value is greater thanthreshold
, attached tothe default command scheduler button loop
.- Parameters:
axis
- The axis to read, starting at 0threshold
- The value above which this trigger should return true.- Returns:
- a Trigger instance that is true when the deadbanded axis value is active (non-zero).
-
getRawAxis
Get the value of the axis.- Parameters:
axis
- The axis to read, starting at 0.- Returns:
- The value of the axis.
-
setRumble
Set the rumble output for the HID. The DS currently supports 2 rumble values, left rumble and right rumble.- Parameters:
type
- Which rumble value to setvalue
- The normalized value (0 to 1) to set the rumble to
-
isConnected
Get if the HID is connected.- Returns:
- true if the HID is connected
-