Files
allwpilib/wpilibj/src/main/java/org/wpilib/driverstation/Gamepad.java

1607 lines
48 KiB
Java
Raw Normal View History

// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
2025-11-07 19:55:43 -05:00
package org.wpilib.driverstation;
import java.util.EnumSet;
import java.util.Objects;
import org.wpilib.driverstation.GenericHID.HIDType;
import org.wpilib.driverstation.GenericHID.RumbleType;
import org.wpilib.driverstation.GenericHID.SupportedOutput;
import org.wpilib.driverstation.internal.DriverStationBackend;
2025-11-07 19:57:21 -05:00
import org.wpilib.event.BooleanEvent;
import org.wpilib.event.EventLoop;
2025-11-07 19:55:43 -05:00
import org.wpilib.hardware.hal.HAL;
import org.wpilib.math.util.MathUtil;
2025-11-07 19:55:43 -05:00
import org.wpilib.util.sendable.Sendable;
import org.wpilib.util.sendable.SendableBuilder;
/**
* Handle input from Gamepad controllers connected to the Driver Station.
*
* <p>This class handles Gamepad input that comes from the Driver Station. Each time a value is
* requested the most recent value is returned. There is a single class instance for each controller
* and the mapping of ports to hardware buttons depends on the code in the Driver Station.
*/
public class Gamepad implements HIDDevice, Sendable {
private static final double MAX_DEADBAND = Math.nextDown(1.0);
/** Represents a digital button on a Gamepad. */
public enum Button {
/** Face Down button. */
FACE_DOWN(0, "FaceDownButton"),
/** Face Right button. */
FACE_RIGHT(1, "FaceRightButton"),
/** Face Left button. */
FACE_LEFT(2, "FaceLeftButton"),
/** Face Up button. */
FACE_UP(3, "FaceUpButton"),
/** Back button. */
BACK(4, "BackButton"),
/** Guide button. */
GUIDE(5, "GuideButton"),
/** Start button. */
START(6, "StartButton"),
/** Left stick button. */
LEFT_STICK(7, "LeftStickButton"),
/** Right stick button. */
RIGHT_STICK(8, "RightStickButton"),
/** Left bumper button. */
LEFT_BUMPER(9, "LeftBumperButton"),
/** Right bumper button. */
RIGHT_BUMPER(10, "RightBumperButton"),
/** D-pad up button. */
DPAD_UP(11, "DpadUpButton"),
/** D-pad down button. */
DPAD_DOWN(12, "DpadDownButton"),
/** D-pad left button. */
DPAD_LEFT(13, "DpadLeftButton"),
/** D-pad right button. */
DPAD_RIGHT(14, "DpadRightButton"),
/** Miscellaneous 1 button. */
MISC_1(15, "Misc1Button"),
/** Right Paddle 1 button. */
RIGHT_PADDLE_1(16, "RightPaddle1Button"),
/** Left Paddle 1 button. */
LEFT_PADDLE_1(17, "LeftPaddle1Button"),
/** Right Paddle 2 button. */
RIGHT_PADDLE_2(18, "RightPaddle2Button"),
/** Left Paddle 2 button. */
LEFT_PADDLE_2(19, "LeftPaddle2Button"),
/** Touchpad button. */
TOUCHPAD(20, "TouchpadButton"),
/** Miscellaneous 2 button. */
MISC_2(21, "Misc2Button"),
/** Miscellaneous 3 button. */
MISC_3(22, "Misc3Button"),
/** Miscellaneous 4 button. */
MISC_4(23, "Misc4Button"),
/** Miscellaneous 5 button. */
MISC_5(24, "Misc5Button"),
/** Miscellaneous 6 button. */
MISC_6(25, "Misc6Button");
/** Button value. */
public final int value;
private final String m_name;
Button(int value, String name) {
this.value = value;
this.m_name = name;
}
/**
* Get the human-friendly name of the button, matching the relevant methods.
*
* <p>Primarily used for automated unit tests.
*
* @return the human-friendly name of the button.
*/
@Override
public String toString() {
return m_name;
}
}
/** Represents an axis on an Gamepad. */
public enum Axis {
/** Left X axis. */
LEFT_X(0, "LeftX"),
/** Left Y axis. */
LEFT_Y(1, "LeftY"),
/** Right X axis. */
RIGHT_X(2, "RightX"),
/** Right Y axis. */
RIGHT_Y(3, "RightY"),
/** Left trigger. */
LEFT_TRIGGER(4, "LeftTriggerAxis"),
/** Right trigger. */
RIGHT_TRIGGER(5, "RightTriggerAxis");
/** Axis value. */
public final int value;
private final String m_name;
Axis(int value, String name) {
this.value = value;
this.m_name = name;
}
/**
* Get the human-friendly name of the axis, matching the relevant methods.
*
* <p>Primarily used for automated unit tests.
*
* @return the human-friendly name of the axis.
*/
@Override
public String toString() {
return m_name;
}
}
private double m_leftXDeadband = 0.1;
private double m_leftYDeadband = 0.1;
private double m_rightXDeadband = 0.1;
private double m_rightYDeadband = 0.1;
private double m_leftTriggerDeadband = 0.01;
private double m_rightTriggerDeadband = 0.01;
private static double clampDeadband(double deadband) {
if (Double.isNaN(deadband)) {
return 0.0;
}
return Math.clamp(deadband, 0.0, MAX_DEADBAND);
}
private final GenericHID m_hid;
/**
* Get the underlying GenericHID object.
*
* @return the wrapped GenericHID object
*/
@Override
public GenericHID getHID() {
return m_hid;
}
/**
* Construct an instance of a gamepad.
*
* @param port The port index on the Driver Station that the gamepad is plugged into (0-5).
*/
public Gamepad(final int port) {
this(DriverStation.getGenericHID(port));
}
/**
* Construct an instance of a gamepad with a GenericHID object.
*
* @param hid The GenericHID object to use for this gamepad.
*/
public Gamepad(final GenericHID hid) {
m_hid = Objects.requireNonNull(hid, "Provided HID object cannot be null");
HAL.reportUsage("HID", hid.getPort(), "Gamepad");
}
/**
* Set the deadband for the left X axis.
*
* <p>The deadband is clamped to [0, 1).
*
* @param deadband The deadband to apply.
*/
public void setLeftXDeadband(double deadband) {
m_leftXDeadband = clampDeadband(deadband);
}
/**
* Set the deadband for the left Y axis.
*
* <p>The deadband is clamped to [0, 1).
*
* @param deadband The deadband to apply.
*/
public void setLeftYDeadband(double deadband) {
m_leftYDeadband = clampDeadband(deadband);
}
/**
* Set the deadband for the right X axis.
*
* <p>The deadband is clamped to [0, 1).
*
* @param deadband The deadband to apply.
*/
public void setRightXDeadband(double deadband) {
m_rightXDeadband = clampDeadband(deadband);
}
/**
* Set the deadband for the right Y axis.
*
* <p>The deadband is clamped to [0, 1).
*
* @param deadband The deadband to apply.
*/
public void setRightYDeadband(double deadband) {
m_rightYDeadband = clampDeadband(deadband);
}
/**
* Set the deadband for the left trigger axis.
*
* <p>The deadband is clamped to [0, 1).
*
* @param deadband The deadband to apply.
*/
public void setLeftTriggerDeadband(double deadband) {
m_leftTriggerDeadband = clampDeadband(deadband);
}
/**
* Set the deadband for the right trigger axis.
*
* <p>The deadband is clamped to [0, 1).
*
* @param deadband The deadband to apply.
*/
public void setRightTriggerDeadband(double deadband) {
m_rightTriggerDeadband = clampDeadband(deadband);
}
/**
* Get the X axis value of left side of the controller. Right is positive.
*
* <p>A deadband of 0.1 is applied by default. Use {@link #setLeftXDeadband} to change it.
*
* @return The axis value.
*/
public double getLeftX() {
return MathUtil.applyDeadband(getAxis(Axis.LEFT_X), m_leftXDeadband);
}
/**
* Get the Y axis value of left side of the controller. Back is positive.
*
* <p>A deadband of 0.1 is applied by default. Use {@link #setLeftYDeadband} to change it.
*
* @return The axis value.
*/
public double getLeftY() {
return MathUtil.applyDeadband(getAxis(Axis.LEFT_Y), m_leftYDeadband);
}
/**
* Get the X axis value of right side of the controller. Right is positive.
*
* <p>A deadband of 0.1 is applied by default. Use {@link #setRightXDeadband} to change it.
*
* @return The axis value.
*/
public double getRightX() {
return MathUtil.applyDeadband(getAxis(Axis.RIGHT_X), m_rightXDeadband);
}
/**
* Get the Y axis value of right side of the controller. Back is positive.
*
* <p>A deadband of 0.1 is applied by default. Use {@link #setRightYDeadband} to change it.
*
* @return The axis value.
*/
public double getRightY() {
return MathUtil.applyDeadband(getAxis(Axis.RIGHT_Y), m_rightYDeadband);
}
/**
* 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].
*
* <p>A deadband of 0.01 is applied by default. Use {@link #setLeftTriggerDeadband} to change it.
*
* @return The axis value.
*/
public double getLeftTriggerAxis() {
return MathUtil.applyDeadband(getAxis(Axis.LEFT_TRIGGER), m_leftTriggerDeadband);
}
/**
* Constructs an event instance around the axis value of the left trigger. The returned trigger
* will be true when the axis value is greater than {@code threshold}.
*
* @param threshold the minimum axis value for the returned {@link BooleanEvent} to be true. This
* value should be in the range [0, 1] where 0 is the unpressed state of the axis.
* @param loop the event loop instance to attach the event to.
* @return an event instance that is true when the left trigger's axis exceeds the provided
* threshold, attached to the given event loop
*/
public BooleanEvent leftTrigger(double threshold, EventLoop loop) {
return axisGreaterThan(Axis.LEFT_TRIGGER, threshold, loop);
}
/**
* Constructs an event instance around the axis value of the left trigger. The returned trigger
* will be true when the axis value is greater than 0.5.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance that is true when the left trigger's axis exceeds the provided
* threshold, attached to the given event loop
*/
public BooleanEvent leftTrigger(EventLoop loop) {
return leftTrigger(0.5, loop);
}
/**
* 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].
*
* <p>A deadband of 0.01 is applied by default. Use {@link #setRightTriggerDeadband} to change it.
*
* @return The axis value.
*/
public double getRightTriggerAxis() {
return MathUtil.applyDeadband(getAxis(Axis.RIGHT_TRIGGER), m_rightTriggerDeadband);
}
/**
* Constructs an event instance around the axis value of the right trigger. The returned trigger
* will be true when the axis value is greater than {@code threshold}.
*
* @param threshold the minimum axis value for the returned {@link BooleanEvent} to be true. This
* value should be in the range [0, 1] where 0 is the unpressed state of the axis.
* @param loop the event loop instance to attach the event to.
* @return an event instance that is true when the right trigger's axis exceeds the provided
* threshold, attached to the given event loop
*/
public BooleanEvent rightTrigger(double threshold, EventLoop loop) {
return axisGreaterThan(Axis.RIGHT_TRIGGER, threshold, loop);
}
/**
* Constructs an event instance around the axis value of the right trigger. The returned trigger
* will be true when the axis value is greater than 0.5.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance that is true when the right trigger's axis exceeds the provided
* threshold, attached to the given event loop
*/
public BooleanEvent rightTrigger(EventLoop loop) {
return rightTrigger(0.5, loop);
}
/**
* Read the value of the Face Down button on the controller.
*
* @return The state of the button.
*/
public boolean getFaceDownButton() {
return getButton(Button.FACE_DOWN);
}
/**
* Whether the Face Down button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getFaceDownButtonPressed() {
return getButtonPressed(Button.FACE_DOWN);
}
/**
* Whether the Face Down button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getFaceDownButtonReleased() {
return getButtonReleased(Button.FACE_DOWN);
}
/**
[wpilib,cmd] Rename gamepad face-button trigger APIs to directional names (faceUp/Down/Left/Right) (#8896) This updates gamepad trigger naming from cardinal-style face buttons (`northFace/southFace/eastFace/westFace` and `NorthFace/SouthFace/EastFace/WestFace`) to directional naming (`faceUp/faceDown/faceRight/faceLeft` and `FaceUp/FaceDown/FaceRight/FaceLeft`) to match the requested API shape. The change is applied across Java and C++ HID/command layers, along with related examples and binding metadata. - **API surface updates (Java)** - Renamed trigger/event methods in: - `wpilibj` `Gamepad` - `commandsv2` `CommandGamepad` - `commandsv3` `CommandGamepad` - Mapping preserved: - `southFace` → `faceDown` - `eastFace` → `faceRight` - `westFace` → `faceLeft` - `northFace` → `faceUp` - **API surface updates (C++)** - Renamed trigger/event methods in: - `wpilibc` `Gamepad` - `commandsv2` `CommandGamepad` - Mapping preserved: - `SouthFace` → `FaceDown` - `EastFace` → `FaceRight` - `WestFace` → `FaceLeft` - `NorthFace` → `FaceUp` - **Python semiwrap updates** - Updated `wpilibc/src/main/python/semiwrap/Gamepad.yml` method mappings to the renamed C++ method names (`FaceDown/FaceRight/FaceLeft/FaceUp`). - **Callsite migration** - Updated Java examples/template code and C++ examples/template code to use the new method names so samples remain aligned with the API rename. - **Docs/comments alignment** - Updated related Javadoc/reference text and example comments to use directional terminology. ```java // Before driverController.southFace().onTrue(command); driverController.eastFace().onTrue(command); // After driverController.faceDown().onTrue(command); driverController.faceRight().onTrue(command); ``` ```cpp // Before driverController.SouthFace().OnTrue(command); driverController.EastFace().OnTrue(command); // After driverController.FaceDown().OnTrue(command); driverController.FaceRight().OnTrue(command); ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ThadHouse <7727148+ThadHouse@users.noreply.github.com>
2026-05-14 22:08:57 -07:00
* Constructs an event instance around the Face Down button's digital signal.
*
* @param loop the event loop instance to attach the event to.
[wpilib,cmd] Rename gamepad face-button trigger APIs to directional names (faceUp/Down/Left/Right) (#8896) This updates gamepad trigger naming from cardinal-style face buttons (`northFace/southFace/eastFace/westFace` and `NorthFace/SouthFace/EastFace/WestFace`) to directional naming (`faceUp/faceDown/faceRight/faceLeft` and `FaceUp/FaceDown/FaceRight/FaceLeft`) to match the requested API shape. The change is applied across Java and C++ HID/command layers, along with related examples and binding metadata. - **API surface updates (Java)** - Renamed trigger/event methods in: - `wpilibj` `Gamepad` - `commandsv2` `CommandGamepad` - `commandsv3` `CommandGamepad` - Mapping preserved: - `southFace` → `faceDown` - `eastFace` → `faceRight` - `westFace` → `faceLeft` - `northFace` → `faceUp` - **API surface updates (C++)** - Renamed trigger/event methods in: - `wpilibc` `Gamepad` - `commandsv2` `CommandGamepad` - Mapping preserved: - `SouthFace` → `FaceDown` - `EastFace` → `FaceRight` - `WestFace` → `FaceLeft` - `NorthFace` → `FaceUp` - **Python semiwrap updates** - Updated `wpilibc/src/main/python/semiwrap/Gamepad.yml` method mappings to the renamed C++ method names (`FaceDown/FaceRight/FaceLeft/FaceUp`). - **Callsite migration** - Updated Java examples/template code and C++ examples/template code to use the new method names so samples remain aligned with the API rename. - **Docs/comments alignment** - Updated related Javadoc/reference text and example comments to use directional terminology. ```java // Before driverController.southFace().onTrue(command); driverController.eastFace().onTrue(command); // After driverController.faceDown().onTrue(command); driverController.faceRight().onTrue(command); ``` ```cpp // Before driverController.SouthFace().OnTrue(command); driverController.EastFace().OnTrue(command); // After driverController.FaceDown().OnTrue(command); driverController.FaceRight().OnTrue(command); ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ThadHouse <7727148+ThadHouse@users.noreply.github.com>
2026-05-14 22:08:57 -07:00
* @return an event instance representing the Face Down button's digital signal attached to the
* given loop.
*/
[wpilib,cmd] Rename gamepad face-button trigger APIs to directional names (faceUp/Down/Left/Right) (#8896) This updates gamepad trigger naming from cardinal-style face buttons (`northFace/southFace/eastFace/westFace` and `NorthFace/SouthFace/EastFace/WestFace`) to directional naming (`faceUp/faceDown/faceRight/faceLeft` and `FaceUp/FaceDown/FaceRight/FaceLeft`) to match the requested API shape. The change is applied across Java and C++ HID/command layers, along with related examples and binding metadata. - **API surface updates (Java)** - Renamed trigger/event methods in: - `wpilibj` `Gamepad` - `commandsv2` `CommandGamepad` - `commandsv3` `CommandGamepad` - Mapping preserved: - `southFace` → `faceDown` - `eastFace` → `faceRight` - `westFace` → `faceLeft` - `northFace` → `faceUp` - **API surface updates (C++)** - Renamed trigger/event methods in: - `wpilibc` `Gamepad` - `commandsv2` `CommandGamepad` - Mapping preserved: - `SouthFace` → `FaceDown` - `EastFace` → `FaceRight` - `WestFace` → `FaceLeft` - `NorthFace` → `FaceUp` - **Python semiwrap updates** - Updated `wpilibc/src/main/python/semiwrap/Gamepad.yml` method mappings to the renamed C++ method names (`FaceDown/FaceRight/FaceLeft/FaceUp`). - **Callsite migration** - Updated Java examples/template code and C++ examples/template code to use the new method names so samples remain aligned with the API rename. - **Docs/comments alignment** - Updated related Javadoc/reference text and example comments to use directional terminology. ```java // Before driverController.southFace().onTrue(command); driverController.eastFace().onTrue(command); // After driverController.faceDown().onTrue(command); driverController.faceRight().onTrue(command); ``` ```cpp // Before driverController.SouthFace().OnTrue(command); driverController.EastFace().OnTrue(command); // After driverController.FaceDown().OnTrue(command); driverController.FaceRight().OnTrue(command); ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ThadHouse <7727148+ThadHouse@users.noreply.github.com>
2026-05-14 22:08:57 -07:00
public BooleanEvent faceDown(EventLoop loop) {
return button(Button.FACE_DOWN, loop);
}
/**
* Read the value of the Face Right button on the controller.
*
* @return The state of the button.
*/
public boolean getFaceRightButton() {
return getButton(Button.FACE_RIGHT);
}
/**
* Whether the Face Right button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getFaceRightButtonPressed() {
return getButtonPressed(Button.FACE_RIGHT);
}
/**
* Whether the Face Right button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getFaceRightButtonReleased() {
return getButtonReleased(Button.FACE_RIGHT);
}
/**
[wpilib,cmd] Rename gamepad face-button trigger APIs to directional names (faceUp/Down/Left/Right) (#8896) This updates gamepad trigger naming from cardinal-style face buttons (`northFace/southFace/eastFace/westFace` and `NorthFace/SouthFace/EastFace/WestFace`) to directional naming (`faceUp/faceDown/faceRight/faceLeft` and `FaceUp/FaceDown/FaceRight/FaceLeft`) to match the requested API shape. The change is applied across Java and C++ HID/command layers, along with related examples and binding metadata. - **API surface updates (Java)** - Renamed trigger/event methods in: - `wpilibj` `Gamepad` - `commandsv2` `CommandGamepad` - `commandsv3` `CommandGamepad` - Mapping preserved: - `southFace` → `faceDown` - `eastFace` → `faceRight` - `westFace` → `faceLeft` - `northFace` → `faceUp` - **API surface updates (C++)** - Renamed trigger/event methods in: - `wpilibc` `Gamepad` - `commandsv2` `CommandGamepad` - Mapping preserved: - `SouthFace` → `FaceDown` - `EastFace` → `FaceRight` - `WestFace` → `FaceLeft` - `NorthFace` → `FaceUp` - **Python semiwrap updates** - Updated `wpilibc/src/main/python/semiwrap/Gamepad.yml` method mappings to the renamed C++ method names (`FaceDown/FaceRight/FaceLeft/FaceUp`). - **Callsite migration** - Updated Java examples/template code and C++ examples/template code to use the new method names so samples remain aligned with the API rename. - **Docs/comments alignment** - Updated related Javadoc/reference text and example comments to use directional terminology. ```java // Before driverController.southFace().onTrue(command); driverController.eastFace().onTrue(command); // After driverController.faceDown().onTrue(command); driverController.faceRight().onTrue(command); ``` ```cpp // Before driverController.SouthFace().OnTrue(command); driverController.EastFace().OnTrue(command); // After driverController.FaceDown().OnTrue(command); driverController.FaceRight().OnTrue(command); ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ThadHouse <7727148+ThadHouse@users.noreply.github.com>
2026-05-14 22:08:57 -07:00
* Constructs an event instance around the Face Right button's digital signal.
*
* @param loop the event loop instance to attach the event to.
[wpilib,cmd] Rename gamepad face-button trigger APIs to directional names (faceUp/Down/Left/Right) (#8896) This updates gamepad trigger naming from cardinal-style face buttons (`northFace/southFace/eastFace/westFace` and `NorthFace/SouthFace/EastFace/WestFace`) to directional naming (`faceUp/faceDown/faceRight/faceLeft` and `FaceUp/FaceDown/FaceRight/FaceLeft`) to match the requested API shape. The change is applied across Java and C++ HID/command layers, along with related examples and binding metadata. - **API surface updates (Java)** - Renamed trigger/event methods in: - `wpilibj` `Gamepad` - `commandsv2` `CommandGamepad` - `commandsv3` `CommandGamepad` - Mapping preserved: - `southFace` → `faceDown` - `eastFace` → `faceRight` - `westFace` → `faceLeft` - `northFace` → `faceUp` - **API surface updates (C++)** - Renamed trigger/event methods in: - `wpilibc` `Gamepad` - `commandsv2` `CommandGamepad` - Mapping preserved: - `SouthFace` → `FaceDown` - `EastFace` → `FaceRight` - `WestFace` → `FaceLeft` - `NorthFace` → `FaceUp` - **Python semiwrap updates** - Updated `wpilibc/src/main/python/semiwrap/Gamepad.yml` method mappings to the renamed C++ method names (`FaceDown/FaceRight/FaceLeft/FaceUp`). - **Callsite migration** - Updated Java examples/template code and C++ examples/template code to use the new method names so samples remain aligned with the API rename. - **Docs/comments alignment** - Updated related Javadoc/reference text and example comments to use directional terminology. ```java // Before driverController.southFace().onTrue(command); driverController.eastFace().onTrue(command); // After driverController.faceDown().onTrue(command); driverController.faceRight().onTrue(command); ``` ```cpp // Before driverController.SouthFace().OnTrue(command); driverController.EastFace().OnTrue(command); // After driverController.FaceDown().OnTrue(command); driverController.FaceRight().OnTrue(command); ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ThadHouse <7727148+ThadHouse@users.noreply.github.com>
2026-05-14 22:08:57 -07:00
* @return an event instance representing the Face Right button's digital signal attached to the
* given loop.
*/
[wpilib,cmd] Rename gamepad face-button trigger APIs to directional names (faceUp/Down/Left/Right) (#8896) This updates gamepad trigger naming from cardinal-style face buttons (`northFace/southFace/eastFace/westFace` and `NorthFace/SouthFace/EastFace/WestFace`) to directional naming (`faceUp/faceDown/faceRight/faceLeft` and `FaceUp/FaceDown/FaceRight/FaceLeft`) to match the requested API shape. The change is applied across Java and C++ HID/command layers, along with related examples and binding metadata. - **API surface updates (Java)** - Renamed trigger/event methods in: - `wpilibj` `Gamepad` - `commandsv2` `CommandGamepad` - `commandsv3` `CommandGamepad` - Mapping preserved: - `southFace` → `faceDown` - `eastFace` → `faceRight` - `westFace` → `faceLeft` - `northFace` → `faceUp` - **API surface updates (C++)** - Renamed trigger/event methods in: - `wpilibc` `Gamepad` - `commandsv2` `CommandGamepad` - Mapping preserved: - `SouthFace` → `FaceDown` - `EastFace` → `FaceRight` - `WestFace` → `FaceLeft` - `NorthFace` → `FaceUp` - **Python semiwrap updates** - Updated `wpilibc/src/main/python/semiwrap/Gamepad.yml` method mappings to the renamed C++ method names (`FaceDown/FaceRight/FaceLeft/FaceUp`). - **Callsite migration** - Updated Java examples/template code and C++ examples/template code to use the new method names so samples remain aligned with the API rename. - **Docs/comments alignment** - Updated related Javadoc/reference text and example comments to use directional terminology. ```java // Before driverController.southFace().onTrue(command); driverController.eastFace().onTrue(command); // After driverController.faceDown().onTrue(command); driverController.faceRight().onTrue(command); ``` ```cpp // Before driverController.SouthFace().OnTrue(command); driverController.EastFace().OnTrue(command); // After driverController.FaceDown().OnTrue(command); driverController.FaceRight().OnTrue(command); ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ThadHouse <7727148+ThadHouse@users.noreply.github.com>
2026-05-14 22:08:57 -07:00
public BooleanEvent faceRight(EventLoop loop) {
return button(Button.FACE_RIGHT, loop);
}
/**
* Read the value of the Face Left button on the controller.
*
* @return The state of the button.
*/
public boolean getFaceLeftButton() {
return getButton(Button.FACE_LEFT);
}
/**
* Whether the Face Left button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getFaceLeftButtonPressed() {
return getButtonPressed(Button.FACE_LEFT);
}
/**
* Whether the Face Left button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getFaceLeftButtonReleased() {
return getButtonReleased(Button.FACE_LEFT);
}
/**
[wpilib,cmd] Rename gamepad face-button trigger APIs to directional names (faceUp/Down/Left/Right) (#8896) This updates gamepad trigger naming from cardinal-style face buttons (`northFace/southFace/eastFace/westFace` and `NorthFace/SouthFace/EastFace/WestFace`) to directional naming (`faceUp/faceDown/faceRight/faceLeft` and `FaceUp/FaceDown/FaceRight/FaceLeft`) to match the requested API shape. The change is applied across Java and C++ HID/command layers, along with related examples and binding metadata. - **API surface updates (Java)** - Renamed trigger/event methods in: - `wpilibj` `Gamepad` - `commandsv2` `CommandGamepad` - `commandsv3` `CommandGamepad` - Mapping preserved: - `southFace` → `faceDown` - `eastFace` → `faceRight` - `westFace` → `faceLeft` - `northFace` → `faceUp` - **API surface updates (C++)** - Renamed trigger/event methods in: - `wpilibc` `Gamepad` - `commandsv2` `CommandGamepad` - Mapping preserved: - `SouthFace` → `FaceDown` - `EastFace` → `FaceRight` - `WestFace` → `FaceLeft` - `NorthFace` → `FaceUp` - **Python semiwrap updates** - Updated `wpilibc/src/main/python/semiwrap/Gamepad.yml` method mappings to the renamed C++ method names (`FaceDown/FaceRight/FaceLeft/FaceUp`). - **Callsite migration** - Updated Java examples/template code and C++ examples/template code to use the new method names so samples remain aligned with the API rename. - **Docs/comments alignment** - Updated related Javadoc/reference text and example comments to use directional terminology. ```java // Before driverController.southFace().onTrue(command); driverController.eastFace().onTrue(command); // After driverController.faceDown().onTrue(command); driverController.faceRight().onTrue(command); ``` ```cpp // Before driverController.SouthFace().OnTrue(command); driverController.EastFace().OnTrue(command); // After driverController.FaceDown().OnTrue(command); driverController.FaceRight().OnTrue(command); ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ThadHouse <7727148+ThadHouse@users.noreply.github.com>
2026-05-14 22:08:57 -07:00
* Constructs an event instance around the Face Left button's digital signal.
*
* @param loop the event loop instance to attach the event to.
[wpilib,cmd] Rename gamepad face-button trigger APIs to directional names (faceUp/Down/Left/Right) (#8896) This updates gamepad trigger naming from cardinal-style face buttons (`northFace/southFace/eastFace/westFace` and `NorthFace/SouthFace/EastFace/WestFace`) to directional naming (`faceUp/faceDown/faceRight/faceLeft` and `FaceUp/FaceDown/FaceRight/FaceLeft`) to match the requested API shape. The change is applied across Java and C++ HID/command layers, along with related examples and binding metadata. - **API surface updates (Java)** - Renamed trigger/event methods in: - `wpilibj` `Gamepad` - `commandsv2` `CommandGamepad` - `commandsv3` `CommandGamepad` - Mapping preserved: - `southFace` → `faceDown` - `eastFace` → `faceRight` - `westFace` → `faceLeft` - `northFace` → `faceUp` - **API surface updates (C++)** - Renamed trigger/event methods in: - `wpilibc` `Gamepad` - `commandsv2` `CommandGamepad` - Mapping preserved: - `SouthFace` → `FaceDown` - `EastFace` → `FaceRight` - `WestFace` → `FaceLeft` - `NorthFace` → `FaceUp` - **Python semiwrap updates** - Updated `wpilibc/src/main/python/semiwrap/Gamepad.yml` method mappings to the renamed C++ method names (`FaceDown/FaceRight/FaceLeft/FaceUp`). - **Callsite migration** - Updated Java examples/template code and C++ examples/template code to use the new method names so samples remain aligned with the API rename. - **Docs/comments alignment** - Updated related Javadoc/reference text and example comments to use directional terminology. ```java // Before driverController.southFace().onTrue(command); driverController.eastFace().onTrue(command); // After driverController.faceDown().onTrue(command); driverController.faceRight().onTrue(command); ``` ```cpp // Before driverController.SouthFace().OnTrue(command); driverController.EastFace().OnTrue(command); // After driverController.FaceDown().OnTrue(command); driverController.FaceRight().OnTrue(command); ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ThadHouse <7727148+ThadHouse@users.noreply.github.com>
2026-05-14 22:08:57 -07:00
* @return an event instance representing the Face Left button's digital signal attached to the
* given loop.
*/
[wpilib,cmd] Rename gamepad face-button trigger APIs to directional names (faceUp/Down/Left/Right) (#8896) This updates gamepad trigger naming from cardinal-style face buttons (`northFace/southFace/eastFace/westFace` and `NorthFace/SouthFace/EastFace/WestFace`) to directional naming (`faceUp/faceDown/faceRight/faceLeft` and `FaceUp/FaceDown/FaceRight/FaceLeft`) to match the requested API shape. The change is applied across Java and C++ HID/command layers, along with related examples and binding metadata. - **API surface updates (Java)** - Renamed trigger/event methods in: - `wpilibj` `Gamepad` - `commandsv2` `CommandGamepad` - `commandsv3` `CommandGamepad` - Mapping preserved: - `southFace` → `faceDown` - `eastFace` → `faceRight` - `westFace` → `faceLeft` - `northFace` → `faceUp` - **API surface updates (C++)** - Renamed trigger/event methods in: - `wpilibc` `Gamepad` - `commandsv2` `CommandGamepad` - Mapping preserved: - `SouthFace` → `FaceDown` - `EastFace` → `FaceRight` - `WestFace` → `FaceLeft` - `NorthFace` → `FaceUp` - **Python semiwrap updates** - Updated `wpilibc/src/main/python/semiwrap/Gamepad.yml` method mappings to the renamed C++ method names (`FaceDown/FaceRight/FaceLeft/FaceUp`). - **Callsite migration** - Updated Java examples/template code and C++ examples/template code to use the new method names so samples remain aligned with the API rename. - **Docs/comments alignment** - Updated related Javadoc/reference text and example comments to use directional terminology. ```java // Before driverController.southFace().onTrue(command); driverController.eastFace().onTrue(command); // After driverController.faceDown().onTrue(command); driverController.faceRight().onTrue(command); ``` ```cpp // Before driverController.SouthFace().OnTrue(command); driverController.EastFace().OnTrue(command); // After driverController.FaceDown().OnTrue(command); driverController.FaceRight().OnTrue(command); ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ThadHouse <7727148+ThadHouse@users.noreply.github.com>
2026-05-14 22:08:57 -07:00
public BooleanEvent faceLeft(EventLoop loop) {
return button(Button.FACE_LEFT, loop);
}
/**
* Read the value of the Face Up button on the controller.
*
* @return The state of the button.
*/
public boolean getFaceUpButton() {
return getButton(Button.FACE_UP);
}
/**
* Whether the Face Up button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getFaceUpButtonPressed() {
return getButtonPressed(Button.FACE_UP);
}
/**
* Whether the Face Up button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getFaceUpButtonReleased() {
return getButtonReleased(Button.FACE_UP);
}
/**
[wpilib,cmd] Rename gamepad face-button trigger APIs to directional names (faceUp/Down/Left/Right) (#8896) This updates gamepad trigger naming from cardinal-style face buttons (`northFace/southFace/eastFace/westFace` and `NorthFace/SouthFace/EastFace/WestFace`) to directional naming (`faceUp/faceDown/faceRight/faceLeft` and `FaceUp/FaceDown/FaceRight/FaceLeft`) to match the requested API shape. The change is applied across Java and C++ HID/command layers, along with related examples and binding metadata. - **API surface updates (Java)** - Renamed trigger/event methods in: - `wpilibj` `Gamepad` - `commandsv2` `CommandGamepad` - `commandsv3` `CommandGamepad` - Mapping preserved: - `southFace` → `faceDown` - `eastFace` → `faceRight` - `westFace` → `faceLeft` - `northFace` → `faceUp` - **API surface updates (C++)** - Renamed trigger/event methods in: - `wpilibc` `Gamepad` - `commandsv2` `CommandGamepad` - Mapping preserved: - `SouthFace` → `FaceDown` - `EastFace` → `FaceRight` - `WestFace` → `FaceLeft` - `NorthFace` → `FaceUp` - **Python semiwrap updates** - Updated `wpilibc/src/main/python/semiwrap/Gamepad.yml` method mappings to the renamed C++ method names (`FaceDown/FaceRight/FaceLeft/FaceUp`). - **Callsite migration** - Updated Java examples/template code and C++ examples/template code to use the new method names so samples remain aligned with the API rename. - **Docs/comments alignment** - Updated related Javadoc/reference text and example comments to use directional terminology. ```java // Before driverController.southFace().onTrue(command); driverController.eastFace().onTrue(command); // After driverController.faceDown().onTrue(command); driverController.faceRight().onTrue(command); ``` ```cpp // Before driverController.SouthFace().OnTrue(command); driverController.EastFace().OnTrue(command); // After driverController.FaceDown().OnTrue(command); driverController.FaceRight().OnTrue(command); ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ThadHouse <7727148+ThadHouse@users.noreply.github.com>
2026-05-14 22:08:57 -07:00
* Constructs an event instance around the Face Up button's digital signal.
*
* @param loop the event loop instance to attach the event to.
[wpilib,cmd] Rename gamepad face-button trigger APIs to directional names (faceUp/Down/Left/Right) (#8896) This updates gamepad trigger naming from cardinal-style face buttons (`northFace/southFace/eastFace/westFace` and `NorthFace/SouthFace/EastFace/WestFace`) to directional naming (`faceUp/faceDown/faceRight/faceLeft` and `FaceUp/FaceDown/FaceRight/FaceLeft`) to match the requested API shape. The change is applied across Java and C++ HID/command layers, along with related examples and binding metadata. - **API surface updates (Java)** - Renamed trigger/event methods in: - `wpilibj` `Gamepad` - `commandsv2` `CommandGamepad` - `commandsv3` `CommandGamepad` - Mapping preserved: - `southFace` → `faceDown` - `eastFace` → `faceRight` - `westFace` → `faceLeft` - `northFace` → `faceUp` - **API surface updates (C++)** - Renamed trigger/event methods in: - `wpilibc` `Gamepad` - `commandsv2` `CommandGamepad` - Mapping preserved: - `SouthFace` → `FaceDown` - `EastFace` → `FaceRight` - `WestFace` → `FaceLeft` - `NorthFace` → `FaceUp` - **Python semiwrap updates** - Updated `wpilibc/src/main/python/semiwrap/Gamepad.yml` method mappings to the renamed C++ method names (`FaceDown/FaceRight/FaceLeft/FaceUp`). - **Callsite migration** - Updated Java examples/template code and C++ examples/template code to use the new method names so samples remain aligned with the API rename. - **Docs/comments alignment** - Updated related Javadoc/reference text and example comments to use directional terminology. ```java // Before driverController.southFace().onTrue(command); driverController.eastFace().onTrue(command); // After driverController.faceDown().onTrue(command); driverController.faceRight().onTrue(command); ``` ```cpp // Before driverController.SouthFace().OnTrue(command); driverController.EastFace().OnTrue(command); // After driverController.FaceDown().OnTrue(command); driverController.FaceRight().OnTrue(command); ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ThadHouse <7727148+ThadHouse@users.noreply.github.com>
2026-05-14 22:08:57 -07:00
* @return an event instance representing the Face Up button's digital signal attached to the
* given loop.
*/
[wpilib,cmd] Rename gamepad face-button trigger APIs to directional names (faceUp/Down/Left/Right) (#8896) This updates gamepad trigger naming from cardinal-style face buttons (`northFace/southFace/eastFace/westFace` and `NorthFace/SouthFace/EastFace/WestFace`) to directional naming (`faceUp/faceDown/faceRight/faceLeft` and `FaceUp/FaceDown/FaceRight/FaceLeft`) to match the requested API shape. The change is applied across Java and C++ HID/command layers, along with related examples and binding metadata. - **API surface updates (Java)** - Renamed trigger/event methods in: - `wpilibj` `Gamepad` - `commandsv2` `CommandGamepad` - `commandsv3` `CommandGamepad` - Mapping preserved: - `southFace` → `faceDown` - `eastFace` → `faceRight` - `westFace` → `faceLeft` - `northFace` → `faceUp` - **API surface updates (C++)** - Renamed trigger/event methods in: - `wpilibc` `Gamepad` - `commandsv2` `CommandGamepad` - Mapping preserved: - `SouthFace` → `FaceDown` - `EastFace` → `FaceRight` - `WestFace` → `FaceLeft` - `NorthFace` → `FaceUp` - **Python semiwrap updates** - Updated `wpilibc/src/main/python/semiwrap/Gamepad.yml` method mappings to the renamed C++ method names (`FaceDown/FaceRight/FaceLeft/FaceUp`). - **Callsite migration** - Updated Java examples/template code and C++ examples/template code to use the new method names so samples remain aligned with the API rename. - **Docs/comments alignment** - Updated related Javadoc/reference text and example comments to use directional terminology. ```java // Before driverController.southFace().onTrue(command); driverController.eastFace().onTrue(command); // After driverController.faceDown().onTrue(command); driverController.faceRight().onTrue(command); ``` ```cpp // Before driverController.SouthFace().OnTrue(command); driverController.EastFace().OnTrue(command); // After driverController.FaceDown().OnTrue(command); driverController.FaceRight().OnTrue(command); ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ThadHouse <7727148+ThadHouse@users.noreply.github.com>
2026-05-14 22:08:57 -07:00
public BooleanEvent faceUp(EventLoop loop) {
return button(Button.FACE_UP, loop);
}
/**
* Read the value of the Back button on the controller.
*
* @return The state of the button.
*/
public boolean getBackButton() {
return getButton(Button.BACK);
}
/**
* Whether the Back button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getBackButtonPressed() {
return getButtonPressed(Button.BACK);
}
/**
* Whether the Back button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getBackButtonReleased() {
return getButtonReleased(Button.BACK);
}
/**
* Constructs an event instance around the Back button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Back button's digital signal attached to the given
* loop.
*/
public BooleanEvent back(EventLoop loop) {
return button(Button.BACK, loop);
}
/**
* Read the value of the Guide button on the controller.
*
* @return The state of the button.
*/
public boolean getGuideButton() {
return getButton(Button.GUIDE);
}
/**
* Whether the Guide button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getGuideButtonPressed() {
return getButtonPressed(Button.GUIDE);
}
/**
* Whether the Guide button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getGuideButtonReleased() {
return getButtonReleased(Button.GUIDE);
}
/**
* Constructs an event instance around the Guide button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Guide button's digital signal attached to the given
* loop.
*/
public BooleanEvent guide(EventLoop loop) {
return button(Button.GUIDE, loop);
}
/**
* Read the value of the Start button on the controller.
*
* @return The state of the button.
*/
public boolean getStartButton() {
return getButton(Button.START);
}
/**
* Whether the Start button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getStartButtonPressed() {
return getButtonPressed(Button.START);
}
/**
* Whether the Start button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getStartButtonReleased() {
return getButtonReleased(Button.START);
}
/**
* Constructs an event instance around the Start button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Start button's digital signal attached to the given
* loop.
*/
public BooleanEvent start(EventLoop loop) {
return button(Button.START, loop);
}
/**
* Read the value of the left stick button on the controller.
*
* @return The state of the button.
*/
public boolean getLeftStickButton() {
return getButton(Button.LEFT_STICK);
}
/**
* Whether the left stick button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getLeftStickButtonPressed() {
return getButtonPressed(Button.LEFT_STICK);
}
/**
* Whether the left stick button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getLeftStickButtonReleased() {
return getButtonReleased(Button.LEFT_STICK);
}
/**
* Constructs an event instance around the left stick button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left stick button's digital signal attached to the
* given loop.
*/
public BooleanEvent leftStick(EventLoop loop) {
return button(Button.LEFT_STICK, loop);
}
/**
* Read the value of the right stick button on the controller.
*
* @return The state of the button.
*/
public boolean getRightStickButton() {
return getButton(Button.RIGHT_STICK);
}
/**
* Whether the right stick button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getRightStickButtonPressed() {
return getButtonPressed(Button.RIGHT_STICK);
}
/**
* Whether the right stick button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getRightStickButtonReleased() {
return getButtonReleased(Button.RIGHT_STICK);
}
/**
* Constructs an event instance around the right stick button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right stick button's digital signal attached to the
* given loop.
*/
public BooleanEvent rightStick(EventLoop loop) {
return button(Button.RIGHT_STICK, loop);
}
/**
* Read the value of the right bumper button on the controller.
*
* @return The state of the button.
*/
public boolean getLeftBumperButton() {
return getButton(Button.LEFT_BUMPER);
}
/**
* Whether the right bumper button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getLeftBumperButtonPressed() {
return getButtonPressed(Button.LEFT_BUMPER);
}
/**
* Whether the right bumper button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getLeftBumperButtonReleased() {
return getButtonReleased(Button.LEFT_BUMPER);
}
/**
* Constructs an event instance around the right bumper button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right bumper button's digital signal attached to the
* given loop.
*/
public BooleanEvent leftBumper(EventLoop loop) {
return button(Button.LEFT_BUMPER, loop);
}
/**
* Read the value of the right bumper button on the controller.
*
* @return The state of the button.
*/
public boolean getRightBumperButton() {
return getButton(Button.RIGHT_BUMPER);
}
/**
* Whether the right bumper button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getRightBumperButtonPressed() {
return getButtonPressed(Button.RIGHT_BUMPER);
}
/**
* Whether the right bumper button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getRightBumperButtonReleased() {
return getButtonReleased(Button.RIGHT_BUMPER);
}
/**
* Constructs an event instance around the right bumper button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right bumper button's digital signal attached to the
* given loop.
*/
public BooleanEvent rightBumper(EventLoop loop) {
return button(Button.RIGHT_BUMPER, loop);
}
/**
* Read the value of the D-pad up button on the controller.
*
* @return The state of the button.
*/
public boolean getDpadUpButton() {
return getButton(Button.DPAD_UP);
}
/**
* Whether the D-pad up button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getDpadUpButtonPressed() {
return getButtonPressed(Button.DPAD_UP);
}
/**
* Whether the D-pad up button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getDpadUpButtonReleased() {
return getButtonReleased(Button.DPAD_UP);
}
/**
* Constructs an event instance around the D-pad up button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the D-pad up button's digital signal attached to the
* given loop.
*/
public BooleanEvent dpadUp(EventLoop loop) {
return button(Button.DPAD_UP, loop);
}
/**
* Read the value of the D-pad down button on the controller.
*
* @return The state of the button.
*/
public boolean getDpadDownButton() {
return getButton(Button.DPAD_DOWN);
}
/**
* Whether the D-pad down button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getDpadDownButtonPressed() {
return getButtonPressed(Button.DPAD_DOWN);
}
/**
* Whether the D-pad down button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getDpadDownButtonReleased() {
return getButtonReleased(Button.DPAD_DOWN);
}
/**
* Constructs an event instance around the D-pad down button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the D-pad down button's digital signal attached to the
* given loop.
*/
public BooleanEvent dpadDown(EventLoop loop) {
return button(Button.DPAD_DOWN, loop);
}
/**
* Read the value of the D-pad left button on the controller.
*
* @return The state of the button.
*/
public boolean getDpadLeftButton() {
return getButton(Button.DPAD_LEFT);
}
/**
* Whether the D-pad left button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getDpadLeftButtonPressed() {
return getButtonPressed(Button.DPAD_LEFT);
}
/**
* Whether the D-pad left button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getDpadLeftButtonReleased() {
return getButtonReleased(Button.DPAD_LEFT);
}
/**
* Constructs an event instance around the D-pad left button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the D-pad left button's digital signal attached to the
* given loop.
*/
public BooleanEvent dpadLeft(EventLoop loop) {
return button(Button.DPAD_LEFT, loop);
}
/**
* Read the value of the D-pad right button on the controller.
*
* @return The state of the button.
*/
public boolean getDpadRightButton() {
return getButton(Button.DPAD_RIGHT);
}
/**
* Whether the D-pad right button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getDpadRightButtonPressed() {
return getButtonPressed(Button.DPAD_RIGHT);
}
/**
* Whether the D-pad right button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getDpadRightButtonReleased() {
return getButtonReleased(Button.DPAD_RIGHT);
}
/**
* Constructs an event instance around the D-pad right button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the D-pad right button's digital signal attached to the
* given loop.
*/
public BooleanEvent dpadRight(EventLoop loop) {
return button(Button.DPAD_RIGHT, loop);
}
/**
* Read the value of the Miscellaneous 1 button on the controller.
*
* @return The state of the button.
*/
public boolean getMisc1Button() {
return getButton(Button.MISC_1);
}
/**
* Whether the Miscellaneous 1 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getMisc1ButtonPressed() {
return getButtonPressed(Button.MISC_1);
}
/**
* Whether the Miscellaneous 1 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getMisc1ButtonReleased() {
return getButtonReleased(Button.MISC_1);
}
/**
* Constructs an event instance around the Miscellaneous 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Miscellaneous 1 button's digital signal attached to
* the given loop.
*/
public BooleanEvent misc1(EventLoop loop) {
return button(Button.MISC_1, loop);
}
/**
* Read the value of the Right Paddle 1 button on the controller.
*
* @return The state of the button.
*/
public boolean getRightPaddle1Button() {
return getButton(Button.RIGHT_PADDLE_1);
}
/**
* Whether the Right Paddle 1 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getRightPaddle1ButtonPressed() {
return getButtonPressed(Button.RIGHT_PADDLE_1);
}
/**
* Whether the Right Paddle 1 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getRightPaddle1ButtonReleased() {
return getButtonReleased(Button.RIGHT_PADDLE_1);
}
/**
* Constructs an event instance around the Right Paddle 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Right Paddle 1 button's digital signal attached to
* the given loop.
*/
public BooleanEvent rightPaddle1(EventLoop loop) {
return button(Button.RIGHT_PADDLE_1, loop);
}
/**
* Read the value of the Left Paddle 1 button on the controller.
*
* @return The state of the button.
*/
public boolean getLeftPaddle1Button() {
return getButton(Button.LEFT_PADDLE_1);
}
/**
* Whether the Left Paddle 1 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getLeftPaddle1ButtonPressed() {
return getButtonPressed(Button.LEFT_PADDLE_1);
}
/**
* Whether the Left Paddle 1 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getLeftPaddle1ButtonReleased() {
return getButtonReleased(Button.LEFT_PADDLE_1);
}
/**
* Constructs an event instance around the Left Paddle 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Left Paddle 1 button's digital signal attached to
* the given loop.
*/
public BooleanEvent leftPaddle1(EventLoop loop) {
return button(Button.LEFT_PADDLE_1, loop);
}
/**
* Read the value of the Right Paddle 2 button on the controller.
*
* @return The state of the button.
*/
public boolean getRightPaddle2Button() {
return getButton(Button.RIGHT_PADDLE_2);
}
/**
* Whether the Right Paddle 2 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getRightPaddle2ButtonPressed() {
return getButtonPressed(Button.RIGHT_PADDLE_2);
}
/**
* Whether the Right Paddle 2 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getRightPaddle2ButtonReleased() {
return getButtonReleased(Button.RIGHT_PADDLE_2);
}
/**
* Constructs an event instance around the Right Paddle 2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Right Paddle 2 button's digital signal attached to
* the given loop.
*/
public BooleanEvent rightPaddle2(EventLoop loop) {
return button(Button.RIGHT_PADDLE_2, loop);
}
/**
* Read the value of the Left Paddle 2 button on the controller.
*
* @return The state of the button.
*/
public boolean getLeftPaddle2Button() {
return getButton(Button.LEFT_PADDLE_2);
}
/**
* Whether the Left Paddle 2 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getLeftPaddle2ButtonPressed() {
return getButtonPressed(Button.LEFT_PADDLE_2);
}
/**
* Whether the Left Paddle 2 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getLeftPaddle2ButtonReleased() {
return getButtonReleased(Button.LEFT_PADDLE_2);
}
/**
* Constructs an event instance around the Left Paddle 2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Left Paddle 2 button's digital signal attached to
* the given loop.
*/
public BooleanEvent leftPaddle2(EventLoop loop) {
return button(Button.LEFT_PADDLE_2, loop);
}
/**
* Read the value of the Touchpad button on the controller.
*
* @return The state of the button.
*/
public boolean getTouchpadButton() {
return getButton(Button.TOUCHPAD);
}
/**
* Whether the Touchpad button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getTouchpadButtonPressed() {
return getButtonPressed(Button.TOUCHPAD);
}
/**
* Whether the Touchpad button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getTouchpadButtonReleased() {
return getButtonReleased(Button.TOUCHPAD);
}
/**
* Constructs an event instance around the Touchpad button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Touchpad button's digital signal attached to the
* given loop.
*/
public BooleanEvent touchpad(EventLoop loop) {
return button(Button.TOUCHPAD, loop);
}
/**
* Read the value of the Miscellaneous 2 button on the controller.
*
* @return The state of the button.
*/
public boolean getMisc2Button() {
return getButton(Button.MISC_2);
}
/**
* Whether the Miscellaneous 2 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getMisc2ButtonPressed() {
return getButtonPressed(Button.MISC_2);
}
/**
* Whether the Miscellaneous 2 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getMisc2ButtonReleased() {
return getButtonReleased(Button.MISC_2);
}
/**
* Constructs an event instance around the Miscellaneous 2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Miscellaneous 2 button's digital signal attached to
* the given loop.
*/
public BooleanEvent misc2(EventLoop loop) {
return button(Button.MISC_2, loop);
}
/**
* Read the value of the Miscellaneous 3 button on the controller.
*
* @return The state of the button.
*/
public boolean getMisc3Button() {
return getButton(Button.MISC_3);
}
/**
* Whether the Miscellaneous 3 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getMisc3ButtonPressed() {
return getButtonPressed(Button.MISC_3);
}
/**
* Whether the Miscellaneous 3 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getMisc3ButtonReleased() {
return getButtonReleased(Button.MISC_3);
}
/**
* Constructs an event instance around the Miscellaneous 3 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Miscellaneous 3 button's digital signal attached to
* the given loop.
*/
public BooleanEvent misc3(EventLoop loop) {
return button(Button.MISC_3, loop);
}
/**
* Read the value of the Miscellaneous 4 button on the controller.
*
* @return The state of the button.
*/
public boolean getMisc4Button() {
return getButton(Button.MISC_4);
}
/**
* Whether the Miscellaneous 4 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getMisc4ButtonPressed() {
return getButtonPressed(Button.MISC_4);
}
/**
* Whether the Miscellaneous 4 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getMisc4ButtonReleased() {
return getButtonReleased(Button.MISC_4);
}
/**
* Constructs an event instance around the Miscellaneous 4 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Miscellaneous 4 button's digital signal attached to
* the given loop.
*/
public BooleanEvent misc4(EventLoop loop) {
return button(Button.MISC_4, loop);
}
/**
* Read the value of the Miscellaneous 5 button on the controller.
*
* @return The state of the button.
*/
public boolean getMisc5Button() {
return getButton(Button.MISC_5);
}
/**
* Whether the Miscellaneous 5 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getMisc5ButtonPressed() {
return getButtonPressed(Button.MISC_5);
}
/**
* Whether the Miscellaneous 5 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getMisc5ButtonReleased() {
return getButtonReleased(Button.MISC_5);
}
/**
* Constructs an event instance around the Miscellaneous 5 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Miscellaneous 5 button's digital signal attached to
* the given loop.
*/
public BooleanEvent misc5(EventLoop loop) {
return button(Button.MISC_5, loop);
}
/**
* Read the value of the Miscellaneous 6 button on the controller.
*
* @return The state of the button.
*/
public boolean getMisc6Button() {
return getButton(Button.MISC_6);
}
/**
* Whether the Miscellaneous 6 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getMisc6ButtonPressed() {
return getButtonPressed(Button.MISC_6);
}
/**
* Whether the Miscellaneous 6 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getMisc6ButtonReleased() {
return getButtonReleased(Button.MISC_6);
}
/**
* Constructs an event instance around the Miscellaneous 6 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Miscellaneous 6 button's digital signal attached to
* the given loop.
*/
public BooleanEvent misc6(EventLoop loop) {
return button(Button.MISC_6, loop);
}
/**
* Get the button value (starting at button 1).
*
* <p>This method returns true if the button is being held down at the time that this method is
* being called.
*
* @param button The button
* @return The state of the button.
*/
public boolean getButton(Button button) {
return m_hid.getRawButton(button.value);
}
/**
* Whether the button was pressed since the last check.
*
* <p>This method returns true if the button went from not pressed to held down since the last
* time this method was called. This is useful if you only want to call a function once when you
* press the button.
*
* @param button The button
* @return Whether the button was pressed since the last check.
*/
public boolean getButtonPressed(Button button) {
return m_hid.getRawButtonPressed(button.value);
}
/**
* Whether the button was released since the last check.
*
* <p>This method returns true if the button went from held down to not pressed since the last
* time this method was called. This is useful if you only want to call a function once when you
* release the button.
*
* @param button The button
* @return Whether the button was released since the last check.
*/
public boolean getButtonReleased(Button button) {
return m_hid.getRawButtonReleased(button.value);
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the button's digital signal attached to the given loop.
*/
public BooleanEvent button(Button button, EventLoop loop) {
return m_hid.button(button.value, loop);
}
/**
* Get the value of the axis.
*
* @param axis The axis to read
* @return The value of the axis.
*/
public double getAxis(Axis axis) {
return m_hid.getRawAxis(axis.value);
}
/**
* Constructs an event instance that is true when the axis value is less than {@code threshold},
* attached to the given loop.
*
* @param axis The axis to read, starting at 0
* @param threshold The value below which this event should return true.
* @param loop the event loop instance to attach the event to.
* @return an event instance that is true when the axis value is less than the provided threshold.
*/
public BooleanEvent axisLessThan(Axis axis, double threshold, EventLoop loop) {
return m_hid.axisLessThan(axis.value, threshold, loop);
}
/**
* Constructs an event instance that is true when the axis value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read, starting at 0
* @param threshold The value above which this event should return true.
* @param loop the event loop instance to attach the event to.
* @return an event instance that is true when the axis value is greater than the provided
* threshold.
*/
public BooleanEvent axisGreaterThan(Axis axis, double threshold, EventLoop loop) {
return m_hid.axisGreaterThan(axis.value, threshold, loop);
}
/**
* Get the bitmask of axes for the gamepad.
*
* @return the number of axis for the current gamepad
*/
public int getAxesAvailable() {
return m_hid.getAxesAvailable();
}
/**
* For the current gamepad, return the bitmask of available buttons.
*
* @return the bitmask of buttons for the current gamepad
*/
public long getButtonsAvailable() {
return m_hid.getButtonsAvailable();
}
/**
* Get if the gamepad is connected.
*
* @return true if the gamepad is connected
*/
public boolean isConnected() {
return m_hid.isConnected();
}
/**
* Get the type of the gamepad.
*
* @return the type of the gamepad.
*/
public HIDType getGamepadType() {
return m_hid.getGamepadType();
}
/**
* Get the supported outputs for the gamepad.
*
* @return the supported outputs for the gamepad.
*/
public EnumSet<SupportedOutput> getSupportedOutputs() {
return m_hid.getSupportedOutputs();
}
/**
* Get the name of the gamepad.
*
* @return the name of the gamepad.
*/
public String getName() {
return m_hid.getName();
}
/**
* Set leds on the gamepad. If only mono is supported, the system will use the highest value
* passed in.
*
* @param r Red value from 0-255
* @param g Green value from 0-255
* @param b Blue value from 0-255
*/
public void setLeds(int r, int g, int b) {
m_hid.setLeds(r, g, b);
}
/**
* Set the rumble output for the HID. The DS currently supports 4 rumble values: left rumble,
* right rumble, left trigger rumble, and right trigger rumble.
*
* @param type Which rumble value to set
* @param value The normalized value (0 to 1) to set the rumble to
*/
public void setRumble(RumbleType type, double value) {
m_hid.setRumble(type, value);
}
/**
* Check if a touchpad finger is available.
*
* @param touchpad The touchpad to check.
* @param finger The finger to check.
* @return true if the touchpad finger is available.
*/
public boolean getTouchpadFingerAvailable(int touchpad, int finger) {
return m_hid.getTouchpadFingerAvailable(touchpad, finger);
}
/**
* Get the touchpad finger data.
*
* @param touchpad The touchpad to read.
* @param finger The finger to read.
* @return The touchpad finger data.
*/
public TouchpadFinger getTouchpadFinger(int touchpad, int finger) {
return m_hid.getTouchpadFinger(touchpad, finger);
}
private double getAxisForSendable(Axis axis) {
return DriverStationBackend.getStickAxisIfAvailable(m_hid.getPort(), axis.value).orElse(0.0);
}
private boolean getButtonForSendable(Button button) {
return DriverStationBackend.getStickButtonIfAvailable(m_hid.getPort(), button.value)
.orElse(false);
}
@Override
public void initSendable(SendableBuilder builder) {
builder.setSmartDashboardType("HID");
builder.publishConstString("ControllerType", "Gamepad");
builder.addDoubleProperty(
"LeftTrigger Axis", () -> getAxisForSendable(Axis.LEFT_TRIGGER), null);
builder.addDoubleProperty(
"RightTrigger Axis", () -> getAxisForSendable(Axis.RIGHT_TRIGGER), null);
builder.addDoubleProperty("LeftX", () -> getAxisForSendable(Axis.LEFT_X), null);
builder.addDoubleProperty("LeftY", () -> getAxisForSendable(Axis.LEFT_Y), null);
builder.addDoubleProperty("RightX", () -> getAxisForSendable(Axis.RIGHT_X), null);
builder.addDoubleProperty("RightY", () -> getAxisForSendable(Axis.RIGHT_Y), null);
builder.addBooleanProperty("FaceDown", () -> getButtonForSendable(Button.FACE_DOWN), null);
builder.addBooleanProperty("FaceRight", () -> getButtonForSendable(Button.FACE_RIGHT), null);
builder.addBooleanProperty("FaceLeft", () -> getButtonForSendable(Button.FACE_LEFT), null);
builder.addBooleanProperty("FaceUp", () -> getButtonForSendable(Button.FACE_UP), null);
builder.addBooleanProperty("Back", () -> getButtonForSendable(Button.BACK), null);
builder.addBooleanProperty("Guide", () -> getButtonForSendable(Button.GUIDE), null);
builder.addBooleanProperty("Start", () -> getButtonForSendable(Button.START), null);
builder.addBooleanProperty("LeftStick", () -> getButtonForSendable(Button.LEFT_STICK), null);
builder.addBooleanProperty("RightStick", () -> getButtonForSendable(Button.RIGHT_STICK), null);
builder.addBooleanProperty("LeftBumper", () -> getButtonForSendable(Button.LEFT_BUMPER), null);
builder.addBooleanProperty(
"RightBumper", () -> getButtonForSendable(Button.RIGHT_BUMPER), null);
builder.addBooleanProperty("DpadUp", () -> getButtonForSendable(Button.DPAD_UP), null);
builder.addBooleanProperty("DpadDown", () -> getButtonForSendable(Button.DPAD_DOWN), null);
builder.addBooleanProperty("DpadLeft", () -> getButtonForSendable(Button.DPAD_LEFT), null);
builder.addBooleanProperty("DpadRight", () -> getButtonForSendable(Button.DPAD_RIGHT), null);
builder.addBooleanProperty("Misc1", () -> getButtonForSendable(Button.MISC_1), null);
builder.addBooleanProperty(
"RightPaddle1", () -> getButtonForSendable(Button.RIGHT_PADDLE_1), null);
builder.addBooleanProperty(
"LeftPaddle1", () -> getButtonForSendable(Button.LEFT_PADDLE_1), null);
builder.addBooleanProperty(
"RightPaddle2", () -> getButtonForSendable(Button.RIGHT_PADDLE_2), null);
builder.addBooleanProperty(
"LeftPaddle2", () -> getButtonForSendable(Button.LEFT_PADDLE_2), null);
builder.addBooleanProperty("Touchpad", () -> getButtonForSendable(Button.TOUCHPAD), null);
builder.addBooleanProperty("Misc2", () -> getButtonForSendable(Button.MISC_2), null);
builder.addBooleanProperty("Misc3", () -> getButtonForSendable(Button.MISC_3), null);
builder.addBooleanProperty("Misc4", () -> getButtonForSendable(Button.MISC_4), null);
builder.addBooleanProperty("Misc5", () -> getButtonForSendable(Button.MISC_5), null);
builder.addBooleanProperty("Misc6", () -> getButtonForSendable(Button.MISC_6), null);
}
}