[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

@@ -1,389 +0,0 @@
// 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.
package edu.wpi.first.wpilibj2.command.button;
import edu.wpi.first.wpilibj.PS4Controller;
import edu.wpi.first.wpilibj.event.EventLoop;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
/**
* A version of {@link PS4Controller} with {@link Trigger} factories for command-based.
*
* @see PS4Controller
*/
@SuppressWarnings("MethodName")
public class CommandPS4Controller extends CommandGenericHID {
private final PS4Controller m_hid;
/**
* Construct an instance of a device.
*
* @param port The port index on the Driver Station that the device is plugged into.
*/
public CommandPS4Controller(int port) {
super(port);
m_hid = new PS4Controller(port);
}
/**
* Get the underlying GenericHID object.
*
* @return the wrapped GenericHID object
*/
@Override
public PS4Controller getHID() {
return m_hid;
}
/**
* Constructs an event instance around the L2 button's digital signal.
*
* @return an event instance representing the L2 button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger L2() {
return L2(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the L2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the L2 button's digital signal attached to the given
* loop.
*/
public Trigger L2(EventLoop loop) {
return m_hid.L2(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the R2 button's digital signal.
*
* @return an event instance representing the R2 button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger R2() {
return R2(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the R2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the R2 button's digital signal attached to the given
* loop.
*/
public Trigger R2(EventLoop loop) {
return m_hid.R2(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the L1 button's digital signal.
*
* @return an event instance representing the L1 button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger L1() {
return L1(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the L1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the L1 button's digital signal attached to the given
* loop.
*/
public Trigger L1(EventLoop loop) {
return m_hid.L1(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the R1 button's digital signal.
*
* @return an event instance representing the R1 button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger R1() {
return R1(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the R1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the R1 button's digital signal attached to the given
* loop.
*/
public Trigger R1(EventLoop loop) {
return m_hid.R1(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the L3 button's digital signal.
*
* @return an event instance representing the L3 button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger L3() {
return L3(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the L3 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the L3 button's digital signal attached to the given
* loop.
*/
public Trigger L3(EventLoop loop) {
return m_hid.L3(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the R3 button's digital signal.
*
* @return an event instance representing the R3 button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger R3() {
return R3(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the R3 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the R3 button's digital signal attached to the given
* loop.
*/
public Trigger R3(EventLoop loop) {
return m_hid.R3(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the square button's digital signal.
*
* @return an event instance representing the square button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger square() {
return square(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger square(EventLoop loop) {
return m_hid.square(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the cross button's digital signal.
*
* @return an event instance representing the cross button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger cross() {
return cross(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger cross(EventLoop loop) {
return m_hid.cross(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the triangle button's digital signal.
*
* @return an event instance representing the triangle button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger triangle() {
return triangle(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger triangle(EventLoop loop) {
return m_hid.triangle(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the circle button's digital signal.
*
* @return an event instance representing the circle button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger circle() {
return circle(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger circle(EventLoop loop) {
return m_hid.circle(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the share button's digital signal.
*
* @return an event instance representing the share button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger share() {
return share(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger share(EventLoop loop) {
return m_hid.share(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the PS button's digital signal.
*
* @return an event instance representing the PS button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger PS() {
return PS(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the PS button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the PS button's digital signal attached to the given
* loop.
*/
public Trigger PS(EventLoop loop) {
return m_hid.PS(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the options button's digital signal.
*
* @return an event instance representing the options button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger options() {
return options(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger options(EventLoop loop) {
return m_hid.options(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the touchpad's digital signal.
*
* @return an event instance representing the touchpad's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger touchpad() {
return touchpad(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the touchpad's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the touchpad's digital signal attached to the given
* loop.
*/
public Trigger touchpad(EventLoop loop) {
return m_hid.touchpad(loop).castTo(Trigger::new);
}
/**
* Get the X axis value of left side of the controller.
*
* @return the axis value.
*/
public double getLeftX() {
return m_hid.getLeftX();
}
/**
* Get the X axis value of right side of the controller.
*
* @return the axis value.
*/
public double getRightX() {
return m_hid.getRightX();
}
/**
* Get the Y axis value of left side of the controller.
*
* @return the axis value.
*/
public double getLeftY() {
return m_hid.getLeftY();
}
/**
* Get the Y axis value of right side of the controller.
*
* @return the axis value.
*/
public double getRightY() {
return m_hid.getRightY();
}
/**
* Get the L2 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 m_hid.getL2Axis();
}
/**
* Get the R2 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 m_hid.getR2Axis();
}
}

View File

@@ -1,389 +0,0 @@
// 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.
package edu.wpi.first.wpilibj2.command.button;
import edu.wpi.first.wpilibj.PS5Controller;
import edu.wpi.first.wpilibj.event.EventLoop;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
/**
* A version of {@link PS5Controller} with {@link Trigger} factories for command-based.
*
* @see PS5Controller
*/
@SuppressWarnings("MethodName")
public class CommandPS5Controller extends CommandGenericHID {
private final PS5Controller m_hid;
/**
* Construct an instance of a device.
*
* @param port The port index on the Driver Station that the device is plugged into.
*/
public CommandPS5Controller(int port) {
super(port);
m_hid = new PS5Controller(port);
}
/**
* Get the underlying GenericHID object.
*
* @return the wrapped GenericHID object
*/
@Override
public PS5Controller getHID() {
return m_hid;
}
/**
* Constructs an event instance around the L2 button's digital signal.
*
* @return an event instance representing the L2 button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger L2() {
return L2(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the L2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the L2 button's digital signal attached to the given
* loop.
*/
public Trigger L2(EventLoop loop) {
return m_hid.L2(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the R2 button's digital signal.
*
* @return an event instance representing the R2 button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger R2() {
return R2(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the R2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the R2 button's digital signal attached to the given
* loop.
*/
public Trigger R2(EventLoop loop) {
return m_hid.R2(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the L1 button's digital signal.
*
* @return an event instance representing the L1 button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger L1() {
return L1(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the L1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the L1 button's digital signal attached to the given
* loop.
*/
public Trigger L1(EventLoop loop) {
return m_hid.L1(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the R1 button's digital signal.
*
* @return an event instance representing the R1 button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger R1() {
return R1(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the R1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the R1 button's digital signal attached to the given
* loop.
*/
public Trigger R1(EventLoop loop) {
return m_hid.R1(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the L3 button's digital signal.
*
* @return an event instance representing the L3 button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger L3() {
return L3(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the L3 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the L3 button's digital signal attached to the given
* loop.
*/
public Trigger L3(EventLoop loop) {
return m_hid.L3(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the R3 button's digital signal.
*
* @return an event instance representing the R3 button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger R3() {
return R3(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the R3 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the R3 button's digital signal attached to the given
* loop.
*/
public Trigger R3(EventLoop loop) {
return m_hid.R3(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the square button's digital signal.
*
* @return an event instance representing the square button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger square() {
return square(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger square(EventLoop loop) {
return m_hid.square(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the cross button's digital signal.
*
* @return an event instance representing the cross button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger cross() {
return cross(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger cross(EventLoop loop) {
return m_hid.cross(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the triangle button's digital signal.
*
* @return an event instance representing the triangle button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger triangle() {
return triangle(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger triangle(EventLoop loop) {
return m_hid.triangle(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the circle button's digital signal.
*
* @return an event instance representing the circle button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger circle() {
return circle(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger circle(EventLoop loop) {
return m_hid.circle(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the create button's digital signal.
*
* @return an event instance representing the create button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger create() {
return create(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger create(EventLoop loop) {
return m_hid.create(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the PS button's digital signal.
*
* @return an event instance representing the PS button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger PS() {
return PS(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the PS button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the PS button's digital signal attached to the given
* loop.
*/
public Trigger PS(EventLoop loop) {
return m_hid.PS(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the options button's digital signal.
*
* @return an event instance representing the options button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger options() {
return options(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger options(EventLoop loop) {
return m_hid.options(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the touchpad's digital signal.
*
* @return an event instance representing the touchpad's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger touchpad() {
return touchpad(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the touchpad's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the touchpad's digital signal attached to the given
* loop.
*/
public Trigger touchpad(EventLoop loop) {
return m_hid.touchpad(loop).castTo(Trigger::new);
}
/**
* Get the X axis value of left side of the controller.
*
* @return the axis value.
*/
public double getLeftX() {
return m_hid.getLeftX();
}
/**
* Get the X axis value of right side of the controller.
*
* @return the axis value.
*/
public double getRightX() {
return m_hid.getRightX();
}
/**
* Get the Y axis value of left side of the controller.
*
* @return the axis value.
*/
public double getLeftY() {
return m_hid.getLeftY();
}
/**
* Get the Y axis value of right side of the controller.
*
* @return the axis value.
*/
public double getRightY() {
return m_hid.getRightY();
}
/**
* Get the L2 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 m_hid.getL2Axis();
}
/**
* Get the R2 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 m_hid.getR2Axis();
}
}

View File

@@ -1,405 +0,0 @@
// 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.
package edu.wpi.first.wpilibj2.command.button;
import edu.wpi.first.wpilibj.StadiaController;
import edu.wpi.first.wpilibj.event.EventLoop;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
/**
* A version of {@link StadiaController} with {@link Trigger} factories for command-based.
*
* @see StadiaController
*/
@SuppressWarnings("MethodName")
public class CommandStadiaController extends CommandGenericHID {
private final StadiaController m_hid;
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandStadiaController(int port) {
super(port);
m_hid = new StadiaController(port);
}
/**
* Get the underlying GenericHID object.
*
* @return the wrapped GenericHID object
*/
@Override
public StadiaController getHID() {
return m_hid;
}
/**
* Constructs an event instance around the left bumper's digital signal.
*
* @return an event instance representing the left bumper's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #leftBumper(EventLoop)
*/
public Trigger leftBumper() {
return leftBumper(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the left bumper's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right bumper's digital signal attached to the given
* loop.
*/
public Trigger leftBumper(EventLoop loop) {
return m_hid.leftBumper(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the right bumper's digital signal.
*
* @return an event instance representing the right bumper's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #rightBumper(EventLoop)
*/
public Trigger rightBumper() {
return rightBumper(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the right bumper's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left bumper's digital signal attached to the given
* loop.
*/
public Trigger rightBumper(EventLoop loop) {
return m_hid.rightBumper(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the left stick button's digital signal.
*
* @return an event instance representing the left stick button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #leftStick(EventLoop)
*/
public Trigger leftStick() {
return leftStick(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger leftStick(EventLoop loop) {
return m_hid.leftStick(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the right stick button's digital signal.
*
* @return an event instance representing the right stick button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #rightStick(EventLoop)
*/
public Trigger rightStick() {
return rightStick(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger rightStick(EventLoop loop) {
return m_hid.rightStick(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the right trigger button's digital signal.
*
* @return an event instance representing the right trigger button's digital signal attached to
* the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #rightTrigger(EventLoop)
*/
public Trigger rightTrigger() {
return rightTrigger(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger rightTrigger(EventLoop loop) {
return m_hid.rightTrigger(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the left trigger button's digital signal.
*
* @return an event instance representing the left trigger button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #leftTrigger(EventLoop)
*/
public Trigger leftTrigger() {
return leftTrigger(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger leftTrigger(EventLoop loop) {
return m_hid.leftTrigger(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the A button's digital signal.
*
* @return an event instance representing the A button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #a(EventLoop)
*/
public Trigger a() {
return a(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger a(EventLoop loop) {
return m_hid.a(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the B button's digital signal.
*
* @return an event instance representing the B button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #b(EventLoop)
*/
public Trigger b() {
return b(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger b(EventLoop loop) {
return m_hid.b(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the X button's digital signal.
*
* @return an event instance representing the X button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #x(EventLoop)
*/
public Trigger x() {
return x(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger x(EventLoop loop) {
return m_hid.x(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the Y button's digital signal.
*
* @return an event instance representing the Y button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #y(EventLoop)
*/
public Trigger y() {
return y(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger y(EventLoop loop) {
return m_hid.y(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the ellipses button's digital signal.
*
* @return an event instance representing the ellipses button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #ellipses(EventLoop)
*/
public Trigger ellipses() {
return ellipses(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger ellipses(EventLoop loop) {
return m_hid.ellipses(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the stadia button's digital signal.
*
* @return an event instance representing the stadia button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #stadia(EventLoop)
*/
public Trigger stadia() {
return stadia(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger stadia(EventLoop loop) {
return m_hid.stadia(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the google button's digital signal.
*
* @return an event instance representing the google button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #google(EventLoop)
*/
public Trigger google() {
return google(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger google(EventLoop loop) {
return m_hid.google(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the frame button's digital signal.
*
* @return an event instance representing the frame button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #frame(EventLoop)
*/
public Trigger frame() {
return frame(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger frame(EventLoop loop) {
return m_hid.frame(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the hamburger button's digital signal.
*
* @return an event instance representing the hamburger button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #hamburger(EventLoop)
*/
public Trigger hamburger() {
return hamburger(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger hamburger(EventLoop loop) {
return m_hid.hamburger(loop).castTo(Trigger::new);
}
/**
* Get the X axis value of left side of the controller.
*
* @return The axis value.
*/
public double getLeftX() {
return m_hid.getLeftX();
}
/**
* Get the X axis value of right side of the controller.
*
* @return The axis value.
*/
public double getRightX() {
return m_hid.getRightX();
}
/**
* Get the Y axis value of left side of the controller.
*
* @return The axis value.
*/
public double getLeftY() {
return m_hid.getLeftY();
}
/**
* Get the Y axis value of right side of the controller.
*
* @return The axis value.
*/
public double getRightY() {
return m_hid.getRightY();
}
}

View File

@@ -1,393 +0,0 @@
// 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.
package edu.wpi.first.wpilibj2.command.button;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.event.EventLoop;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
/**
* A version of {@link XboxController} with {@link Trigger} factories for command-based.
*
* @see XboxController
*/
@SuppressWarnings("MethodName")
public class CommandXboxController extends CommandGenericHID {
private final XboxController m_hid;
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandXboxController(int port) {
super(port);
m_hid = new XboxController(port);
}
/**
* Get the underlying GenericHID object.
*
* @return the wrapped GenericHID object
*/
@Override
public XboxController getHID() {
return m_hid;
}
/**
* Constructs an event instance around the left bumper's digital signal.
*
* @return an event instance representing the left bumper's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #leftBumper(EventLoop)
*/
public Trigger leftBumper() {
return leftBumper(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the left bumper's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right bumper's digital signal attached to the given
* loop.
*/
public Trigger leftBumper(EventLoop loop) {
return m_hid.leftBumper(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the right bumper's digital signal.
*
* @return an event instance representing the right bumper's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #rightBumper(EventLoop)
*/
public Trigger rightBumper() {
return rightBumper(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around the right bumper's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left bumper's digital signal attached to the given
* loop.
*/
public Trigger rightBumper(EventLoop loop) {
return m_hid.rightBumper(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the left stick button's digital signal.
*
* @return an event instance representing the left stick button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #leftStick(EventLoop)
*/
public Trigger leftStick() {
return leftStick(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger leftStick(EventLoop loop) {
return m_hid.leftStick(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the right stick button's digital signal.
*
* @return an event instance representing the right stick button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #rightStick(EventLoop)
*/
public Trigger rightStick() {
return rightStick(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger rightStick(EventLoop loop) {
return m_hid.rightStick(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the A button's digital signal.
*
* @return an event instance representing the A button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #a(EventLoop)
*/
public Trigger a() {
return a(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger a(EventLoop loop) {
return m_hid.a(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the B button's digital signal.
*
* @return an event instance representing the B button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #b(EventLoop)
*/
public Trigger b() {
return b(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger b(EventLoop loop) {
return m_hid.b(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the X button's digital signal.
*
* @return an event instance representing the X button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #x(EventLoop)
*/
public Trigger x() {
return x(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger x(EventLoop loop) {
return m_hid.x(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the Y button's digital signal.
*
* @return an event instance representing the Y button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #y(EventLoop)
*/
public Trigger y() {
return y(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger y(EventLoop loop) {
return m_hid.y(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the start button's digital signal.
*
* @return an event instance representing the start button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #start(EventLoop)
*/
public Trigger start() {
return start(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger start(EventLoop loop) {
return m_hid.start(loop).castTo(Trigger::new);
}
/**
* Constructs an event instance around the back button's digital signal.
*
* @return an event instance representing the back button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #back(EventLoop)
*/
public Trigger back() {
return back(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 Trigger back(EventLoop loop) {
return m_hid.back(loop).castTo(Trigger::new);
}
/**
* Constructs a Trigger 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 Trigger} 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 Trigger to.
* @return a Trigger instance that is true when the left trigger's axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger leftTrigger(double threshold, EventLoop loop) {
return m_hid.leftTrigger(threshold, loop).castTo(Trigger::new);
}
/**
* Constructs a Trigger 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 Trigger} to be true. This value
* should be in the range [0, 1] where 0 is the unpressed state of the axis.
* @return a Trigger instance that is true when the left trigger's axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger leftTrigger(double threshold) {
return leftTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the axis value of the left trigger. The returned trigger
* will be true when the axis value is greater than 0.5.
*
* @return a Trigger instance that is true when the left trigger's axis exceeds 0.5, attached to
* the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger leftTrigger() {
return leftTrigger(0.5);
}
/**
* Constructs a Trigger 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 Trigger} 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 Trigger to.
* @return a Trigger instance that is true when the right trigger's axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger rightTrigger(double threshold, EventLoop loop) {
return m_hid.rightTrigger(threshold, loop).castTo(Trigger::new);
}
/**
* Constructs a Trigger 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 Trigger} to be true. This value
* should be in the range [0, 1] where 0 is the unpressed state of the axis.
* @return a Trigger instance that is true when the right trigger's axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger rightTrigger(double threshold) {
return rightTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the axis value of the right trigger. The returned trigger
* will be true when the axis value is greater than 0.5.
*
* @return a Trigger instance that is true when the right trigger's axis exceeds 0.5, attached to
* the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
*/
public Trigger rightTrigger() {
return rightTrigger(0.5);
}
/**
* Get the X axis value of left side of the controller.
*
* @return The axis value.
*/
public double getLeftX() {
return m_hid.getLeftX();
}
/**
* Get the X axis value of right side of the controller.
*
* @return The axis value.
*/
public double getRightX() {
return m_hid.getRightX();
}
/**
* Get the Y axis value of left side of the controller.
*
* @return The axis value.
*/
public double getLeftY() {
return m_hid.getLeftY();
}
/**
* Get the Y axis value of right side of the controller.
*
* @return The axis value.
*/
public double getRightY() {
return m_hid.getRightY();
}
/**
* Get the left trigger (LT) 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 m_hid.getLeftTriggerAxis();
}
/**
* Get the right trigger (RT) 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 m_hid.getRightTriggerAxis();
}
}