SCRIPT Move subprojects

This commit is contained in:
PJ Reiniger
2025-11-07 19:55:36 -05:00
committed by Peter Johnson
parent 8cfc158790
commit a5492d30da
431 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,405 @@
// 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 ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY
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 controller.
*
* @param port The port index on the Driver Station that the controller 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 a Trigger instance around the square button's digital signal.
*
* @return a Trigger instance representing the square button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #square(EventLoop)
*/
public Trigger square() {
return square(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the square button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the square button's digital signal attached
* to the given loop.
*/
public Trigger square(EventLoop loop) {
return button(PS4Controller.Button.kSquare.value, loop);
}
/**
* Constructs a Trigger instance around the cross button's digital signal.
*
* @return a Trigger instance representing the cross button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #cross(EventLoop)
*/
public Trigger cross() {
return cross(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the cross button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the cross button's digital signal attached
* to the given loop.
*/
public Trigger cross(EventLoop loop) {
return button(PS4Controller.Button.kCross.value, loop);
}
/**
* Constructs a Trigger instance around the circle button's digital signal.
*
* @return a Trigger instance representing the circle button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #circle(EventLoop)
*/
public Trigger circle() {
return circle(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the circle button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the circle button's digital signal attached
* to the given loop.
*/
public Trigger circle(EventLoop loop) {
return button(PS4Controller.Button.kCircle.value, loop);
}
/**
* Constructs a Trigger instance around the triangle button's digital signal.
*
* @return a Trigger instance representing the triangle button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #triangle(EventLoop)
*/
public Trigger triangle() {
return triangle(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the triangle button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the triangle button's digital signal attached
* to the given loop.
*/
public Trigger triangle(EventLoop loop) {
return button(PS4Controller.Button.kTriangle.value, loop);
}
/**
* Constructs a Trigger instance around the left trigger 1 button's digital signal.
*
* @return a Trigger instance representing the left trigger 1 button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #L1(EventLoop)
*/
public Trigger L1() {
return L1(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the left trigger 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the left trigger 1 button's digital signal attached
* to the given loop.
*/
public Trigger L1(EventLoop loop) {
return button(PS4Controller.Button.kL1.value, loop);
}
/**
* Constructs a Trigger instance around the right trigger 1 button's digital signal.
*
* @return a Trigger instance representing the right trigger 1 button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #R1(EventLoop)
*/
public Trigger R1() {
return R1(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the right trigger 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the right trigger 1 button's digital signal attached
* to the given loop.
*/
public Trigger R1(EventLoop loop) {
return button(PS4Controller.Button.kR1.value, loop);
}
/**
* Constructs a Trigger instance around the left trigger 2 button's digital signal.
*
* @return a Trigger instance representing the left trigger 2 button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #L2(EventLoop)
*/
public Trigger L2() {
return L2(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the left trigger 2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the left trigger 2 button's digital signal attached
* to the given loop.
*/
public Trigger L2(EventLoop loop) {
return button(PS4Controller.Button.kL2.value, loop);
}
/**
* Constructs a Trigger instance around the right trigger 2 button's digital signal.
*
* @return a Trigger instance representing the right trigger 2 button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #R2(EventLoop)
*/
public Trigger R2() {
return R2(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the right trigger 2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the right trigger 2 button's digital signal attached
* to the given loop.
*/
public Trigger R2(EventLoop loop) {
return button(PS4Controller.Button.kR2.value, loop);
}
/**
* Constructs a Trigger instance around the share button's digital signal.
*
* @return a Trigger instance representing the share button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #share(EventLoop)
*/
public Trigger share() {
return share(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the share button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the share button's digital signal attached
* to the given loop.
*/
public Trigger share(EventLoop loop) {
return button(PS4Controller.Button.kShare.value, loop);
}
/**
* Constructs a Trigger instance around the options button's digital signal.
*
* @return a Trigger instance representing the options button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #options(EventLoop)
*/
public Trigger options() {
return options(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the options button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the options button's digital signal attached
* to the given loop.
*/
public Trigger options(EventLoop loop) {
return button(PS4Controller.Button.kOptions.value, loop);
}
/**
* Constructs a Trigger instance around the L3 (left stick) button's digital signal.
*
* @return a Trigger instance representing the L3 (left stick) button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #L3(EventLoop)
*/
public Trigger L3() {
return L3(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the L3 (left stick) button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the L3 (left stick) button's digital signal attached
* to the given loop.
*/
public Trigger L3(EventLoop loop) {
return button(PS4Controller.Button.kL3.value, loop);
}
/**
* Constructs a Trigger instance around the R3 (right stick) button's digital signal.
*
* @return a Trigger instance representing the R3 (right stick) button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #R3(EventLoop)
*/
public Trigger R3() {
return R3(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the R3 (right stick) button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the R3 (right stick) button's digital signal attached
* to the given loop.
*/
public Trigger R3(EventLoop loop) {
return button(PS4Controller.Button.kR3.value, loop);
}
/**
* Constructs a Trigger instance around the PlayStation button's digital signal.
*
* @return a Trigger instance representing the PlayStation button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #PS(EventLoop)
*/
public Trigger PS() {
return PS(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the PlayStation button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the PlayStation button's digital signal attached
* to the given loop.
*/
public Trigger PS(EventLoop loop) {
return button(PS4Controller.Button.kPS.value, loop);
}
/**
* Constructs a Trigger instance around the touchpad button's digital signal.
*
* @return a Trigger instance representing the touchpad button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #touchpad(EventLoop)
*/
public Trigger touchpad() {
return touchpad(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the touchpad button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the touchpad button's digital signal attached
* to the given loop.
*/
public Trigger touchpad(EventLoop loop) {
return button(PS4Controller.Button.kTouchpad.value, loop);
}
/**
* Get the X axis value of left side of the controller. Right is positive.
*
* @return The axis value.
*/
public double getLeftX() {
return m_hid.getLeftX();
}
/**
* Get the Y axis value of left side of the controller. Back is positive.
*
* @return The axis value.
*/
public double getLeftY() {
return m_hid.getLeftY();
}
/**
* Get the X axis value of right side of the controller. Right is positive.
*
* @return The axis value.
*/
public double getRightX() {
return m_hid.getRightX();
}
/**
* Get the Y axis value of right side of the controller. Back is positive.
*
* @return The axis value.
*/
public double getRightY() {
return m_hid.getRightY();
}
/**
* 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 m_hid.getL2Axis();
}
/**
* 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 m_hid.getR2Axis();
}
}

View File

@@ -0,0 +1,405 @@
// 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 ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY
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 controller.
*
* @param port The port index on the Driver Station that the controller 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 a Trigger instance around the square button's digital signal.
*
* @return a Trigger instance representing the square button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #square(EventLoop)
*/
public Trigger square() {
return square(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the square button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the square button's digital signal attached
* to the given loop.
*/
public Trigger square(EventLoop loop) {
return button(PS5Controller.Button.kSquare.value, loop);
}
/**
* Constructs a Trigger instance around the cross button's digital signal.
*
* @return a Trigger instance representing the cross button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #cross(EventLoop)
*/
public Trigger cross() {
return cross(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the cross button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the cross button's digital signal attached
* to the given loop.
*/
public Trigger cross(EventLoop loop) {
return button(PS5Controller.Button.kCross.value, loop);
}
/**
* Constructs a Trigger instance around the circle button's digital signal.
*
* @return a Trigger instance representing the circle button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #circle(EventLoop)
*/
public Trigger circle() {
return circle(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the circle button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the circle button's digital signal attached
* to the given loop.
*/
public Trigger circle(EventLoop loop) {
return button(PS5Controller.Button.kCircle.value, loop);
}
/**
* Constructs a Trigger instance around the triangle button's digital signal.
*
* @return a Trigger instance representing the triangle button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #triangle(EventLoop)
*/
public Trigger triangle() {
return triangle(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the triangle button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the triangle button's digital signal attached
* to the given loop.
*/
public Trigger triangle(EventLoop loop) {
return button(PS5Controller.Button.kTriangle.value, loop);
}
/**
* Constructs a Trigger instance around the left trigger 1 button's digital signal.
*
* @return a Trigger instance representing the left trigger 1 button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #L1(EventLoop)
*/
public Trigger L1() {
return L1(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the left trigger 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the left trigger 1 button's digital signal attached
* to the given loop.
*/
public Trigger L1(EventLoop loop) {
return button(PS5Controller.Button.kL1.value, loop);
}
/**
* Constructs a Trigger instance around the right trigger 1 button's digital signal.
*
* @return a Trigger instance representing the right trigger 1 button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #R1(EventLoop)
*/
public Trigger R1() {
return R1(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the right trigger 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the right trigger 1 button's digital signal attached
* to the given loop.
*/
public Trigger R1(EventLoop loop) {
return button(PS5Controller.Button.kR1.value, loop);
}
/**
* Constructs a Trigger instance around the left trigger 2 button's digital signal.
*
* @return a Trigger instance representing the left trigger 2 button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #L2(EventLoop)
*/
public Trigger L2() {
return L2(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the left trigger 2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the left trigger 2 button's digital signal attached
* to the given loop.
*/
public Trigger L2(EventLoop loop) {
return button(PS5Controller.Button.kL2.value, loop);
}
/**
* Constructs a Trigger instance around the right trigger 2 button's digital signal.
*
* @return a Trigger instance representing the right trigger 2 button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #R2(EventLoop)
*/
public Trigger R2() {
return R2(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the right trigger 2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the right trigger 2 button's digital signal attached
* to the given loop.
*/
public Trigger R2(EventLoop loop) {
return button(PS5Controller.Button.kR2.value, loop);
}
/**
* Constructs a Trigger instance around the create button's digital signal.
*
* @return a Trigger instance representing the create button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #create(EventLoop)
*/
public Trigger create() {
return create(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the create button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the create button's digital signal attached
* to the given loop.
*/
public Trigger create(EventLoop loop) {
return button(PS5Controller.Button.kCreate.value, loop);
}
/**
* Constructs a Trigger instance around the options button's digital signal.
*
* @return a Trigger instance representing the options button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #options(EventLoop)
*/
public Trigger options() {
return options(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the options button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the options button's digital signal attached
* to the given loop.
*/
public Trigger options(EventLoop loop) {
return button(PS5Controller.Button.kOptions.value, loop);
}
/**
* Constructs a Trigger instance around the L3 (left stick) button's digital signal.
*
* @return a Trigger instance representing the L3 (left stick) button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #L3(EventLoop)
*/
public Trigger L3() {
return L3(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the L3 (left stick) button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the L3 (left stick) button's digital signal attached
* to the given loop.
*/
public Trigger L3(EventLoop loop) {
return button(PS5Controller.Button.kL3.value, loop);
}
/**
* Constructs a Trigger instance around the R3 (right stick) button's digital signal.
*
* @return a Trigger instance representing the R3 (right stick) button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #R3(EventLoop)
*/
public Trigger R3() {
return R3(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the R3 (right stick) button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the R3 (right stick) button's digital signal attached
* to the given loop.
*/
public Trigger R3(EventLoop loop) {
return button(PS5Controller.Button.kR3.value, loop);
}
/**
* Constructs a Trigger instance around the PlayStation button's digital signal.
*
* @return a Trigger instance representing the PlayStation button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #PS(EventLoop)
*/
public Trigger PS() {
return PS(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the PlayStation button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the PlayStation button's digital signal attached
* to the given loop.
*/
public Trigger PS(EventLoop loop) {
return button(PS5Controller.Button.kPS.value, loop);
}
/**
* Constructs a Trigger instance around the touchpad button's digital signal.
*
* @return a Trigger instance representing the touchpad button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #touchpad(EventLoop)
*/
public Trigger touchpad() {
return touchpad(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the touchpad button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the touchpad button's digital signal attached
* to the given loop.
*/
public Trigger touchpad(EventLoop loop) {
return button(PS5Controller.Button.kTouchpad.value, loop);
}
/**
* Get the X axis value of left side of the controller. Right is positive.
*
* @return The axis value.
*/
public double getLeftX() {
return m_hid.getLeftX();
}
/**
* Get the Y axis value of left side of the controller. Back is positive.
*
* @return The axis value.
*/
public double getLeftY() {
return m_hid.getLeftY();
}
/**
* Get the X axis value of right side of the controller. Right is positive.
*
* @return The axis value.
*/
public double getRightX() {
return m_hid.getRightX();
}
/**
* Get the Y axis value of right side of the controller. Back is positive.
*
* @return The axis value.
*/
public double getRightY() {
return m_hid.getRightY();
}
/**
* 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 m_hid.getL2Axis();
}
/**
* 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 m_hid.getR2Axis();
}
}

View File

@@ -0,0 +1,407 @@
// 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 ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY
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 a Trigger instance around the A button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the A button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the A button's digital signal attached
* to the given loop.
*/
public Trigger a(EventLoop loop) {
return button(StadiaController.Button.kA.value, loop);
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the B button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the B button's digital signal attached
* to the given loop.
*/
public Trigger b(EventLoop loop) {
return button(StadiaController.Button.kB.value, loop);
}
/**
* Constructs a Trigger instance around the X button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the X button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the X button's digital signal attached
* to the given loop.
*/
public Trigger x(EventLoop loop) {
return button(StadiaController.Button.kX.value, loop);
}
/**
* Constructs a Trigger instance around the Y button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the Y button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Y button's digital signal attached
* to the given loop.
*/
public Trigger y(EventLoop loop) {
return button(StadiaController.Button.kY.value, loop);
}
/**
* Constructs a Trigger instance around the left bumper button's digital signal.
*
* @return a Trigger instance representing the left bumper button'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 a Trigger instance around the left bumper button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the left bumper button's digital signal attached
* to the given loop.
*/
public Trigger leftBumper(EventLoop loop) {
return button(StadiaController.Button.kLeftBumper.value, loop);
}
/**
* Constructs a Trigger instance around the right bumper button's digital signal.
*
* @return a Trigger instance representing the right bumper button'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 a Trigger instance around the right bumper button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the right bumper button's digital signal attached
* to the given loop.
*/
public Trigger rightBumper(EventLoop loop) {
return button(StadiaController.Button.kRightBumper.value, loop);
}
/**
* Constructs a Trigger instance around the left stick button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the left stick button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the left stick button's digital signal attached
* to the given loop.
*/
public Trigger leftStick(EventLoop loop) {
return button(StadiaController.Button.kLeftStick.value, loop);
}
/**
* Constructs a Trigger instance around the right stick button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the right stick button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the right stick button's digital signal attached
* to the given loop.
*/
public Trigger rightStick(EventLoop loop) {
return button(StadiaController.Button.kRightStick.value, loop);
}
/**
* Constructs a Trigger instance around the ellipses button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the ellipses button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the ellipses button's digital signal attached
* to the given loop.
*/
public Trigger ellipses(EventLoop loop) {
return button(StadiaController.Button.kEllipses.value, loop);
}
/**
* Constructs a Trigger instance around the hamburger button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the hamburger button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the hamburger button's digital signal attached
* to the given loop.
*/
public Trigger hamburger(EventLoop loop) {
return button(StadiaController.Button.kHamburger.value, loop);
}
/**
* Constructs a Trigger instance around the stadia button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the stadia button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the stadia button's digital signal attached
* to the given loop.
*/
public Trigger stadia(EventLoop loop) {
return button(StadiaController.Button.kStadia.value, loop);
}
/**
* Constructs a Trigger instance around the right trigger button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the right trigger button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the right trigger button's digital signal attached
* to the given loop.
*/
public Trigger rightTrigger(EventLoop loop) {
return button(StadiaController.Button.kRightTrigger.value, loop);
}
/**
* Constructs a Trigger instance around the left trigger button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the left trigger button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the left trigger button's digital signal attached
* to the given loop.
*/
public Trigger leftTrigger(EventLoop loop) {
return button(StadiaController.Button.kLeftTrigger.value, loop);
}
/**
* Constructs a Trigger instance around the google button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the google button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the google button's digital signal attached
* to the given loop.
*/
public Trigger google(EventLoop loop) {
return button(StadiaController.Button.kGoogle.value, loop);
}
/**
* Constructs a Trigger instance around the frame button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the frame button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the frame button's digital signal attached
* to the given loop.
*/
public Trigger frame(EventLoop loop) {
return button(StadiaController.Button.kFrame.value, loop);
}
/**
* Get the X axis value of left side of the controller. Right is positive.
*
* @return The axis value.
*/
public double getLeftX() {
return m_hid.getLeftX();
}
/**
* Get the X axis value of right side of the controller. Right is positive.
*
* @return The axis value.
*/
public double getRightX() {
return m_hid.getRightX();
}
/**
* Get the Y axis value of left side of the controller. Back is positive.
*
* @return The axis value.
*/
public double getLeftY() {
return m_hid.getLeftY();
}
/**
* Get the Y axis value of right side of the controller. Back is positive.
*
* @return The axis value.
*/
public double getRightY() {
return m_hid.getRightY();
}
}

View File

@@ -0,0 +1,395 @@
// 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 ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY
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 a Trigger instance around the A button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the A button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the A button's digital signal attached
* to the given loop.
*/
public Trigger a(EventLoop loop) {
return button(XboxController.Button.kA.value, loop);
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the B button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the B button's digital signal attached
* to the given loop.
*/
public Trigger b(EventLoop loop) {
return button(XboxController.Button.kB.value, loop);
}
/**
* Constructs a Trigger instance around the X button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the X button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the X button's digital signal attached
* to the given loop.
*/
public Trigger x(EventLoop loop) {
return button(XboxController.Button.kX.value, loop);
}
/**
* Constructs a Trigger instance around the Y button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the Y button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Y button's digital signal attached
* to the given loop.
*/
public Trigger y(EventLoop loop) {
return button(XboxController.Button.kY.value, loop);
}
/**
* Constructs a Trigger instance around the left bumper button's digital signal.
*
* @return a Trigger instance representing the left bumper button'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 a Trigger instance around the left bumper button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the left bumper button's digital signal attached
* to the given loop.
*/
public Trigger leftBumper(EventLoop loop) {
return button(XboxController.Button.kLeftBumper.value, loop);
}
/**
* Constructs a Trigger instance around the right bumper button's digital signal.
*
* @return a Trigger instance representing the right bumper button'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 a Trigger instance around the right bumper button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the right bumper button's digital signal attached
* to the given loop.
*/
public Trigger rightBumper(EventLoop loop) {
return button(XboxController.Button.kRightBumper.value, loop);
}
/**
* Constructs a Trigger instance around the back button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the back button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the back button's digital signal attached
* to the given loop.
*/
public Trigger back(EventLoop loop) {
return button(XboxController.Button.kBack.value, loop);
}
/**
* Constructs a Trigger instance around the start button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the start button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the start button's digital signal attached
* to the given loop.
*/
public Trigger start(EventLoop loop) {
return button(XboxController.Button.kStart.value, loop);
}
/**
* Constructs a Trigger instance around the left stick button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the left stick button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the left stick button's digital signal attached
* to the given loop.
*/
public Trigger leftStick(EventLoop loop) {
return button(XboxController.Button.kLeftStick.value, loop);
}
/**
* Constructs a Trigger instance around the right stick button's digital signal.
*
* @return a Trigger 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 a Trigger instance around the right stick button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the right stick button's digital signal attached
* to the given loop.
*/
public Trigger rightStick(EventLoop loop) {
return button(XboxController.Button.kRightStick.value, loop);
}
/**
* 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 axisGreaterThan(XboxController.Axis.kLeftTrigger.value, threshold, loop);
}
/**
* 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 axisGreaterThan(XboxController.Axis.kRightTrigger.value, threshold, loop);
}
/**
* 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. Right is positive.
*
* @return The axis value.
*/
public double getLeftX() {
return m_hid.getLeftX();
}
/**
* Get the X axis value of right side of the controller. Right is positive.
*
* @return The axis value.
*/
public double getRightX() {
return m_hid.getRightX();
}
/**
* Get the Y axis value of left side of the controller. Back is positive.
*
* @return The axis value.
*/
public double getLeftY() {
return m_hid.getLeftY();
}
/**
* Get the Y axis value of right side of the controller. Back is positive.
*
* @return The axis value.
*/
public double getRightY() {
return m_hid.getRightY();
}
/**
* 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 m_hid.getLeftTriggerAxis();
}
/**
* 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 m_hid.getRightTriggerAxis();
}
}

View File

@@ -0,0 +1,96 @@
// 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 ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY
#include "frc2/command/button/CommandPS4Controller.h"
using namespace frc2;
CommandPS4Controller::CommandPS4Controller(int port)
: CommandGenericHID(port), m_hid{frc::PS4Controller(port)} {}
frc::PS4Controller& CommandPS4Controller::GetHID() {
return m_hid;
}
Trigger CommandPS4Controller::Square(frc::EventLoop* loop) const {
return Button(frc::PS4Controller::Button::kSquare, loop);
}
Trigger CommandPS4Controller::Cross(frc::EventLoop* loop) const {
return Button(frc::PS4Controller::Button::kCross, loop);
}
Trigger CommandPS4Controller::Circle(frc::EventLoop* loop) const {
return Button(frc::PS4Controller::Button::kCircle, loop);
}
Trigger CommandPS4Controller::Triangle(frc::EventLoop* loop) const {
return Button(frc::PS4Controller::Button::kTriangle, loop);
}
Trigger CommandPS4Controller::L1(frc::EventLoop* loop) const {
return Button(frc::PS4Controller::Button::kL1, loop);
}
Trigger CommandPS4Controller::R1(frc::EventLoop* loop) const {
return Button(frc::PS4Controller::Button::kR1, loop);
}
Trigger CommandPS4Controller::L2(frc::EventLoop* loop) const {
return Button(frc::PS4Controller::Button::kL2, loop);
}
Trigger CommandPS4Controller::R2(frc::EventLoop* loop) const {
return Button(frc::PS4Controller::Button::kR2, loop);
}
Trigger CommandPS4Controller::Share(frc::EventLoop* loop) const {
return Button(frc::PS4Controller::Button::kShare, loop);
}
Trigger CommandPS4Controller::Options(frc::EventLoop* loop) const {
return Button(frc::PS4Controller::Button::kOptions, loop);
}
Trigger CommandPS4Controller::L3(frc::EventLoop* loop) const {
return Button(frc::PS4Controller::Button::kL3, loop);
}
Trigger CommandPS4Controller::R3(frc::EventLoop* loop) const {
return Button(frc::PS4Controller::Button::kR3, loop);
}
Trigger CommandPS4Controller::PS(frc::EventLoop* loop) const {
return Button(frc::PS4Controller::Button::kPS, loop);
}
Trigger CommandPS4Controller::Touchpad(frc::EventLoop* loop) const {
return Button(frc::PS4Controller::Button::kTouchpad, loop);
}
double CommandPS4Controller::GetLeftX() const {
return m_hid.GetLeftX();
}
double CommandPS4Controller::GetLeftY() const {
return m_hid.GetLeftY();
}
double CommandPS4Controller::GetRightX() const {
return m_hid.GetRightX();
}
double CommandPS4Controller::GetRightY() const {
return m_hid.GetRightY();
}
double CommandPS4Controller::GetL2Axis() const {
return m_hid.GetL2Axis();
}
double CommandPS4Controller::GetR2Axis() const {
return m_hid.GetR2Axis();
}

View File

@@ -0,0 +1,96 @@
// 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 ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY
#include "frc2/command/button/CommandPS5Controller.h"
using namespace frc2;
CommandPS5Controller::CommandPS5Controller(int port)
: CommandGenericHID(port), m_hid{frc::PS5Controller(port)} {}
frc::PS5Controller& CommandPS5Controller::GetHID() {
return m_hid;
}
Trigger CommandPS5Controller::Square(frc::EventLoop* loop) const {
return Button(frc::PS5Controller::Button::kSquare, loop);
}
Trigger CommandPS5Controller::Cross(frc::EventLoop* loop) const {
return Button(frc::PS5Controller::Button::kCross, loop);
}
Trigger CommandPS5Controller::Circle(frc::EventLoop* loop) const {
return Button(frc::PS5Controller::Button::kCircle, loop);
}
Trigger CommandPS5Controller::Triangle(frc::EventLoop* loop) const {
return Button(frc::PS5Controller::Button::kTriangle, loop);
}
Trigger CommandPS5Controller::L1(frc::EventLoop* loop) const {
return Button(frc::PS5Controller::Button::kL1, loop);
}
Trigger CommandPS5Controller::R1(frc::EventLoop* loop) const {
return Button(frc::PS5Controller::Button::kR1, loop);
}
Trigger CommandPS5Controller::L2(frc::EventLoop* loop) const {
return Button(frc::PS5Controller::Button::kL2, loop);
}
Trigger CommandPS5Controller::R2(frc::EventLoop* loop) const {
return Button(frc::PS5Controller::Button::kR2, loop);
}
Trigger CommandPS5Controller::Create(frc::EventLoop* loop) const {
return Button(frc::PS5Controller::Button::kCreate, loop);
}
Trigger CommandPS5Controller::Options(frc::EventLoop* loop) const {
return Button(frc::PS5Controller::Button::kOptions, loop);
}
Trigger CommandPS5Controller::L3(frc::EventLoop* loop) const {
return Button(frc::PS5Controller::Button::kL3, loop);
}
Trigger CommandPS5Controller::R3(frc::EventLoop* loop) const {
return Button(frc::PS5Controller::Button::kR3, loop);
}
Trigger CommandPS5Controller::PS(frc::EventLoop* loop) const {
return Button(frc::PS5Controller::Button::kPS, loop);
}
Trigger CommandPS5Controller::Touchpad(frc::EventLoop* loop) const {
return Button(frc::PS5Controller::Button::kTouchpad, loop);
}
double CommandPS5Controller::GetLeftX() const {
return m_hid.GetLeftX();
}
double CommandPS5Controller::GetLeftY() const {
return m_hid.GetLeftY();
}
double CommandPS5Controller::GetRightX() const {
return m_hid.GetRightX();
}
double CommandPS5Controller::GetRightY() const {
return m_hid.GetRightY();
}
double CommandPS5Controller::GetL2Axis() const {
return m_hid.GetL2Axis();
}
double CommandPS5Controller::GetR2Axis() const {
return m_hid.GetR2Axis();
}

View File

@@ -0,0 +1,92 @@
// 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 ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY
#include "frc2/command/button/CommandStadiaController.h"
using namespace frc2;
CommandStadiaController::CommandStadiaController(int port)
: CommandGenericHID(port), m_hid{frc::StadiaController(port)} {}
frc::StadiaController& CommandStadiaController::GetHID() {
return m_hid;
}
Trigger CommandStadiaController::A(frc::EventLoop* loop) const {
return Button(frc::StadiaController::Button::kA, loop);
}
Trigger CommandStadiaController::B(frc::EventLoop* loop) const {
return Button(frc::StadiaController::Button::kB, loop);
}
Trigger CommandStadiaController::X(frc::EventLoop* loop) const {
return Button(frc::StadiaController::Button::kX, loop);
}
Trigger CommandStadiaController::Y(frc::EventLoop* loop) const {
return Button(frc::StadiaController::Button::kY, loop);
}
Trigger CommandStadiaController::LeftBumper(frc::EventLoop* loop) const {
return Button(frc::StadiaController::Button::kLeftBumper, loop);
}
Trigger CommandStadiaController::RightBumper(frc::EventLoop* loop) const {
return Button(frc::StadiaController::Button::kRightBumper, loop);
}
Trigger CommandStadiaController::LeftStick(frc::EventLoop* loop) const {
return Button(frc::StadiaController::Button::kLeftStick, loop);
}
Trigger CommandStadiaController::RightStick(frc::EventLoop* loop) const {
return Button(frc::StadiaController::Button::kRightStick, loop);
}
Trigger CommandStadiaController::Ellipses(frc::EventLoop* loop) const {
return Button(frc::StadiaController::Button::kEllipses, loop);
}
Trigger CommandStadiaController::Hamburger(frc::EventLoop* loop) const {
return Button(frc::StadiaController::Button::kHamburger, loop);
}
Trigger CommandStadiaController::Stadia(frc::EventLoop* loop) const {
return Button(frc::StadiaController::Button::kStadia, loop);
}
Trigger CommandStadiaController::RightTrigger(frc::EventLoop* loop) const {
return Button(frc::StadiaController::Button::kRightTrigger, loop);
}
Trigger CommandStadiaController::LeftTrigger(frc::EventLoop* loop) const {
return Button(frc::StadiaController::Button::kLeftTrigger, loop);
}
Trigger CommandStadiaController::Google(frc::EventLoop* loop) const {
return Button(frc::StadiaController::Button::kGoogle, loop);
}
Trigger CommandStadiaController::Frame(frc::EventLoop* loop) const {
return Button(frc::StadiaController::Button::kFrame, loop);
}
double CommandStadiaController::GetLeftX() const {
return m_hid.GetLeftX();
}
double CommandStadiaController::GetRightX() const {
return m_hid.GetRightX();
}
double CommandStadiaController::GetLeftY() const {
return m_hid.GetLeftY();
}
double CommandStadiaController::GetRightY() const {
return m_hid.GetRightY();
}

View File

@@ -0,0 +1,94 @@
// 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 ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY
#include "frc2/command/button/CommandXboxController.h"
using namespace frc2;
CommandXboxController::CommandXboxController(int port)
: CommandGenericHID(port), m_hid{frc::XboxController(port)} {}
frc::XboxController& CommandXboxController::GetHID() {
return m_hid;
}
Trigger CommandXboxController::A(frc::EventLoop* loop) const {
return Button(frc::XboxController::Button::kA, loop);
}
Trigger CommandXboxController::B(frc::EventLoop* loop) const {
return Button(frc::XboxController::Button::kB, loop);
}
Trigger CommandXboxController::X(frc::EventLoop* loop) const {
return Button(frc::XboxController::Button::kX, loop);
}
Trigger CommandXboxController::Y(frc::EventLoop* loop) const {
return Button(frc::XboxController::Button::kY, loop);
}
Trigger CommandXboxController::LeftBumper(frc::EventLoop* loop) const {
return Button(frc::XboxController::Button::kLeftBumper, loop);
}
Trigger CommandXboxController::RightBumper(frc::EventLoop* loop) const {
return Button(frc::XboxController::Button::kRightBumper, loop);
}
Trigger CommandXboxController::Back(frc::EventLoop* loop) const {
return Button(frc::XboxController::Button::kBack, loop);
}
Trigger CommandXboxController::Start(frc::EventLoop* loop) const {
return Button(frc::XboxController::Button::kStart, loop);
}
Trigger CommandXboxController::LeftStick(frc::EventLoop* loop) const {
return Button(frc::XboxController::Button::kLeftStick, loop);
}
Trigger CommandXboxController::RightStick(frc::EventLoop* loop) const {
return Button(frc::XboxController::Button::kRightStick, loop);
}
Trigger CommandXboxController::LeftTrigger(double threshold,
frc::EventLoop* loop) const {
return Trigger(loop, [this, threshold] {
return m_hid.GetLeftTriggerAxis() > threshold;
});
}
Trigger CommandXboxController::RightTrigger(double threshold,
frc::EventLoop* loop) const {
return Trigger(loop, [this, threshold] {
return m_hid.GetRightTriggerAxis() > threshold;
});
}
double CommandXboxController::GetLeftX() const {
return m_hid.GetLeftX();
}
double CommandXboxController::GetRightX() const {
return m_hid.GetRightX();
}
double CommandXboxController::GetLeftY() const {
return m_hid.GetLeftY();
}
double CommandXboxController::GetRightY() const {
return m_hid.GetRightY();
}
double CommandXboxController::GetLeftTriggerAxis() const {
return m_hid.GetLeftTriggerAxis();
}
double CommandXboxController::GetRightTriggerAxis() const {
return m_hid.GetRightTriggerAxis();
}

View File

@@ -0,0 +1,253 @@
// 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 ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY
#pragma once
#include <frc/PS4Controller.h>
#include "frc2/command/button/Trigger.h"
#include "frc2/command/CommandScheduler.h"
#include "frc2/command/button/CommandGenericHID.h"
namespace frc2 {
/**
* A version of {@link frc::PS4Controller} with {@link Trigger} factories for
* command-based.
*
* @see frc::PS4Controller
*/
class CommandPS4Controller : public CommandGenericHID {
public:
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is
* plugged into.
*/
explicit CommandPS4Controller(int port);
/**
* Get the underlying GenericHID object.
*
* @return the wrapped GenericHID object
*/
frc::PS4Controller& GetHID();
/**
* Constructs a Trigger instance around the square button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the square button's
* digital signal attached to the given loop.
*/
Trigger Square(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the cross button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the cross button's
* digital signal attached to the given loop.
*/
Trigger Cross(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the circle button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the circle button's
* digital signal attached to the given loop.
*/
Trigger Circle(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the triangle button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the triangle button's
* digital signal attached to the given loop.
*/
Trigger Triangle(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the left trigger 1 button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the left trigger 1 button's
* digital signal attached to the given loop.
*/
Trigger L1(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the right trigger 1 button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the right trigger 1 button's
* digital signal attached to the given loop.
*/
Trigger R1(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the left trigger 2 button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the left trigger 2 button's
* digital signal attached to the given loop.
*/
Trigger L2(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the right trigger 2 button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the right trigger 2 button's
* digital signal attached to the given loop.
*/
Trigger R2(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the share button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the share button's
* digital signal attached to the given loop.
*/
Trigger Share(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the options button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the options button's
* digital signal attached to the given loop.
*/
Trigger Options(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the L3 (left stick) button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the L3 (left stick) button's
* digital signal attached to the given loop.
*/
Trigger L3(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the R3 (right stick) button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the R3 (right stick) button's
* digital signal attached to the given loop.
*/
Trigger R3(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the PlayStation button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the PlayStation button's
* digital signal attached to the given loop.
*/
Trigger PS(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the touchpad button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the touchpad button's
* digital signal attached to the given loop.
*/
Trigger Touchpad(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Get the X axis value of left side of the controller. Right is positive.
*
* @return The axis value.
*/
double GetLeftX() const;
/**
* Get the Y axis value of left side of the controller. Back is positive.
*
* @return The axis value.
*/
double GetLeftY() const;
/**
* Get the X axis value of right side of the controller. Right is positive.
*
* @return The axis value.
*/
double GetRightX() const;
/**
* Get the Y axis value of right side of the controller. Back is positive.
*
* @return The axis value.
*/
double GetRightY() const;
/**
* 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.
*/
double GetL2Axis() const;
/**
* 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.
*/
double GetR2Axis() const;
private:
frc::PS4Controller m_hid;
};
} // namespace frc2

View File

@@ -0,0 +1,253 @@
// 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 ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY
#pragma once
#include <frc/PS5Controller.h>
#include "frc2/command/button/Trigger.h"
#include "frc2/command/CommandScheduler.h"
#include "frc2/command/button/CommandGenericHID.h"
namespace frc2 {
/**
* A version of {@link frc::PS5Controller} with {@link Trigger} factories for
* command-based.
*
* @see frc::PS5Controller
*/
class CommandPS5Controller : public CommandGenericHID {
public:
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is
* plugged into.
*/
explicit CommandPS5Controller(int port);
/**
* Get the underlying GenericHID object.
*
* @return the wrapped GenericHID object
*/
frc::PS5Controller& GetHID();
/**
* Constructs a Trigger instance around the square button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the square button's
* digital signal attached to the given loop.
*/
Trigger Square(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the cross button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the cross button's
* digital signal attached to the given loop.
*/
Trigger Cross(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the circle button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the circle button's
* digital signal attached to the given loop.
*/
Trigger Circle(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the triangle button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the triangle button's
* digital signal attached to the given loop.
*/
Trigger Triangle(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the left trigger 1 button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the left trigger 1 button's
* digital signal attached to the given loop.
*/
Trigger L1(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the right trigger 1 button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the right trigger 1 button's
* digital signal attached to the given loop.
*/
Trigger R1(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the left trigger 2 button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the left trigger 2 button's
* digital signal attached to the given loop.
*/
Trigger L2(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the right trigger 2 button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the right trigger 2 button's
* digital signal attached to the given loop.
*/
Trigger R2(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the create button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the create button's
* digital signal attached to the given loop.
*/
Trigger Create(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the options button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the options button's
* digital signal attached to the given loop.
*/
Trigger Options(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the L3 (left stick) button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the L3 (left stick) button's
* digital signal attached to the given loop.
*/
Trigger L3(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the R3 (right stick) button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the R3 (right stick) button's
* digital signal attached to the given loop.
*/
Trigger R3(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the PlayStation button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the PlayStation button's
* digital signal attached to the given loop.
*/
Trigger PS(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the touchpad button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the touchpad button's
* digital signal attached to the given loop.
*/
Trigger Touchpad(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Get the X axis value of left side of the controller. Right is positive.
*
* @return The axis value.
*/
double GetLeftX() const;
/**
* Get the Y axis value of left side of the controller. Back is positive.
*
* @return The axis value.
*/
double GetLeftY() const;
/**
* Get the X axis value of right side of the controller. Right is positive.
*
* @return The axis value.
*/
double GetRightX() const;
/**
* Get the Y axis value of right side of the controller. Back is positive.
*
* @return The axis value.
*/
double GetRightY() const;
/**
* 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.
*/
double GetL2Axis() const;
/**
* 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.
*/
double GetR2Axis() const;
private:
frc::PS5Controller m_hid;
};
} // namespace frc2

View File

@@ -0,0 +1,249 @@
// 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 ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY
#pragma once
#include <frc/StadiaController.h>
#include "frc2/command/button/Trigger.h"
#include "frc2/command/CommandScheduler.h"
#include "frc2/command/button/CommandGenericHID.h"
namespace frc2 {
/**
* A version of {@link frc::StadiaController} with {@link Trigger} factories for
* command-based.
*
* @see frc::StadiaController
*/
class CommandStadiaController : public CommandGenericHID {
public:
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is
* plugged into.
*/
explicit CommandStadiaController(int port);
/**
* Get the underlying GenericHID object.
*
* @return the wrapped GenericHID object
*/
frc::StadiaController& GetHID();
/**
* Constructs a Trigger instance around the A button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the A button's
* digital signal attached to the given loop.
*/
Trigger A(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the B button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the B button's
* digital signal attached to the given loop.
*/
Trigger B(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the X button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the X button's
* digital signal attached to the given loop.
*/
Trigger X(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Y button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the Y button's
* digital signal attached to the given loop.
*/
Trigger Y(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the left bumper button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the left bumper button's
* digital signal attached to the given loop.
*/
Trigger LeftBumper(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the right bumper button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the right bumper button's
* digital signal attached to the given loop.
*/
Trigger RightBumper(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the left stick button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the left stick button's
* digital signal attached to the given loop.
*/
Trigger LeftStick(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the right stick button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the right stick button's
* digital signal attached to the given loop.
*/
Trigger RightStick(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the ellipses button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the ellipses button's
* digital signal attached to the given loop.
*/
Trigger Ellipses(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the hamburger button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the hamburger button's
* digital signal attached to the given loop.
*/
Trigger Hamburger(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the stadia button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the stadia button's
* digital signal attached to the given loop.
*/
Trigger Stadia(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the right trigger button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the right trigger button's
* digital signal attached to the given loop.
*/
Trigger RightTrigger(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the left trigger button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the left trigger button's
* digital signal attached to the given loop.
*/
Trigger LeftTrigger(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the google button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the google button's
* digital signal attached to the given loop.
*/
Trigger Google(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the frame button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the frame button's
* digital signal attached to the given loop.
*/
Trigger Frame(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Get the X axis value of left side of the controller. Right is positive.
*
* @return The axis value.
*/
double GetLeftX() const;
/**
* Get the X axis value of right side of the controller. Right is positive.
*
* @return The axis value.
*/
double GetRightX() const;
/**
* Get the Y axis value of left side of the controller. Back is positive.
*
* @return The axis value.
*/
double GetLeftY() const;
/**
* Get the Y axis value of right side of the controller. Back is positive.
*
* @return The axis value.
*/
double GetRightY() const;
private:
frc::StadiaController m_hid;
};
} // namespace frc2

View File

@@ -0,0 +1,239 @@
// 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 ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY
#pragma once
#include <frc/XboxController.h>
#include "frc2/command/button/Trigger.h"
#include "frc2/command/CommandScheduler.h"
#include "frc2/command/button/CommandGenericHID.h"
namespace frc2 {
/**
* A version of {@link frc::XboxController} with {@link Trigger} factories for
* command-based.
*
* @see frc::XboxController
*/
class CommandXboxController : public CommandGenericHID {
public:
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is
* plugged into.
*/
explicit CommandXboxController(int port);
/**
* Get the underlying GenericHID object.
*
* @return the wrapped GenericHID object
*/
frc::XboxController& GetHID();
/**
* Constructs a Trigger instance around the A button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the A button's
* digital signal attached to the given loop.
*/
Trigger A(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the B button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the B button's
* digital signal attached to the given loop.
*/
Trigger B(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the X button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the X button's
* digital signal attached to the given loop.
*/
Trigger X(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Y button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the Y button's
* digital signal attached to the given loop.
*/
Trigger Y(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the left bumper button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the left bumper button's
* digital signal attached to the given loop.
*/
Trigger LeftBumper(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the right bumper button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the right bumper button's
* digital signal attached to the given loop.
*/
Trigger RightBumper(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the back button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the back button's
* digital signal attached to the given loop.
*/
Trigger Back(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the start button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the start button's
* digital signal attached to the given loop.
*/
Trigger Start(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the left stick button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the left stick button's
* digital signal attached to the given loop.
*/
Trigger LeftStick(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the right stick button's
* digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return a Trigger instance representing the right stick button's
* digital signal attached to the given loop.
*/
Trigger RightStick(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* 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 Trigger to be
* true. This value should be in the range [0, 1] where 0 is the unpressed
* state of the axis. Defaults to 0.5.
* @param loop the event loop instance to attach the Trigger to. Defaults to
* the CommandScheduler's default loop.
* @return a Trigger instance that is true when the left trigger's axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger LeftTrigger(double threshold = 0.5,
frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* 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 Trigger to be
* true. This value should be in the range [0, 1] where 0 is the unpressed
* state of the axis. Defaults to 0.5.
* @param loop the event loop instance to attach the Trigger to. Defaults to
* the CommandScheduler's default loop.
* @return a Trigger instance that is true when the right trigger's axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger RightTrigger(double threshold = 0.5,
frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Get the X axis value of left side of the controller. Right is positive.
*
* @return The axis value.
*/
double GetLeftX() const;
/**
* Get the X axis value of right side of the controller. Right is positive.
*
* @return The axis value.
*/
double GetRightX() const;
/**
* Get the Y axis value of left side of the controller. Back is positive.
*
* @return The axis value.
*/
double GetLeftY() const;
/**
* Get the Y axis value of right side of the controller. Back is positive.
*
* @return The axis value.
*/
double GetRightY() const;
/**
* 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.
*/
double GetLeftTriggerAxis() const;
/**
* 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.
*/
double GetRightTriggerAxis() const;
private:
frc::XboxController m_hid;
};
} // namespace frc2