Class CommandGenericHID
java.lang.Object
org.wpilib.command3.button.CommandGenericHID
A version of
GenericHID with Trigger factories for command-based.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCommandGenericHID(int port) Construct an instance of a device.CommandGenericHID(Scheduler scheduler, int port) Construct an instance of a device.CommandGenericHID(Scheduler scheduler, GenericHID hid) Construct an instance of a device with a GenericHID object.Construct an instance of a device with a GenericHID object. -
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.static CommandGenericHIDgetCommandGenericHID(int port) Gets the CommandGenericHID object for the given port using the default scheduler.static CommandGenericHIDgetCommandGenericHID(Scheduler scheduler, int port) Gets the CommandGenericHID object for the given scheduler and port.getHID()Get the underlying GenericHID object.doublegetRawAxis(int axis) Get the value of the axis.booleanGet if the HID is connected.pov(int pov, POVDirection angle, EventLoop loop) Constructs a Trigger instance based around this angle of a POV on the HID.pov(POVDirection 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 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.voidsetRumble(GenericHID.RumbleType type, double value) Set the rumble output for the HID.
-
Constructor Details
-
CommandGenericHID
Construct an instance of a device.- Parameters:
scheduler- The scheduler that should execute the triggered commands.port- The port index on the Driver Station that the device is plugged into.
-
CommandGenericHID
Construct an instance of a device with a GenericHID object.- Parameters:
scheduler- The scheduler that should execute the triggered commands.hid- The GenericHID object to use for this command HID.
-
CommandGenericHID
Construct an instance of a device with a GenericHID object.- Parameters:
hid- The GenericHID object to use for this command HID.
-
CommandGenericHID
public CommandGenericHID(int port) Construct an instance of a device.- Parameters:
port- The port index on the Driver Station that the device is plugged into.
-
-
Method Details
-
getCommandGenericHID
Gets the CommandGenericHID object for the given scheduler and port. CommandGenericHID objects are cached, so this will always return the same object for the same scheduler and port.- Parameters:
scheduler- The scheduler that should execute the triggered commands.port- The port index on the Driver Station that the device is plugged into.- Returns:
- The CommandGenericHID object for the given scheduler and port.
-
getCommandGenericHID
Gets the CommandGenericHID object for the given port using the default scheduler. CommandGenericHID objects are cached, so this will always return the same object for the same port.- Parameters:
port- The port index on the Driver Station that the device is plugged into.- Returns:
- The CommandGenericHID object for the given port.
-
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.- Parameters:
angle- POV angle- 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.- Parameters:
pov- index of the POV to read (starting at 0). Defaults to 0.angle- POV angleloop- 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
public double getRawAxis(int axis) 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
public boolean isConnected()Get if the HID is connected.- Returns:
- true if the HID is connected
-