[wpilib,cmd] Remove Axis from Gamepad Triggers (#8956)

It's a bit confusing, especially since some controllers will have this be
a 0:1 button rather than axis.
This commit is contained in:
Thad House
2026-06-12 06:42:06 -07:00
committed by GitHub
parent d6fb871a26
commit 5a7d7d50ee
11 changed files with 47 additions and 49 deletions

View File

@@ -873,22 +873,22 @@ public class CommandGamepad {
}
/**
* 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].
* Get the left trigger value of the controller. Note that this axis is bound to the range of [0,
* 1] as opposed to the usual [-1, 1].
*
* @return The axis value.
*/
public double getLeftTriggerAxis() {
return m_gamepad.getLeftTriggerAxis();
public double getLeftTrigger() {
return m_gamepad.getLeftTrigger();
}
/**
* 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].
* Get the right trigger value of the controller. Note that this axis is bound to the range of [0,
* 1] as opposed to the usual [-1, 1].
*
* @return The axis value.
*/
public double getRightTriggerAxis() {
return m_gamepad.getRightTriggerAxis();
public double getRightTrigger() {
return m_gamepad.getRightTrigger();
}
}

View File

@@ -181,10 +181,10 @@ double CommandGamepad::GetRightY() const {
return m_gamepad->GetRightY();
}
double CommandGamepad::GetLeftTriggerAxis() const {
return m_gamepad->GetLeftTriggerAxis();
double CommandGamepad::GetLeftTrigger() const {
return m_gamepad->GetLeftTrigger();
}
double CommandGamepad::GetRightTriggerAxis() const {
return m_gamepad->GetRightTriggerAxis();
double CommandGamepad::GetRightTrigger() const {
return m_gamepad->GetRightTrigger();
}

View File

@@ -494,20 +494,20 @@ class CommandGamepad {
double GetRightY() const;
/**
* Get the left trigger axis value of the controller. Note that this axis is
* Get the left trigger value of the controller. Note that this axis is
* bound to the range of [0, 1] as opposed to the usual [-1, 1].
*
* @return The axis value.
*/
double GetLeftTriggerAxis() const;
double GetLeftTrigger() const;
/**
* Get the right trigger axis value of the controller. Note that this axis is
* Get the right trigger value of the controller. Note that this axis is
* bound to the range of [0, 1] as opposed to the usual [-1, 1].
*
* @return The axis value.
*/
double GetRightTriggerAxis() const;
double GetRightTrigger() const;
private:
CommandGenericHID* m_hid;

View File

@@ -824,22 +824,22 @@ public class CommandGamepad {
}
/**
* 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].
* Get the left trigger value of the controller. Note that this axis is bound to the range of [0,
* 1] as opposed to the usual [-1, 1].
*
* @return The axis value.
*/
public double getLeftTriggerAxis() {
return m_gamepad.getLeftTriggerAxis();
public double getLeftTrigger() {
return m_gamepad.getLeftTrigger();
}
/**
* 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].
* Get the right trigger value of the controller. Note that this axis is bound to the range of [0,
* 1] as opposed to the usual [-1, 1].
*
* @return The axis value.
*/
public double getRightTriggerAxis() {
return m_gamepad.getRightTriggerAxis();
public double getRightTrigger() {
return m_gamepad.getRightTrigger();
}
}

View File

@@ -69,7 +69,7 @@ void Gamepad::SetRightYDeadband(double deadband) {
m_rightYDeadband = ClampDeadband(deadband);
}
double Gamepad::GetLeftTriggerAxis() const {
double Gamepad::GetLeftTrigger() const {
return wpi::math::ApplyDeadband(GetAxis(Axis::LEFT_TRIGGER),
m_leftTriggerDeadband);
}
@@ -88,7 +88,7 @@ BooleanEvent Gamepad::LeftTrigger(EventLoop* loop) const {
return this->LeftTrigger(0.5, loop);
}
double Gamepad::GetRightTriggerAxis() const {
double Gamepad::GetRightTrigger() const {
return wpi::math::ApplyDeadband(GetAxis(Axis::RIGHT_TRIGGER),
m_rightTriggerDeadband);
}
@@ -613,10 +613,10 @@ void Gamepad::InitSendable(wpi::util::SendableBuilder& builder) {
builder.SetSmartDashboardType("HID");
builder.PublishConstString("ControllerType", "Gamepad");
builder.AddDoubleProperty(
"LeftTrigger Axis",
[this] { return GetAxisForSendable(Axis::LEFT_TRIGGER); }, nullptr);
"LeftTrigger", [this] { return GetAxisForSendable(Axis::LEFT_TRIGGER); },
nullptr);
builder.AddDoubleProperty(
"RightTrigger Axis",
"RightTrigger",
[this] { return GetAxisForSendable(Axis::RIGHT_TRIGGER); }, nullptr);
builder.AddDoubleProperty(
"LeftX", [this] { return GetAxisForSendable(Axis::LEFT_X); }, nullptr);

View File

@@ -214,7 +214,7 @@ class Gamepad : public HIDDevice,
void SetRightYDeadband(double deadband);
/**
* Get the left trigger axis value of the controller. Note that this axis
* Get the left trigger value of the controller. Note that this axis
* is bound to the range of [0, 1] as opposed to the usual [-1, 1].
*
* A deadband of 0.01 is applied by default. Use SetLeftTriggerDeadband() to
@@ -222,7 +222,7 @@ class Gamepad : public HIDDevice,
*
* @return the axis value.
*/
double GetLeftTriggerAxis() const;
double GetLeftTrigger() const;
/**
* Set the deadband for the left trigger axis.
@@ -256,7 +256,7 @@ class Gamepad : public HIDDevice,
BooleanEvent LeftTrigger(EventLoop* loop) const;
/**
* Get the right trigger axis value of the controller. Note that this axis
* Get the right trigger value of the controller. Note that this axis
* is bound to the range of [0, 1] as opposed to the usual [-1, 1].
*
* A deadband of 0.01 is applied by default. Use SetRightTriggerDeadband() to
@@ -264,7 +264,7 @@ class Gamepad : public HIDDevice,
*
* @return the axis value.
*/
double GetRightTriggerAxis() const;
double GetRightTrigger() const;
/**
* Set the deadband for the right trigger axis.

View File

@@ -29,13 +29,13 @@ classes:
SetRightXDeadband:
GetRightY:
SetRightYDeadband:
GetLeftTriggerAxis:
GetLeftTrigger:
SetLeftTriggerDeadband:
LeftTrigger:
overloads:
double, EventLoop* [const]:
EventLoop* [const]:
GetRightTriggerAxis:
GetRightTrigger:
SetRightTriggerDeadband:
RightTrigger:
overloads:

View File

@@ -27,7 +27,7 @@ void SysIdRoutineBot::ConfigureBindings() {
.WhileTrue(drive.SysIdDynamic(wpi::cmd::sysid::Direction::kReverse));
shooter.SetDefaultCommand(shooter.RunShooterCommand(
[this] { return driverController.GetLeftTriggerAxis(); }));
[this] { return driverController.GetLeftTrigger(); }));
(driverController.FaceDown() && driverController.LeftBumper())
.WhileTrue(

View File

@@ -299,14 +299,14 @@ public class Gamepad implements HIDDevice, Sendable {
}
/**
* 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].
* Get the left trigger 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() {
public double getLeftTrigger() {
return MathUtil.applyDeadband(getAxis(Axis.LEFT_TRIGGER), m_leftTriggerDeadband);
}
@@ -337,14 +337,14 @@ public class Gamepad implements HIDDevice, Sendable {
}
/**
* 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].
* Get the right trigger 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() {
public double getRightTrigger() {
return MathUtil.applyDeadband(getAxis(Axis.RIGHT_TRIGGER), m_rightTriggerDeadband);
}
@@ -1563,10 +1563,8 @@ public class Gamepad implements HIDDevice, Sendable {
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("LeftTrigger", () -> getAxisForSendable(Axis.LEFT_TRIGGER), null);
builder.addDoubleProperty("RightTrigger", () -> 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);

View File

@@ -25,7 +25,7 @@ public class DefaultTeleMode extends PeriodicOpMode {
robot.motor1.setThrottle(-gamepad.getRightY());
robot.motor2.setThrottle(-gamepad.getLeftX());
robot.motor3.setThrottle(-gamepad.getRightX());
robot.servo0.setPosition(gamepad.getLeftTriggerAxis());
robot.servo1.setPosition(gamepad.getRightTriggerAxis());
robot.servo0.setPosition(gamepad.getLeftTrigger());
robot.servo1.setPosition(gamepad.getRightTrigger());
}
}

View File

@@ -62,7 +62,7 @@ public class SysIdRoutineBot {
.whileTrue(drive.sysIdDynamic(SysIdRoutine.Direction.kReverse));
// Control the shooter wheel with the left trigger
shooter.setDefaultCommand(shooter.runShooter(driverController::getLeftTriggerAxis));
shooter.setDefaultCommand(shooter.runShooter(driverController::getLeftTrigger));
driverController
.faceDown()