[wpilib,commands] Use Jinja to generate HID classes (#6274)

This commit is contained in:
Gold856
2024-06-08 12:59:07 -04:00
committed by GitHub
parent a0efc9ca31
commit 65c6306047
75 changed files with 7622 additions and 4546 deletions

View File

@@ -0,0 +1,749 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_hids.py. DO NOT MODIFY
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.wpilibj.event.BooleanEvent;
import edu.wpi.first.wpilibj.event.EventLoop;
/**
* Handle input from PS4 controllers connected to the Driver Station.
*
* <p>This class handles PS4 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.
*
* <p>Only first party controllers from Sony are guaranteed to have the correct mapping, and
* only through the official NI DS. Sim is not guaranteed to have the same mapping, as well as any
* 3rd party controllers.
*/
public class PS4Controller extends GenericHID {
/** Represents a digital button on a PS4Controller. */
public enum Button {
/** Square button. */
kSquare(1),
/** Cross button. */
kCross(2),
/** Circle button. */
kCircle(3),
/** Triangle button. */
kTriangle(4),
/** Left trigger 1 button. */
kL1(5),
/** Right trigger 1 button. */
kR1(6),
/** Left trigger 2 button. */
kL2(7),
/** Right trigger 2 button. */
kR2(8),
/** Share button. */
kShare(9),
/** Options button. */
kOptions(10),
/** L3 (left stick) button. */
kL3(11),
/** R3 (right stick) button. */
kR3(12),
/** PlayStation button. */
kPS(13),
/** Touchpad button. */
kTouchpad(14);
/** Button value. */
public final int value;
Button(int value) {
this.value = value;
}
/**
* Get the human-friendly name of the button, matching the relevant methods. This is done by
* stripping the leading `k`, and appending `Button`.
*
* <p>Primarily used for automated unit tests.
*
* @return the human-friendly name of the button.
*/
@Override
public String toString() {
// Remove leading `k`
return this.name().substring(1) + "Button";
}
}
/** Represents an axis on an PS4Controller. */
public enum Axis {
/** Left X axis. */
kLeftX(0),
/** Left Y axis. */
kLeftY(1),
/** Right X axis. */
kRightX(2),
/** Right Y axis. */
kRightY(5),
/** Left trigger 2. */
kL2(3),
/** Right trigger 2. */
kR2(4);
/** Axis value. */
public final int value;
Axis(int value) {
this.value = value;
}
/**
* Get the human-friendly name of the axis, matching the relevant methods. This is done by
* stripping the leading `k`, and appending `Axis` if the name ends with `2`.
*
* <p>Primarily used for automated unit tests.
*
* @return the human-friendly name of the axis.
*/
@Override
public String toString() {
var name = this.name().substring(1); // Remove leading `k`
if (name.endsWith("2")) {
return name + "Axis";
}
return name;
}
}
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into (0-5).
*/
public PS4Controller(final int port) {
super(port);
HAL.report(tResourceType.kResourceType_PS4Controller, port + 1);
}
/**
* Get the X axis value of left side of the controller.
*
* @return The axis value.
*/
public double getLeftX() {
return getRawAxis(Axis.kLeftX.value);
}
/**
* Get the Y axis value of left side of the controller.
*
* @return The axis value.
*/
public double getLeftY() {
return getRawAxis(Axis.kLeftY.value);
}
/**
* Get the X axis value of right side of the controller.
*
* @return The axis value.
*/
public double getRightX() {
return getRawAxis(Axis.kRightX.value);
}
/**
* Get the Y axis value of right side of the controller.
*
* @return The axis value.
*/
public double getRightY() {
return getRawAxis(Axis.kRightY.value);
}
/**
* Get the left trigger 2 axis 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 getL2Axis() {
return getRawAxis(Axis.kL2.value);
}
/**
* Get the right trigger 2 axis 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 getR2Axis() {
return getRawAxis(Axis.kR2.value);
}
/**
* Read the value of the square button on the controller.
*
* @return The state of the button.
*/
public boolean getSquareButton() {
return getRawButton(Button.kSquare.value);
}
/**
* Whether the square button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getSquareButtonPressed() {
return getRawButtonPressed(Button.kSquare.value);
}
/**
* Whether the square button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getSquareButtonReleased() {
return getRawButtonReleased(Button.kSquare.value);
}
/**
* Constructs an event instance around the square button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the square button's digital signal
* attached to the given loop.
*/
public BooleanEvent square(EventLoop loop) {
return new BooleanEvent(loop, this::getSquareButton);
}
/**
* Read the value of the cross button on the controller.
*
* @return The state of the button.
*/
public boolean getCrossButton() {
return getRawButton(Button.kCross.value);
}
/**
* Whether the cross button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getCrossButtonPressed() {
return getRawButtonPressed(Button.kCross.value);
}
/**
* Whether the cross button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getCrossButtonReleased() {
return getRawButtonReleased(Button.kCross.value);
}
/**
* Constructs an event instance around the cross button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the cross button's digital signal
* attached to the given loop.
*/
public BooleanEvent cross(EventLoop loop) {
return new BooleanEvent(loop, this::getCrossButton);
}
/**
* Read the value of the circle button on the controller.
*
* @return The state of the button.
*/
public boolean getCircleButton() {
return getRawButton(Button.kCircle.value);
}
/**
* Whether the circle button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getCircleButtonPressed() {
return getRawButtonPressed(Button.kCircle.value);
}
/**
* Whether the circle button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getCircleButtonReleased() {
return getRawButtonReleased(Button.kCircle.value);
}
/**
* Constructs an event instance around the circle button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the circle button's digital signal
* attached to the given loop.
*/
public BooleanEvent circle(EventLoop loop) {
return new BooleanEvent(loop, this::getCircleButton);
}
/**
* Read the value of the triangle button on the controller.
*
* @return The state of the button.
*/
public boolean getTriangleButton() {
return getRawButton(Button.kTriangle.value);
}
/**
* Whether the triangle button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getTriangleButtonPressed() {
return getRawButtonPressed(Button.kTriangle.value);
}
/**
* Whether the triangle button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getTriangleButtonReleased() {
return getRawButtonReleased(Button.kTriangle.value);
}
/**
* Constructs an event instance around the triangle button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the triangle button's digital signal
* attached to the given loop.
*/
public BooleanEvent triangle(EventLoop loop) {
return new BooleanEvent(loop, this::getTriangleButton);
}
/**
* Read the value of the left trigger 1 button on the controller.
*
* @return The state of the button.
*/
public boolean getL1Button() {
return getRawButton(Button.kL1.value);
}
/**
* Whether the left trigger 1 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getL1ButtonPressed() {
return getRawButtonPressed(Button.kL1.value);
}
/**
* Whether the left trigger 1 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getL1ButtonReleased() {
return getRawButtonReleased(Button.kL1.value);
}
/**
* Constructs an event instance around the left trigger 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left trigger 1 button's digital signal
* attached to the given loop.
*/
public BooleanEvent L1(EventLoop loop) {
return new BooleanEvent(loop, this::getL1Button);
}
/**
* Read the value of the right trigger 1 button on the controller.
*
* @return The state of the button.
*/
public boolean getR1Button() {
return getRawButton(Button.kR1.value);
}
/**
* Whether the right trigger 1 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getR1ButtonPressed() {
return getRawButtonPressed(Button.kR1.value);
}
/**
* Whether the right trigger 1 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getR1ButtonReleased() {
return getRawButtonReleased(Button.kR1.value);
}
/**
* Constructs an event instance around the right trigger 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right trigger 1 button's digital signal
* attached to the given loop.
*/
public BooleanEvent R1(EventLoop loop) {
return new BooleanEvent(loop, this::getR1Button);
}
/**
* Read the value of the left trigger 2 button on the controller.
*
* @return The state of the button.
*/
public boolean getL2Button() {
return getRawButton(Button.kL2.value);
}
/**
* Whether the left trigger 2 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getL2ButtonPressed() {
return getRawButtonPressed(Button.kL2.value);
}
/**
* Whether the left trigger 2 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getL2ButtonReleased() {
return getRawButtonReleased(Button.kL2.value);
}
/**
* Constructs an event instance around the left trigger 2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left trigger 2 button's digital signal
* attached to the given loop.
*/
public BooleanEvent L2(EventLoop loop) {
return new BooleanEvent(loop, this::getL2Button);
}
/**
* Read the value of the right trigger 2 button on the controller.
*
* @return The state of the button.
*/
public boolean getR2Button() {
return getRawButton(Button.kR2.value);
}
/**
* Whether the right trigger 2 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getR2ButtonPressed() {
return getRawButtonPressed(Button.kR2.value);
}
/**
* Whether the right trigger 2 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getR2ButtonReleased() {
return getRawButtonReleased(Button.kR2.value);
}
/**
* Constructs an event instance around the right trigger 2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right trigger 2 button's digital signal
* attached to the given loop.
*/
public BooleanEvent R2(EventLoop loop) {
return new BooleanEvent(loop, this::getR2Button);
}
/**
* Read the value of the share button on the controller.
*
* @return The state of the button.
*/
public boolean getShareButton() {
return getRawButton(Button.kShare.value);
}
/**
* Whether the share button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getShareButtonPressed() {
return getRawButtonPressed(Button.kShare.value);
}
/**
* Whether the share button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getShareButtonReleased() {
return getRawButtonReleased(Button.kShare.value);
}
/**
* Constructs an event instance around the share button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the share button's digital signal
* attached to the given loop.
*/
public BooleanEvent share(EventLoop loop) {
return new BooleanEvent(loop, this::getShareButton);
}
/**
* Read the value of the options button on the controller.
*
* @return The state of the button.
*/
public boolean getOptionsButton() {
return getRawButton(Button.kOptions.value);
}
/**
* Whether the options button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getOptionsButtonPressed() {
return getRawButtonPressed(Button.kOptions.value);
}
/**
* Whether the options button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getOptionsButtonReleased() {
return getRawButtonReleased(Button.kOptions.value);
}
/**
* Constructs an event instance around the options button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the options button's digital signal
* attached to the given loop.
*/
public BooleanEvent options(EventLoop loop) {
return new BooleanEvent(loop, this::getOptionsButton);
}
/**
* Read the value of the L3 (left stick) button on the controller.
*
* @return The state of the button.
*/
public boolean getL3Button() {
return getRawButton(Button.kL3.value);
}
/**
* Whether the L3 (left stick) button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getL3ButtonPressed() {
return getRawButtonPressed(Button.kL3.value);
}
/**
* Whether the L3 (left stick) button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getL3ButtonReleased() {
return getRawButtonReleased(Button.kL3.value);
}
/**
* Constructs an event instance around the L3 (left stick) button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the L3 (left stick) button's digital signal
* attached to the given loop.
*/
public BooleanEvent L3(EventLoop loop) {
return new BooleanEvent(loop, this::getL3Button);
}
/**
* Read the value of the R3 (right stick) button on the controller.
*
* @return The state of the button.
*/
public boolean getR3Button() {
return getRawButton(Button.kR3.value);
}
/**
* Whether the R3 (right stick) button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getR3ButtonPressed() {
return getRawButtonPressed(Button.kR3.value);
}
/**
* Whether the R3 (right stick) button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getR3ButtonReleased() {
return getRawButtonReleased(Button.kR3.value);
}
/**
* Constructs an event instance around the R3 (right stick) button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the R3 (right stick) button's digital signal
* attached to the given loop.
*/
public BooleanEvent R3(EventLoop loop) {
return new BooleanEvent(loop, this::getR3Button);
}
/**
* Read the value of the PlayStation button on the controller.
*
* @return The state of the button.
*/
public boolean getPSButton() {
return getRawButton(Button.kPS.value);
}
/**
* Whether the PlayStation button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getPSButtonPressed() {
return getRawButtonPressed(Button.kPS.value);
}
/**
* Whether the PlayStation button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getPSButtonReleased() {
return getRawButtonReleased(Button.kPS.value);
}
/**
* Constructs an event instance around the PlayStation button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the PlayStation button's digital signal
* attached to the given loop.
*/
public BooleanEvent PS(EventLoop loop) {
return new BooleanEvent(loop, this::getPSButton);
}
/**
* Read the value of the touchpad button on the controller.
*
* @return The state of the button.
*/
public boolean getTouchpadButton() {
return getRawButton(Button.kTouchpad.value);
}
/**
* Whether the touchpad button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getTouchpadButtonPressed() {
return getRawButtonPressed(Button.kTouchpad.value);
}
/**
* Whether the touchpad button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getTouchpadButtonReleased() {
return getRawButtonReleased(Button.kTouchpad.value);
}
/**
* 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 new BooleanEvent(loop, this::getTouchpadButton);
}
/**
* Read the value of the touchpad on the controller.
*
* @return The state of the touchpad.
* @deprecated Use {@link getTouchpadButton} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getTouchpad() {
return getRawButton(Button.kTouchpad.value);
}
/**
* Whether the touchpad was pressed since the last check.
*
* @return Whether the touchpad was pressed since the last check.
* @deprecated Use {@link getTouchpadButtonPressed} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getTouchpadPressed() {
return getRawButtonPressed(Button.kTouchpad.value);
}
/**
* Whether the touchpad was released since the last check.
*
* @return Whether the touchpad was released since the last check.
* @deprecated Use {@link getTouchpadButtonReleased} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getTouchpadReleased() {
return getRawButtonReleased(Button.kTouchpad.value);
}
}

View File

@@ -0,0 +1,749 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_hids.py. DO NOT MODIFY
package edu.wpi.first.wpilibj;
// import edu.wpi.first.hal.FRCNetComm.tResourceType;
// import edu.wpi.first.hal.HAL;
import edu.wpi.first.wpilibj.event.BooleanEvent;
import edu.wpi.first.wpilibj.event.EventLoop;
/**
* Handle input from PS5 controllers connected to the Driver Station.
*
* <p>This class handles PS5 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.
*
* <p>Only first party controllers from Sony are guaranteed to have the correct mapping, and
* only through the official NI DS. Sim is not guaranteed to have the same mapping, as well as any
* 3rd party controllers.
*/
public class PS5Controller extends GenericHID {
/** Represents a digital button on a PS5Controller. */
public enum Button {
/** Square button. */
kSquare(1),
/** Cross button. */
kCross(2),
/** Circle button. */
kCircle(3),
/** Triangle button. */
kTriangle(4),
/** Left trigger 1 button. */
kL1(5),
/** Right trigger 1 button. */
kR1(6),
/** Left trigger 2 button. */
kL2(7),
/** Right trigger 2 button. */
kR2(8),
/** Create button. */
kCreate(9),
/** Options button. */
kOptions(10),
/** L3 (left stick) button. */
kL3(11),
/** R3 (right stick) button. */
kR3(12),
/** PlayStation button. */
kPS(13),
/** Touchpad button. */
kTouchpad(14);
/** Button value. */
public final int value;
Button(int value) {
this.value = value;
}
/**
* Get the human-friendly name of the button, matching the relevant methods. This is done by
* stripping the leading `k`, and appending `Button`.
*
* <p>Primarily used for automated unit tests.
*
* @return the human-friendly name of the button.
*/
@Override
public String toString() {
// Remove leading `k`
return this.name().substring(1) + "Button";
}
}
/** Represents an axis on an PS5Controller. */
public enum Axis {
/** Left X axis. */
kLeftX(0),
/** Left Y axis. */
kLeftY(1),
/** Right X axis. */
kRightX(2),
/** Right Y axis. */
kRightY(5),
/** Left trigger 2. */
kL2(3),
/** Right trigger 2. */
kR2(4);
/** Axis value. */
public final int value;
Axis(int value) {
this.value = value;
}
/**
* Get the human-friendly name of the axis, matching the relevant methods. This is done by
* stripping the leading `k`, and appending `Axis` if the name ends with `2`.
*
* <p>Primarily used for automated unit tests.
*
* @return the human-friendly name of the axis.
*/
@Override
public String toString() {
var name = this.name().substring(1); // Remove leading `k`
if (name.endsWith("2")) {
return name + "Axis";
}
return name;
}
}
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into (0-5).
*/
public PS5Controller(final int port) {
super(port);
// HAL.report(tResourceType.kResourceType_PS5Controller, port + 1);
}
/**
* Get the X axis value of left side of the controller.
*
* @return The axis value.
*/
public double getLeftX() {
return getRawAxis(Axis.kLeftX.value);
}
/**
* Get the Y axis value of left side of the controller.
*
* @return The axis value.
*/
public double getLeftY() {
return getRawAxis(Axis.kLeftY.value);
}
/**
* Get the X axis value of right side of the controller.
*
* @return The axis value.
*/
public double getRightX() {
return getRawAxis(Axis.kRightX.value);
}
/**
* Get the Y axis value of right side of the controller.
*
* @return The axis value.
*/
public double getRightY() {
return getRawAxis(Axis.kRightY.value);
}
/**
* Get the left trigger 2 axis 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 getL2Axis() {
return getRawAxis(Axis.kL2.value);
}
/**
* Get the right trigger 2 axis 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 getR2Axis() {
return getRawAxis(Axis.kR2.value);
}
/**
* Read the value of the square button on the controller.
*
* @return The state of the button.
*/
public boolean getSquareButton() {
return getRawButton(Button.kSquare.value);
}
/**
* Whether the square button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getSquareButtonPressed() {
return getRawButtonPressed(Button.kSquare.value);
}
/**
* Whether the square button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getSquareButtonReleased() {
return getRawButtonReleased(Button.kSquare.value);
}
/**
* Constructs an event instance around the square button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the square button's digital signal
* attached to the given loop.
*/
public BooleanEvent square(EventLoop loop) {
return new BooleanEvent(loop, this::getSquareButton);
}
/**
* Read the value of the cross button on the controller.
*
* @return The state of the button.
*/
public boolean getCrossButton() {
return getRawButton(Button.kCross.value);
}
/**
* Whether the cross button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getCrossButtonPressed() {
return getRawButtonPressed(Button.kCross.value);
}
/**
* Whether the cross button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getCrossButtonReleased() {
return getRawButtonReleased(Button.kCross.value);
}
/**
* Constructs an event instance around the cross button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the cross button's digital signal
* attached to the given loop.
*/
public BooleanEvent cross(EventLoop loop) {
return new BooleanEvent(loop, this::getCrossButton);
}
/**
* Read the value of the circle button on the controller.
*
* @return The state of the button.
*/
public boolean getCircleButton() {
return getRawButton(Button.kCircle.value);
}
/**
* Whether the circle button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getCircleButtonPressed() {
return getRawButtonPressed(Button.kCircle.value);
}
/**
* Whether the circle button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getCircleButtonReleased() {
return getRawButtonReleased(Button.kCircle.value);
}
/**
* Constructs an event instance around the circle button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the circle button's digital signal
* attached to the given loop.
*/
public BooleanEvent circle(EventLoop loop) {
return new BooleanEvent(loop, this::getCircleButton);
}
/**
* Read the value of the triangle button on the controller.
*
* @return The state of the button.
*/
public boolean getTriangleButton() {
return getRawButton(Button.kTriangle.value);
}
/**
* Whether the triangle button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getTriangleButtonPressed() {
return getRawButtonPressed(Button.kTriangle.value);
}
/**
* Whether the triangle button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getTriangleButtonReleased() {
return getRawButtonReleased(Button.kTriangle.value);
}
/**
* Constructs an event instance around the triangle button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the triangle button's digital signal
* attached to the given loop.
*/
public BooleanEvent triangle(EventLoop loop) {
return new BooleanEvent(loop, this::getTriangleButton);
}
/**
* Read the value of the left trigger 1 button on the controller.
*
* @return The state of the button.
*/
public boolean getL1Button() {
return getRawButton(Button.kL1.value);
}
/**
* Whether the left trigger 1 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getL1ButtonPressed() {
return getRawButtonPressed(Button.kL1.value);
}
/**
* Whether the left trigger 1 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getL1ButtonReleased() {
return getRawButtonReleased(Button.kL1.value);
}
/**
* Constructs an event instance around the left trigger 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left trigger 1 button's digital signal
* attached to the given loop.
*/
public BooleanEvent L1(EventLoop loop) {
return new BooleanEvent(loop, this::getL1Button);
}
/**
* Read the value of the right trigger 1 button on the controller.
*
* @return The state of the button.
*/
public boolean getR1Button() {
return getRawButton(Button.kR1.value);
}
/**
* Whether the right trigger 1 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getR1ButtonPressed() {
return getRawButtonPressed(Button.kR1.value);
}
/**
* Whether the right trigger 1 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getR1ButtonReleased() {
return getRawButtonReleased(Button.kR1.value);
}
/**
* Constructs an event instance around the right trigger 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right trigger 1 button's digital signal
* attached to the given loop.
*/
public BooleanEvent R1(EventLoop loop) {
return new BooleanEvent(loop, this::getR1Button);
}
/**
* Read the value of the left trigger 2 button on the controller.
*
* @return The state of the button.
*/
public boolean getL2Button() {
return getRawButton(Button.kL2.value);
}
/**
* Whether the left trigger 2 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getL2ButtonPressed() {
return getRawButtonPressed(Button.kL2.value);
}
/**
* Whether the left trigger 2 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getL2ButtonReleased() {
return getRawButtonReleased(Button.kL2.value);
}
/**
* Constructs an event instance around the left trigger 2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left trigger 2 button's digital signal
* attached to the given loop.
*/
public BooleanEvent L2(EventLoop loop) {
return new BooleanEvent(loop, this::getL2Button);
}
/**
* Read the value of the right trigger 2 button on the controller.
*
* @return The state of the button.
*/
public boolean getR2Button() {
return getRawButton(Button.kR2.value);
}
/**
* Whether the right trigger 2 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getR2ButtonPressed() {
return getRawButtonPressed(Button.kR2.value);
}
/**
* Whether the right trigger 2 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getR2ButtonReleased() {
return getRawButtonReleased(Button.kR2.value);
}
/**
* Constructs an event instance around the right trigger 2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right trigger 2 button's digital signal
* attached to the given loop.
*/
public BooleanEvent R2(EventLoop loop) {
return new BooleanEvent(loop, this::getR2Button);
}
/**
* Read the value of the create button on the controller.
*
* @return The state of the button.
*/
public boolean getCreateButton() {
return getRawButton(Button.kCreate.value);
}
/**
* Whether the create button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getCreateButtonPressed() {
return getRawButtonPressed(Button.kCreate.value);
}
/**
* Whether the create button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getCreateButtonReleased() {
return getRawButtonReleased(Button.kCreate.value);
}
/**
* Constructs an event instance around the create button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the create button's digital signal
* attached to the given loop.
*/
public BooleanEvent create(EventLoop loop) {
return new BooleanEvent(loop, this::getCreateButton);
}
/**
* Read the value of the options button on the controller.
*
* @return The state of the button.
*/
public boolean getOptionsButton() {
return getRawButton(Button.kOptions.value);
}
/**
* Whether the options button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getOptionsButtonPressed() {
return getRawButtonPressed(Button.kOptions.value);
}
/**
* Whether the options button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getOptionsButtonReleased() {
return getRawButtonReleased(Button.kOptions.value);
}
/**
* Constructs an event instance around the options button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the options button's digital signal
* attached to the given loop.
*/
public BooleanEvent options(EventLoop loop) {
return new BooleanEvent(loop, this::getOptionsButton);
}
/**
* Read the value of the L3 (left stick) button on the controller.
*
* @return The state of the button.
*/
public boolean getL3Button() {
return getRawButton(Button.kL3.value);
}
/**
* Whether the L3 (left stick) button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getL3ButtonPressed() {
return getRawButtonPressed(Button.kL3.value);
}
/**
* Whether the L3 (left stick) button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getL3ButtonReleased() {
return getRawButtonReleased(Button.kL3.value);
}
/**
* Constructs an event instance around the L3 (left stick) button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the L3 (left stick) button's digital signal
* attached to the given loop.
*/
public BooleanEvent L3(EventLoop loop) {
return new BooleanEvent(loop, this::getL3Button);
}
/**
* Read the value of the R3 (right stick) button on the controller.
*
* @return The state of the button.
*/
public boolean getR3Button() {
return getRawButton(Button.kR3.value);
}
/**
* Whether the R3 (right stick) button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getR3ButtonPressed() {
return getRawButtonPressed(Button.kR3.value);
}
/**
* Whether the R3 (right stick) button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getR3ButtonReleased() {
return getRawButtonReleased(Button.kR3.value);
}
/**
* Constructs an event instance around the R3 (right stick) button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the R3 (right stick) button's digital signal
* attached to the given loop.
*/
public BooleanEvent R3(EventLoop loop) {
return new BooleanEvent(loop, this::getR3Button);
}
/**
* Read the value of the PlayStation button on the controller.
*
* @return The state of the button.
*/
public boolean getPSButton() {
return getRawButton(Button.kPS.value);
}
/**
* Whether the PlayStation button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getPSButtonPressed() {
return getRawButtonPressed(Button.kPS.value);
}
/**
* Whether the PlayStation button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getPSButtonReleased() {
return getRawButtonReleased(Button.kPS.value);
}
/**
* Constructs an event instance around the PlayStation button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the PlayStation button's digital signal
* attached to the given loop.
*/
public BooleanEvent PS(EventLoop loop) {
return new BooleanEvent(loop, this::getPSButton);
}
/**
* Read the value of the touchpad button on the controller.
*
* @return The state of the button.
*/
public boolean getTouchpadButton() {
return getRawButton(Button.kTouchpad.value);
}
/**
* Whether the touchpad button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getTouchpadButtonPressed() {
return getRawButtonPressed(Button.kTouchpad.value);
}
/**
* Whether the touchpad button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getTouchpadButtonReleased() {
return getRawButtonReleased(Button.kTouchpad.value);
}
/**
* 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 new BooleanEvent(loop, this::getTouchpadButton);
}
/**
* Read the value of the touchpad on the controller.
*
* @return The state of the touchpad.
* @deprecated Use {@link getTouchpadButton} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getTouchpad() {
return getRawButton(Button.kTouchpad.value);
}
/**
* Whether the touchpad was pressed since the last check.
*
* @return Whether the touchpad was pressed since the last check.
* @deprecated Use {@link getTouchpadButtonPressed} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getTouchpadPressed() {
return getRawButtonPressed(Button.kTouchpad.value);
}
/**
* Whether the touchpad was released since the last check.
*
* @return Whether the touchpad was released since the last check.
* @deprecated Use {@link getTouchpadButtonReleased} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getTouchpadReleased() {
return getRawButtonReleased(Button.kTouchpad.value);
}
}

View File

@@ -0,0 +1,798 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_hids.py. DO NOT MODIFY
package edu.wpi.first.wpilibj;
// import edu.wpi.first.hal.FRCNetComm.tResourceType;
// import edu.wpi.first.hal.HAL;
import edu.wpi.first.wpilibj.event.BooleanEvent;
import edu.wpi.first.wpilibj.event.EventLoop;
/**
* Handle input from Stadia controllers connected to the Driver Station.
*
* <p>This class handles Stadia 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.
*
* <p>Only first party controllers from Google are guaranteed to have the correct mapping, and
* only through the official NI DS. Sim is not guaranteed to have the same mapping, as well as any
* 3rd party controllers.
*/
public class StadiaController extends GenericHID {
/** Represents a digital button on a StadiaController. */
public enum Button {
/** A button. */
kA(1),
/** B button. */
kB(2),
/** X button. */
kX(3),
/** Y button. */
kY(4),
/** Left bumper button. */
kLeftBumper(5),
/** Right bumper button. */
kRightBumper(6),
/** Left stick button. */
kLeftStick(7),
/** Right stick button. */
kRightStick(8),
/** Ellipses button. */
kEllipses(9),
/** Hamburger button. */
kHamburger(10),
/** Stadia button. */
kStadia(11),
/** Right trigger button. */
kRightTrigger(12),
/** Left trigger button. */
kLeftTrigger(13),
/** Google button. */
kGoogle(14),
/** Frame button. */
kFrame(15);
/** Button value. */
public final int value;
Button(int value) {
this.value = value;
}
/**
* Get the human-friendly name of the button, matching the relevant methods. This is done by
* stripping the leading `k`, and appending `Button`.
*
* <p>Primarily used for automated unit tests.
*
* @return the human-friendly name of the button.
*/
@Override
public String toString() {
// Remove leading `k`
return this.name().substring(1) + "Button";
}
}
/** Represents an axis on an StadiaController. */
public enum Axis {
/** Left X axis. */
kLeftX(0),
/** Right X axis. */
kRightX(3),
/** Left Y axis. */
kLeftY(1),
/** Right Y axis. */
kRightY(4);
/** Axis value. */
public final int value;
Axis(int value) {
this.value = value;
}
/**
* Get the human-friendly name of the axis, matching the relevant methods. This is done by
* stripping the leading `k`, and appending `Axis` if the name ends with `Trigger`.
*
* <p>Primarily used for automated unit tests.
*
* @return the human-friendly name of the axis.
*/
@Override
public String toString() {
var name = this.name().substring(1); // Remove leading `k`
if (name.endsWith("Trigger")) {
return name + "Axis";
}
return name;
}
}
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into (0-5).
*/
public StadiaController(final int port) {
super(port);
// HAL.report(tResourceType.kResourceType_StadiaController, port + 1);
}
/**
* Get the X axis value of left side of the controller.
*
* @return The axis value.
*/
public double getLeftX() {
return getRawAxis(Axis.kLeftX.value);
}
/**
* Get the X axis value of right side of the controller.
*
* @return The axis value.
*/
public double getRightX() {
return getRawAxis(Axis.kRightX.value);
}
/**
* Get the Y axis value of left side of the controller.
*
* @return The axis value.
*/
public double getLeftY() {
return getRawAxis(Axis.kLeftY.value);
}
/**
* Get the Y axis value of right side of the controller.
*
* @return The axis value.
*/
public double getRightY() {
return getRawAxis(Axis.kRightY.value);
}
/**
* Read the value of the A button on the controller.
*
* @return The state of the button.
*/
public boolean getAButton() {
return getRawButton(Button.kA.value);
}
/**
* Whether the A button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getAButtonPressed() {
return getRawButtonPressed(Button.kA.value);
}
/**
* Whether the A button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getAButtonReleased() {
return getRawButtonReleased(Button.kA.value);
}
/**
* Constructs an event instance around the A button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the A button's digital signal
* attached to the given loop.
*/
public BooleanEvent a(EventLoop loop) {
return new BooleanEvent(loop, this::getAButton);
}
/**
* Read the value of the B button on the controller.
*
* @return The state of the button.
*/
public boolean getBButton() {
return getRawButton(Button.kB.value);
}
/**
* Whether the B button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getBButtonPressed() {
return getRawButtonPressed(Button.kB.value);
}
/**
* Whether the B button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getBButtonReleased() {
return getRawButtonReleased(Button.kB.value);
}
/**
* Constructs an event instance around the B button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the B button's digital signal
* attached to the given loop.
*/
public BooleanEvent b(EventLoop loop) {
return new BooleanEvent(loop, this::getBButton);
}
/**
* Read the value of the X button on the controller.
*
* @return The state of the button.
*/
public boolean getXButton() {
return getRawButton(Button.kX.value);
}
/**
* Whether the X button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getXButtonPressed() {
return getRawButtonPressed(Button.kX.value);
}
/**
* Whether the X button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getXButtonReleased() {
return getRawButtonReleased(Button.kX.value);
}
/**
* Constructs an event instance around the X button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the X button's digital signal
* attached to the given loop.
*/
public BooleanEvent x(EventLoop loop) {
return new BooleanEvent(loop, this::getXButton);
}
/**
* Read the value of the Y button on the controller.
*
* @return The state of the button.
*/
public boolean getYButton() {
return getRawButton(Button.kY.value);
}
/**
* Whether the Y button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getYButtonPressed() {
return getRawButtonPressed(Button.kY.value);
}
/**
* Whether the Y button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getYButtonReleased() {
return getRawButtonReleased(Button.kY.value);
}
/**
* Constructs an event instance around the Y button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Y button's digital signal
* attached to the given loop.
*/
public BooleanEvent y(EventLoop loop) {
return new BooleanEvent(loop, this::getYButton);
}
/**
* Read the value of the left bumper button on the controller.
*
* @return The state of the button.
*/
public boolean getLeftBumperButton() {
return getRawButton(Button.kLeftBumper.value);
}
/**
* Whether the left bumper button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getLeftBumperButtonPressed() {
return getRawButtonPressed(Button.kLeftBumper.value);
}
/**
* Whether the left bumper button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getLeftBumperButtonReleased() {
return getRawButtonReleased(Button.kLeftBumper.value);
}
/**
* Constructs an event instance around the left bumper button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left bumper button's digital signal
* attached to the given loop.
*/
public BooleanEvent leftBumper(EventLoop loop) {
return new BooleanEvent(loop, this::getLeftBumperButton);
}
/**
* Read the value of the right bumper button on the controller.
*
* @return The state of the button.
*/
public boolean getRightBumperButton() {
return getRawButton(Button.kRightBumper.value);
}
/**
* 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 getRawButtonPressed(Button.kRightBumper.value);
}
/**
* 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 getRawButtonReleased(Button.kRightBumper.value);
}
/**
* 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 new BooleanEvent(loop, this::getRightBumperButton);
}
/**
* Read the value of the left stick button on the controller.
*
* @return The state of the button.
*/
public boolean getLeftStickButton() {
return getRawButton(Button.kLeftStick.value);
}
/**
* 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 getRawButtonPressed(Button.kLeftStick.value);
}
/**
* 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 getRawButtonReleased(Button.kLeftStick.value);
}
/**
* 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 new BooleanEvent(loop, this::getLeftStickButton);
}
/**
* Read the value of the right stick button on the controller.
*
* @return The state of the button.
*/
public boolean getRightStickButton() {
return getRawButton(Button.kRightStick.value);
}
/**
* 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 getRawButtonPressed(Button.kRightStick.value);
}
/**
* 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 getRawButtonReleased(Button.kRightStick.value);
}
/**
* 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 new BooleanEvent(loop, this::getRightStickButton);
}
/**
* Read the value of the ellipses button on the controller.
*
* @return The state of the button.
*/
public boolean getEllipsesButton() {
return getRawButton(Button.kEllipses.value);
}
/**
* Whether the ellipses button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getEllipsesButtonPressed() {
return getRawButtonPressed(Button.kEllipses.value);
}
/**
* Whether the ellipses button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getEllipsesButtonReleased() {
return getRawButtonReleased(Button.kEllipses.value);
}
/**
* Constructs an event instance around the ellipses button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the ellipses button's digital signal
* attached to the given loop.
*/
public BooleanEvent ellipses(EventLoop loop) {
return new BooleanEvent(loop, this::getEllipsesButton);
}
/**
* Read the value of the hamburger button on the controller.
*
* @return The state of the button.
*/
public boolean getHamburgerButton() {
return getRawButton(Button.kHamburger.value);
}
/**
* Whether the hamburger button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getHamburgerButtonPressed() {
return getRawButtonPressed(Button.kHamburger.value);
}
/**
* Whether the hamburger button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getHamburgerButtonReleased() {
return getRawButtonReleased(Button.kHamburger.value);
}
/**
* Constructs an event instance around the hamburger button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the hamburger button's digital signal
* attached to the given loop.
*/
public BooleanEvent hamburger(EventLoop loop) {
return new BooleanEvent(loop, this::getHamburgerButton);
}
/**
* Read the value of the stadia button on the controller.
*
* @return The state of the button.
*/
public boolean getStadiaButton() {
return getRawButton(Button.kStadia.value);
}
/**
* Whether the stadia button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getStadiaButtonPressed() {
return getRawButtonPressed(Button.kStadia.value);
}
/**
* Whether the stadia button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getStadiaButtonReleased() {
return getRawButtonReleased(Button.kStadia.value);
}
/**
* Constructs an event instance around the stadia button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the stadia button's digital signal
* attached to the given loop.
*/
public BooleanEvent stadia(EventLoop loop) {
return new BooleanEvent(loop, this::getStadiaButton);
}
/**
* Read the value of the right trigger button on the controller.
*
* @return The state of the button.
*/
public boolean getRightTriggerButton() {
return getRawButton(Button.kRightTrigger.value);
}
/**
* Whether the right trigger button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getRightTriggerButtonPressed() {
return getRawButtonPressed(Button.kRightTrigger.value);
}
/**
* Whether the right trigger button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getRightTriggerButtonReleased() {
return getRawButtonReleased(Button.kRightTrigger.value);
}
/**
* Constructs an event instance around the right trigger button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right trigger button's digital signal
* attached to the given loop.
*/
public BooleanEvent rightTrigger(EventLoop loop) {
return new BooleanEvent(loop, this::getRightTriggerButton);
}
/**
* Read the value of the left trigger button on the controller.
*
* @return The state of the button.
*/
public boolean getLeftTriggerButton() {
return getRawButton(Button.kLeftTrigger.value);
}
/**
* Whether the left trigger button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getLeftTriggerButtonPressed() {
return getRawButtonPressed(Button.kLeftTrigger.value);
}
/**
* Whether the left trigger button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getLeftTriggerButtonReleased() {
return getRawButtonReleased(Button.kLeftTrigger.value);
}
/**
* Constructs an event instance around the left trigger button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left trigger button's digital signal
* attached to the given loop.
*/
public BooleanEvent leftTrigger(EventLoop loop) {
return new BooleanEvent(loop, this::getLeftTriggerButton);
}
/**
* Read the value of the google button on the controller.
*
* @return The state of the button.
*/
public boolean getGoogleButton() {
return getRawButton(Button.kGoogle.value);
}
/**
* Whether the google button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getGoogleButtonPressed() {
return getRawButtonPressed(Button.kGoogle.value);
}
/**
* Whether the google button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getGoogleButtonReleased() {
return getRawButtonReleased(Button.kGoogle.value);
}
/**
* Constructs an event instance around the google button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the google button's digital signal
* attached to the given loop.
*/
public BooleanEvent google(EventLoop loop) {
return new BooleanEvent(loop, this::getGoogleButton);
}
/**
* Read the value of the frame button on the controller.
*
* @return The state of the button.
*/
public boolean getFrameButton() {
return getRawButton(Button.kFrame.value);
}
/**
* Whether the frame button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getFrameButtonPressed() {
return getRawButtonPressed(Button.kFrame.value);
}
/**
* Whether the frame button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getFrameButtonReleased() {
return getRawButtonReleased(Button.kFrame.value);
}
/**
* Constructs an event instance around the frame button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the frame button's digital signal
* attached to the given loop.
*/
public BooleanEvent frame(EventLoop loop) {
return new BooleanEvent(loop, this::getFrameButton);
}
/**
* Read the value of the left bumper (LB) button on the controller.
*
* @return The state of the button.
* @deprecated Use {@link getLeftBumperButton} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getLeftBumper() {
return getRawButton(Button.kLeftBumper.value);
}
/**
* Read the value of the right bumper (RB) button on the controller.
*
* @return The state of the button.
* @deprecated Use {@link getRightBumperButton} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getRightBumper() {
return getRawButton(Button.kRightBumper.value);
}
/**
* Whether the left bumper (LB) was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
* @deprecated Use {@link getLeftBumperButtonPressed} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getLeftBumperPressed() {
return getRawButtonPressed(Button.kLeftBumper.value);
}
/**
* Whether the right bumper (RB) was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
* @deprecated Use {@link getRightBumperButtonPressed} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getRightBumperPressed() {
return getRawButtonPressed(Button.kRightBumper.value);
}
/**
* Whether the left bumper (LB) was released since the last check.
*
* @return Whether the button was released since the last check.
* @deprecated Use {@link getLeftBumperButtonReleased} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getLeftBumperReleased() {
return getRawButtonReleased(Button.kLeftBumper.value);
}
/**
* Whether the right bumper (RB) was released since the last check.
*
* @return Whether the button was released since the last check.
* @deprecated Use {@link getRightBumperButtonReleased} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getRightBumperReleased() {
return getRawButtonReleased(Button.kRightBumper.value);
}
}

View File

@@ -0,0 +1,674 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_hids.py. DO NOT MODIFY
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.wpilibj.event.BooleanEvent;
import edu.wpi.first.wpilibj.event.EventLoop;
/**
* Handle input from Xbox controllers connected to the Driver Station.
*
* <p>This class handles Xbox 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.
*
* <p>Only first party controllers from Microsoft are guaranteed to have the correct mapping, and
* only through the official NI DS. Sim is not guaranteed to have the same mapping, as well as any
* 3rd party controllers.
*/
public class XboxController extends GenericHID {
/** Represents a digital button on a XboxController. */
public enum Button {
/** A button. */
kA(1),
/** B button. */
kB(2),
/** X button. */
kX(3),
/** Y button. */
kY(4),
/** Left bumper button. */
kLeftBumper(5),
/** Right bumper button. */
kRightBumper(6),
/** Back button. */
kBack(7),
/** Start button. */
kStart(8),
/** Left stick button. */
kLeftStick(9),
/** Right stick button. */
kRightStick(10);
/** Button value. */
public final int value;
Button(int value) {
this.value = value;
}
/**
* Get the human-friendly name of the button, matching the relevant methods. This is done by
* stripping the leading `k`, and appending `Button`.
*
* <p>Primarily used for automated unit tests.
*
* @return the human-friendly name of the button.
*/
@Override
public String toString() {
// Remove leading `k`
return this.name().substring(1) + "Button";
}
}
/** Represents an axis on an XboxController. */
public enum Axis {
/** Left X axis. */
kLeftX(0),
/** Right X axis. */
kRightX(4),
/** Left Y axis. */
kLeftY(1),
/** Right Y axis. */
kRightY(5),
/** Left trigger. */
kLeftTrigger(2),
/** Right trigger. */
kRightTrigger(3);
/** Axis value. */
public final int value;
Axis(int value) {
this.value = value;
}
/**
* Get the human-friendly name of the axis, matching the relevant methods. This is done by
* stripping the leading `k`, and appending `Axis` if the name ends with `Trigger`.
*
* <p>Primarily used for automated unit tests.
*
* @return the human-friendly name of the axis.
*/
@Override
public String toString() {
var name = this.name().substring(1); // Remove leading `k`
if (name.endsWith("Trigger")) {
return name + "Axis";
}
return name;
}
}
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into (0-5).
*/
public XboxController(final int port) {
super(port);
HAL.report(tResourceType.kResourceType_XboxController, port + 1);
}
/**
* Get the X axis value of left side of the controller.
*
* @return The axis value.
*/
public double getLeftX() {
return getRawAxis(Axis.kLeftX.value);
}
/**
* Get the X axis value of right side of the controller.
*
* @return The axis value.
*/
public double getRightX() {
return getRawAxis(Axis.kRightX.value);
}
/**
* Get the Y axis value of left side of the controller.
*
* @return The axis value.
*/
public double getLeftY() {
return getRawAxis(Axis.kLeftY.value);
}
/**
* Get the Y axis value of right side of the controller.
*
* @return The axis value.
*/
public double getRightY() {
return getRawAxis(Axis.kRightY.value);
}
/**
* 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].
*
* @return The axis value.
*/
public double getLeftTriggerAxis() {
return getRawAxis(Axis.kLeftTrigger.value);
}
/**
* 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 new BooleanEvent(loop, () -> getLeftTriggerAxis() > threshold);
}
/**
* 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].
*
* @return The axis value.
*/
public double getRightTriggerAxis() {
return getRawAxis(Axis.kRightTrigger.value);
}
/**
* 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 new BooleanEvent(loop, () -> getRightTriggerAxis() > threshold);
}
/**
* 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 A button on the controller.
*
* @return The state of the button.
*/
public boolean getAButton() {
return getRawButton(Button.kA.value);
}
/**
* Whether the A button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getAButtonPressed() {
return getRawButtonPressed(Button.kA.value);
}
/**
* Whether the A button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getAButtonReleased() {
return getRawButtonReleased(Button.kA.value);
}
/**
* Constructs an event instance around the A button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the A button's digital signal
* attached to the given loop.
*/
public BooleanEvent a(EventLoop loop) {
return new BooleanEvent(loop, this::getAButton);
}
/**
* Read the value of the B button on the controller.
*
* @return The state of the button.
*/
public boolean getBButton() {
return getRawButton(Button.kB.value);
}
/**
* Whether the B button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getBButtonPressed() {
return getRawButtonPressed(Button.kB.value);
}
/**
* Whether the B button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getBButtonReleased() {
return getRawButtonReleased(Button.kB.value);
}
/**
* Constructs an event instance around the B button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the B button's digital signal
* attached to the given loop.
*/
public BooleanEvent b(EventLoop loop) {
return new BooleanEvent(loop, this::getBButton);
}
/**
* Read the value of the X button on the controller.
*
* @return The state of the button.
*/
public boolean getXButton() {
return getRawButton(Button.kX.value);
}
/**
* Whether the X button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getXButtonPressed() {
return getRawButtonPressed(Button.kX.value);
}
/**
* Whether the X button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getXButtonReleased() {
return getRawButtonReleased(Button.kX.value);
}
/**
* Constructs an event instance around the X button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the X button's digital signal
* attached to the given loop.
*/
public BooleanEvent x(EventLoop loop) {
return new BooleanEvent(loop, this::getXButton);
}
/**
* Read the value of the Y button on the controller.
*
* @return The state of the button.
*/
public boolean getYButton() {
return getRawButton(Button.kY.value);
}
/**
* Whether the Y button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getYButtonPressed() {
return getRawButtonPressed(Button.kY.value);
}
/**
* Whether the Y button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getYButtonReleased() {
return getRawButtonReleased(Button.kY.value);
}
/**
* Constructs an event instance around the Y button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Y button's digital signal
* attached to the given loop.
*/
public BooleanEvent y(EventLoop loop) {
return new BooleanEvent(loop, this::getYButton);
}
/**
* Read the value of the left bumper button on the controller.
*
* @return The state of the button.
*/
public boolean getLeftBumperButton() {
return getRawButton(Button.kLeftBumper.value);
}
/**
* Whether the left bumper button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getLeftBumperButtonPressed() {
return getRawButtonPressed(Button.kLeftBumper.value);
}
/**
* Whether the left bumper button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getLeftBumperButtonReleased() {
return getRawButtonReleased(Button.kLeftBumper.value);
}
/**
* Constructs an event instance around the left bumper button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left bumper button's digital signal
* attached to the given loop.
*/
public BooleanEvent leftBumper(EventLoop loop) {
return new BooleanEvent(loop, this::getLeftBumperButton);
}
/**
* Read the value of the right bumper button on the controller.
*
* @return The state of the button.
*/
public boolean getRightBumperButton() {
return getRawButton(Button.kRightBumper.value);
}
/**
* 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 getRawButtonPressed(Button.kRightBumper.value);
}
/**
* 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 getRawButtonReleased(Button.kRightBumper.value);
}
/**
* 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 new BooleanEvent(loop, this::getRightBumperButton);
}
/**
* Read the value of the back button on the controller.
*
* @return The state of the button.
*/
public boolean getBackButton() {
return getRawButton(Button.kBack.value);
}
/**
* Whether the back button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getBackButtonPressed() {
return getRawButtonPressed(Button.kBack.value);
}
/**
* Whether the back button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getBackButtonReleased() {
return getRawButtonReleased(Button.kBack.value);
}
/**
* 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 new BooleanEvent(loop, this::getBackButton);
}
/**
* Read the value of the start button on the controller.
*
* @return The state of the button.
*/
public boolean getStartButton() {
return getRawButton(Button.kStart.value);
}
/**
* Whether the start button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
public boolean getStartButtonPressed() {
return getRawButtonPressed(Button.kStart.value);
}
/**
* Whether the start button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
public boolean getStartButtonReleased() {
return getRawButtonReleased(Button.kStart.value);
}
/**
* 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 new BooleanEvent(loop, this::getStartButton);
}
/**
* Read the value of the left stick button on the controller.
*
* @return The state of the button.
*/
public boolean getLeftStickButton() {
return getRawButton(Button.kLeftStick.value);
}
/**
* 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 getRawButtonPressed(Button.kLeftStick.value);
}
/**
* 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 getRawButtonReleased(Button.kLeftStick.value);
}
/**
* 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 new BooleanEvent(loop, this::getLeftStickButton);
}
/**
* Read the value of the right stick button on the controller.
*
* @return The state of the button.
*/
public boolean getRightStickButton() {
return getRawButton(Button.kRightStick.value);
}
/**
* 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 getRawButtonPressed(Button.kRightStick.value);
}
/**
* 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 getRawButtonReleased(Button.kRightStick.value);
}
/**
* 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 new BooleanEvent(loop, this::getRightStickButton);
}
/**
* Read the value of the left bumper (LB) button on the controller.
*
* @return The state of the button.
* @deprecated Use {@link getLeftBumperButton} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getLeftBumper() {
return getRawButton(Button.kLeftBumper.value);
}
/**
* Read the value of the right bumper (RB) button on the controller.
*
* @return The state of the button.
* @deprecated Use {@link getRightBumperButton} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getRightBumper() {
return getRawButton(Button.kRightBumper.value);
}
/**
* Whether the left bumper (LB) was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
* @deprecated Use {@link getLeftBumperButtonPressed} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getLeftBumperPressed() {
return getRawButtonPressed(Button.kLeftBumper.value);
}
/**
* Whether the right bumper (RB) was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
* @deprecated Use {@link getRightBumperButtonPressed} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getRightBumperPressed() {
return getRawButtonPressed(Button.kRightBumper.value);
}
/**
* Whether the left bumper (LB) was released since the last check.
*
* @return Whether the button was released since the last check.
* @deprecated Use {@link getLeftBumperButtonReleased} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getLeftBumperReleased() {
return getRawButtonReleased(Button.kLeftBumper.value);
}
/**
* Whether the right bumper (RB) was released since the last check.
*
* @return Whether the button was released since the last check.
* @deprecated Use {@link getRightBumperButtonReleased} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public boolean getRightBumperReleased() {
return getRawButtonReleased(Button.kRightBumper.value);
}
}

View File

@@ -0,0 +1,229 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_hids.py. DO NOT MODIFY
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.wpilibj.PS4Controller;
/** Class to control a simulated PS4 controller. */
public class PS4ControllerSim extends GenericHIDSim {
/**
* Constructs from a PS4Controller object.
*
* @param joystick controller to simulate
*/
@SuppressWarnings("this-escape")
public PS4ControllerSim(PS4Controller joystick) {
super(joystick);
setAxisCount(6);
setButtonCount(14);
setPOVCount(1);
}
/**
* Constructs from a joystick port number.
*
* @param port port number
*/
@SuppressWarnings("this-escape")
public PS4ControllerSim(int port) {
super(port);
setAxisCount(6);
setButtonCount(14);
setPOVCount(1);
}
/**
* Change the left X value of the controller's joystick.
*
* @param value the new value
*/
public void setLeftX(double value) {
setRawAxis(PS4Controller.Axis.kLeftX.value, value);
}
/**
* Change the left Y value of the controller's joystick.
*
* @param value the new value
*/
public void setLeftY(double value) {
setRawAxis(PS4Controller.Axis.kLeftY.value, value);
}
/**
* Change the right X value of the controller's joystick.
*
* @param value the new value
*/
public void setRightX(double value) {
setRawAxis(PS4Controller.Axis.kRightX.value, value);
}
/**
* Change the right Y value of the controller's joystick.
*
* @param value the new value
*/
public void setRightY(double value) {
setRawAxis(PS4Controller.Axis.kRightY.value, value);
}
/**
* Change the value of the left trigger 2 axis on the controller.
*
* @param value the new value
*/
public void setL2Axis(double value) {
setRawAxis(PS4Controller.Axis.kL2.value, value);
}
/**
* Change the value of the right trigger 2 axis on the controller.
*
* @param value the new value
*/
public void setR2Axis(double value) {
setRawAxis(PS4Controller.Axis.kR2.value, value);
}
/**
* Change the value of the square button on the controller.
*
* @param value the new value
*/
public void setSquareButton(boolean value) {
setRawButton(PS4Controller.Button.kSquare.value, value);
}
/**
* Change the value of the cross button on the controller.
*
* @param value the new value
*/
public void setCrossButton(boolean value) {
setRawButton(PS4Controller.Button.kCross.value, value);
}
/**
* Change the value of the circle button on the controller.
*
* @param value the new value
*/
public void setCircleButton(boolean value) {
setRawButton(PS4Controller.Button.kCircle.value, value);
}
/**
* Change the value of the triangle button on the controller.
*
* @param value the new value
*/
public void setTriangleButton(boolean value) {
setRawButton(PS4Controller.Button.kTriangle.value, value);
}
/**
* Change the value of the left trigger 1 button on the controller.
*
* @param value the new value
*/
public void setL1Button(boolean value) {
setRawButton(PS4Controller.Button.kL1.value, value);
}
/**
* Change the value of the right trigger 1 button on the controller.
*
* @param value the new value
*/
public void setR1Button(boolean value) {
setRawButton(PS4Controller.Button.kR1.value, value);
}
/**
* Change the value of the left trigger 2 button on the controller.
*
* @param value the new value
*/
public void setL2Button(boolean value) {
setRawButton(PS4Controller.Button.kL2.value, value);
}
/**
* Change the value of the right trigger 2 button on the controller.
*
* @param value the new value
*/
public void setR2Button(boolean value) {
setRawButton(PS4Controller.Button.kR2.value, value);
}
/**
* Change the value of the share button on the controller.
*
* @param value the new value
*/
public void setShareButton(boolean value) {
setRawButton(PS4Controller.Button.kShare.value, value);
}
/**
* Change the value of the options button on the controller.
*
* @param value the new value
*/
public void setOptionsButton(boolean value) {
setRawButton(PS4Controller.Button.kOptions.value, value);
}
/**
* Change the value of the L3 (left stick) button on the controller.
*
* @param value the new value
*/
public void setL3Button(boolean value) {
setRawButton(PS4Controller.Button.kL3.value, value);
}
/**
* Change the value of the R3 (right stick) button on the controller.
*
* @param value the new value
*/
public void setR3Button(boolean value) {
setRawButton(PS4Controller.Button.kR3.value, value);
}
/**
* Change the value of the PlayStation button on the controller.
*
* @param value the new value
*/
public void setPSButton(boolean value) {
setRawButton(PS4Controller.Button.kPS.value, value);
}
/**
* Change the value of the touchpad button on the controller.
*
* @param value the new value
*/
public void setTouchpadButton(boolean value) {
setRawButton(PS4Controller.Button.kTouchpad.value, value);
}
/**
* Change the value of the touchpad button on the controller.
*
* @param value the new value
* @deprecated Use {@link setTouchpadButton} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public void setTouchpad(boolean value) {
setRawButton(PS4Controller.Button.kTouchpad.value, value);
}
}

View File

@@ -0,0 +1,229 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_hids.py. DO NOT MODIFY
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.wpilibj.PS5Controller;
/** Class to control a simulated PS5 controller. */
public class PS5ControllerSim extends GenericHIDSim {
/**
* Constructs from a PS5Controller object.
*
* @param joystick controller to simulate
*/
@SuppressWarnings("this-escape")
public PS5ControllerSim(PS5Controller joystick) {
super(joystick);
setAxisCount(6);
setButtonCount(14);
setPOVCount(1);
}
/**
* Constructs from a joystick port number.
*
* @param port port number
*/
@SuppressWarnings("this-escape")
public PS5ControllerSim(int port) {
super(port);
setAxisCount(6);
setButtonCount(14);
setPOVCount(1);
}
/**
* Change the left X value of the controller's joystick.
*
* @param value the new value
*/
public void setLeftX(double value) {
setRawAxis(PS5Controller.Axis.kLeftX.value, value);
}
/**
* Change the left Y value of the controller's joystick.
*
* @param value the new value
*/
public void setLeftY(double value) {
setRawAxis(PS5Controller.Axis.kLeftY.value, value);
}
/**
* Change the right X value of the controller's joystick.
*
* @param value the new value
*/
public void setRightX(double value) {
setRawAxis(PS5Controller.Axis.kRightX.value, value);
}
/**
* Change the right Y value of the controller's joystick.
*
* @param value the new value
*/
public void setRightY(double value) {
setRawAxis(PS5Controller.Axis.kRightY.value, value);
}
/**
* Change the value of the left trigger 2 axis on the controller.
*
* @param value the new value
*/
public void setL2Axis(double value) {
setRawAxis(PS5Controller.Axis.kL2.value, value);
}
/**
* Change the value of the right trigger 2 axis on the controller.
*
* @param value the new value
*/
public void setR2Axis(double value) {
setRawAxis(PS5Controller.Axis.kR2.value, value);
}
/**
* Change the value of the square button on the controller.
*
* @param value the new value
*/
public void setSquareButton(boolean value) {
setRawButton(PS5Controller.Button.kSquare.value, value);
}
/**
* Change the value of the cross button on the controller.
*
* @param value the new value
*/
public void setCrossButton(boolean value) {
setRawButton(PS5Controller.Button.kCross.value, value);
}
/**
* Change the value of the circle button on the controller.
*
* @param value the new value
*/
public void setCircleButton(boolean value) {
setRawButton(PS5Controller.Button.kCircle.value, value);
}
/**
* Change the value of the triangle button on the controller.
*
* @param value the new value
*/
public void setTriangleButton(boolean value) {
setRawButton(PS5Controller.Button.kTriangle.value, value);
}
/**
* Change the value of the left trigger 1 button on the controller.
*
* @param value the new value
*/
public void setL1Button(boolean value) {
setRawButton(PS5Controller.Button.kL1.value, value);
}
/**
* Change the value of the right trigger 1 button on the controller.
*
* @param value the new value
*/
public void setR1Button(boolean value) {
setRawButton(PS5Controller.Button.kR1.value, value);
}
/**
* Change the value of the left trigger 2 button on the controller.
*
* @param value the new value
*/
public void setL2Button(boolean value) {
setRawButton(PS5Controller.Button.kL2.value, value);
}
/**
* Change the value of the right trigger 2 button on the controller.
*
* @param value the new value
*/
public void setR2Button(boolean value) {
setRawButton(PS5Controller.Button.kR2.value, value);
}
/**
* Change the value of the create button on the controller.
*
* @param value the new value
*/
public void setCreateButton(boolean value) {
setRawButton(PS5Controller.Button.kCreate.value, value);
}
/**
* Change the value of the options button on the controller.
*
* @param value the new value
*/
public void setOptionsButton(boolean value) {
setRawButton(PS5Controller.Button.kOptions.value, value);
}
/**
* Change the value of the L3 (left stick) button on the controller.
*
* @param value the new value
*/
public void setL3Button(boolean value) {
setRawButton(PS5Controller.Button.kL3.value, value);
}
/**
* Change the value of the R3 (right stick) button on the controller.
*
* @param value the new value
*/
public void setR3Button(boolean value) {
setRawButton(PS5Controller.Button.kR3.value, value);
}
/**
* Change the value of the PlayStation button on the controller.
*
* @param value the new value
*/
public void setPSButton(boolean value) {
setRawButton(PS5Controller.Button.kPS.value, value);
}
/**
* Change the value of the touchpad button on the controller.
*
* @param value the new value
*/
public void setTouchpadButton(boolean value) {
setRawButton(PS5Controller.Button.kTouchpad.value, value);
}
/**
* Change the value of the touchpad button on the controller.
*
* @param value the new value
* @deprecated Use {@link setTouchpadButton} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public void setTouchpad(boolean value) {
setRawButton(PS5Controller.Button.kTouchpad.value, value);
}
}

View File

@@ -0,0 +1,209 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_hids.py. DO NOT MODIFY
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.wpilibj.StadiaController;
/** Class to control a simulated Stadia controller. */
public class StadiaControllerSim extends GenericHIDSim {
/**
* Constructs from a StadiaController object.
*
* @param joystick controller to simulate
*/
@SuppressWarnings("this-escape")
public StadiaControllerSim(StadiaController joystick) {
super(joystick);
setAxisCount(4);
setButtonCount(15);
setPOVCount(1);
}
/**
* Constructs from a joystick port number.
*
* @param port port number
*/
@SuppressWarnings("this-escape")
public StadiaControllerSim(int port) {
super(port);
setAxisCount(4);
setButtonCount(15);
setPOVCount(1);
}
/**
* Change the left X value of the controller's joystick.
*
* @param value the new value
*/
public void setLeftX(double value) {
setRawAxis(StadiaController.Axis.kLeftX.value, value);
}
/**
* Change the right X value of the controller's joystick.
*
* @param value the new value
*/
public void setRightX(double value) {
setRawAxis(StadiaController.Axis.kRightX.value, value);
}
/**
* Change the left Y value of the controller's joystick.
*
* @param value the new value
*/
public void setLeftY(double value) {
setRawAxis(StadiaController.Axis.kLeftY.value, value);
}
/**
* Change the right Y value of the controller's joystick.
*
* @param value the new value
*/
public void setRightY(double value) {
setRawAxis(StadiaController.Axis.kRightY.value, value);
}
/**
* Change the value of the A button on the controller.
*
* @param value the new value
*/
public void setAButton(boolean value) {
setRawButton(StadiaController.Button.kA.value, value);
}
/**
* Change the value of the B button on the controller.
*
* @param value the new value
*/
public void setBButton(boolean value) {
setRawButton(StadiaController.Button.kB.value, value);
}
/**
* Change the value of the X button on the controller.
*
* @param value the new value
*/
public void setXButton(boolean value) {
setRawButton(StadiaController.Button.kX.value, value);
}
/**
* Change the value of the Y button on the controller.
*
* @param value the new value
*/
public void setYButton(boolean value) {
setRawButton(StadiaController.Button.kY.value, value);
}
/**
* Change the value of the left bumper button on the controller.
*
* @param value the new value
*/
public void setLeftBumperButton(boolean value) {
setRawButton(StadiaController.Button.kLeftBumper.value, value);
}
/**
* Change the value of the right bumper button on the controller.
*
* @param value the new value
*/
public void setRightBumperButton(boolean value) {
setRawButton(StadiaController.Button.kRightBumper.value, value);
}
/**
* Change the value of the left stick button on the controller.
*
* @param value the new value
*/
public void setLeftStickButton(boolean value) {
setRawButton(StadiaController.Button.kLeftStick.value, value);
}
/**
* Change the value of the right stick button on the controller.
*
* @param value the new value
*/
public void setRightStickButton(boolean value) {
setRawButton(StadiaController.Button.kRightStick.value, value);
}
/**
* Change the value of the ellipses button on the controller.
*
* @param value the new value
*/
public void setEllipsesButton(boolean value) {
setRawButton(StadiaController.Button.kEllipses.value, value);
}
/**
* Change the value of the hamburger button on the controller.
*
* @param value the new value
*/
public void setHamburgerButton(boolean value) {
setRawButton(StadiaController.Button.kHamburger.value, value);
}
/**
* Change the value of the stadia button on the controller.
*
* @param value the new value
*/
public void setStadiaButton(boolean value) {
setRawButton(StadiaController.Button.kStadia.value, value);
}
/**
* Change the value of the right trigger button on the controller.
*
* @param value the new value
*/
public void setRightTriggerButton(boolean value) {
setRawButton(StadiaController.Button.kRightTrigger.value, value);
}
/**
* Change the value of the left trigger button on the controller.
*
* @param value the new value
*/
public void setLeftTriggerButton(boolean value) {
setRawButton(StadiaController.Button.kLeftTrigger.value, value);
}
/**
* Change the value of the google button on the controller.
*
* @param value the new value
*/
public void setGoogleButton(boolean value) {
setRawButton(StadiaController.Button.kGoogle.value, value);
}
/**
* Change the value of the frame button on the controller.
*
* @param value the new value
*/
public void setFrameButton(boolean value) {
setRawButton(StadiaController.Button.kFrame.value, value);
}
}

View File

@@ -0,0 +1,204 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_hids.py. DO NOT MODIFY
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.wpilibj.XboxController;
/** Class to control a simulated Xbox controller. */
public class XboxControllerSim extends GenericHIDSim {
/**
* Constructs from a XboxController object.
*
* @param joystick controller to simulate
*/
@SuppressWarnings("this-escape")
public XboxControllerSim(XboxController joystick) {
super(joystick);
setAxisCount(6);
setButtonCount(10);
setPOVCount(1);
}
/**
* Constructs from a joystick port number.
*
* @param port port number
*/
@SuppressWarnings("this-escape")
public XboxControllerSim(int port) {
super(port);
setAxisCount(6);
setButtonCount(10);
setPOVCount(1);
}
/**
* Change the left X value of the controller's joystick.
*
* @param value the new value
*/
public void setLeftX(double value) {
setRawAxis(XboxController.Axis.kLeftX.value, value);
}
/**
* Change the right X value of the controller's joystick.
*
* @param value the new value
*/
public void setRightX(double value) {
setRawAxis(XboxController.Axis.kRightX.value, value);
}
/**
* Change the left Y value of the controller's joystick.
*
* @param value the new value
*/
public void setLeftY(double value) {
setRawAxis(XboxController.Axis.kLeftY.value, value);
}
/**
* Change the right Y value of the controller's joystick.
*
* @param value the new value
*/
public void setRightY(double value) {
setRawAxis(XboxController.Axis.kRightY.value, value);
}
/**
* Change the value of the left trigger axis on the controller.
*
* @param value the new value
*/
public void setLeftTriggerAxis(double value) {
setRawAxis(XboxController.Axis.kLeftTrigger.value, value);
}
/**
* Change the value of the right trigger axis on the controller.
*
* @param value the new value
*/
public void setRightTriggerAxis(double value) {
setRawAxis(XboxController.Axis.kRightTrigger.value, value);
}
/**
* Change the value of the A button on the controller.
*
* @param value the new value
*/
public void setAButton(boolean value) {
setRawButton(XboxController.Button.kA.value, value);
}
/**
* Change the value of the B button on the controller.
*
* @param value the new value
*/
public void setBButton(boolean value) {
setRawButton(XboxController.Button.kB.value, value);
}
/**
* Change the value of the X button on the controller.
*
* @param value the new value
*/
public void setXButton(boolean value) {
setRawButton(XboxController.Button.kX.value, value);
}
/**
* Change the value of the Y button on the controller.
*
* @param value the new value
*/
public void setYButton(boolean value) {
setRawButton(XboxController.Button.kY.value, value);
}
/**
* Change the value of the left bumper button on the controller.
*
* @param value the new value
*/
public void setLeftBumperButton(boolean value) {
setRawButton(XboxController.Button.kLeftBumper.value, value);
}
/**
* Change the value of the right bumper button on the controller.
*
* @param value the new value
*/
public void setRightBumperButton(boolean value) {
setRawButton(XboxController.Button.kRightBumper.value, value);
}
/**
* Change the value of the back button on the controller.
*
* @param value the new value
*/
public void setBackButton(boolean value) {
setRawButton(XboxController.Button.kBack.value, value);
}
/**
* Change the value of the start button on the controller.
*
* @param value the new value
*/
public void setStartButton(boolean value) {
setRawButton(XboxController.Button.kStart.value, value);
}
/**
* Change the value of the left stick button on the controller.
*
* @param value the new value
*/
public void setLeftStickButton(boolean value) {
setRawButton(XboxController.Button.kLeftStick.value, value);
}
/**
* Change the value of the right stick button on the controller.
*
* @param value the new value
*/
public void setRightStickButton(boolean value) {
setRawButton(XboxController.Button.kRightStick.value, value);
}
/**
* Change the value of the left bumper on the joystick.
*
* @param state the new value
* @deprecated Use {@link setLeftBumperButton} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public void setLeftBumper(boolean state) {
setRawButton(XboxController.Button.kLeftBumper.value, state);
}
/**
* Change the value of the right bumper on the joystick.
*
* @param state the new value
* @deprecated Use {@link setRightBumperButton} instead
*/
@Deprecated(since = "2025", forRemoval = true)
public void setRightBumper(boolean state) {
setRawButton(XboxController.Button.kRightBumper.value, state);
}
}