diff --git a/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandDualSenseEdgeController.java b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandDualSenseEdgeController.java new file mode 100644 index 0000000000..086238b8fc --- /dev/null +++ b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandDualSenseEdgeController.java @@ -0,0 +1,784 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY + +package org.wpilib.command2.button; + +import java.util.Objects; +import org.wpilib.command2.CommandScheduler; +import org.wpilib.driverstation.DualSenseEdgeController; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link DualSenseEdgeController} with {@link Trigger} factories for command-based. + * + * @see DualSenseEdgeController + */ +@SuppressWarnings("MethodName") +public class CommandDualSenseEdgeController { + private final CommandGenericHID m_hid; + private final DualSenseEdgeController m_controller; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandDualSenseEdgeController(int port) { + m_hid = CommandGenericHID.getCommandGenericHID(port); + m_controller = new DualSenseEdgeController(m_hid.getHID()); + } + + /** + * Construct an instance of a controller with a DualSenseEdgeController object. + * + * @param controller The DualSenseEdgeController object to use for this controller. + */ + public CommandDualSenseEdgeController(DualSenseEdgeController controller) { + m_controller = + Objects.requireNonNull(controller, "Provided DualSenseEdgeController cannot be null"); + m_hid = new CommandGenericHID(m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public DualSenseEdgeController getController() { + return m_controller; + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @return an event instance representing the button's digital signal attached to the {@link + * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #button(DualSenseEdgeController.Button, EventLoop) + */ + public Trigger button(DualSenseEdgeController.Button button) { + return button(button, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public Trigger button(DualSenseEdgeController.Button button, EventLoop loop) { + return m_hid.button(button.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(DualSenseEdgeController.Button.CROSS, 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(DualSenseEdgeController.Button.CIRCLE, loop); + } + + /** + * 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(DualSenseEdgeController.Button.SQUARE, 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(DualSenseEdgeController.Button.TRIANGLE, 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(DualSenseEdgeController.Button.CREATE, loop); + } + + /** + * Constructs a Trigger instance around the PS button's digital signal. + * + * @return a Trigger instance representing the PS 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 PS button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the PS button's digital signal attached + * to the given loop. + */ + public Trigger PS(EventLoop loop) { + return button(DualSenseEdgeController.Button.PS, 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(DualSenseEdgeController.Button.OPTIONS, loop); + } + + /** + * Constructs a Trigger instance around the L 3 button's digital signal. + * + * @return a Trigger instance representing the L 3 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 L 3 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L 3 button's digital signal attached + * to the given loop. + */ + public Trigger L3(EventLoop loop) { + return button(DualSenseEdgeController.Button.L3, loop); + } + + /** + * Constructs a Trigger instance around the R 3 button's digital signal. + * + * @return a Trigger instance representing the R 3 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 R 3 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R 3 button's digital signal attached + * to the given loop. + */ + public Trigger R3(EventLoop loop) { + return button(DualSenseEdgeController.Button.R3, loop); + } + + /** + * Constructs a Trigger instance around the L 1 button's digital signal. + * + * @return a Trigger instance representing the L 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 L 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L 1 button's digital signal attached + * to the given loop. + */ + public Trigger L1(EventLoop loop) { + return button(DualSenseEdgeController.Button.L1, loop); + } + + /** + * Constructs a Trigger instance around the R 1 button's digital signal. + * + * @return a Trigger instance representing the R 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 R 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R 1 button's digital signal attached + * to the given loop. + */ + public Trigger R1(EventLoop loop) { + return button(DualSenseEdgeController.Button.R1, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return button(DualSenseEdgeController.Button.DPAD_UP, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return button(DualSenseEdgeController.Button.DPAD_DOWN, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return button(DualSenseEdgeController.Button.DPAD_LEFT, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return button(DualSenseEdgeController.Button.DPAD_RIGHT, loop); + } + + /** + * Constructs a Trigger instance around the Microphone button's digital signal. + * + * @return a Trigger instance representing the Microphone button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #microphone(EventLoop) + */ + public Trigger microphone() { + return microphone(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Microphone button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Microphone button's digital signal attached + * to the given loop. + */ + public Trigger microphone(EventLoop loop) { + return button(DualSenseEdgeController.Button.MICROPHONE, loop); + } + + /** + * Constructs a Trigger instance around the Right Paddle 1 button's digital signal. + * + * @return a Trigger instance representing the Right Paddle 1 button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #rightPaddle1(EventLoop) + */ + public Trigger rightPaddle1() { + return rightPaddle1(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Right Paddle 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Right Paddle 1 button's digital signal attached + * to the given loop. + */ + public Trigger rightPaddle1(EventLoop loop) { + return button(DualSenseEdgeController.Button.RIGHT_PADDLE_1, loop); + } + + /** + * Constructs a Trigger instance around the Left Paddle 1 button's digital signal. + * + * @return a Trigger instance representing the Left Paddle 1 button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #leftPaddle1(EventLoop) + */ + public Trigger leftPaddle1() { + return leftPaddle1(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Left Paddle 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Left Paddle 1 button's digital signal attached + * to the given loop. + */ + public Trigger leftPaddle1(EventLoop loop) { + return button(DualSenseEdgeController.Button.LEFT_PADDLE_1, 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(DualSenseEdgeController.Button.TOUCHPAD, loop); + } + + /** + * Constructs a Trigger instance around the Left Function button's digital signal. + * + * @return a Trigger instance representing the Left Function button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #leftFunction(EventLoop) + */ + public Trigger leftFunction() { + return leftFunction(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Left Function button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Left Function button's digital signal attached + * to the given loop. + */ + public Trigger leftFunction(EventLoop loop) { + return button(DualSenseEdgeController.Button.LEFT_FUNCTION, loop); + } + + /** + * Constructs a Trigger instance around the Right Function button's digital signal. + * + * @return a Trigger instance representing the Right Function button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #rightFunction(EventLoop) + */ + public Trigger rightFunction() { + return rightFunction(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Right Function button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Right Function button's digital signal attached + * to the given loop. + */ + public Trigger rightFunction(EventLoop loop) { + return button(DualSenseEdgeController.Button.RIGHT_FUNCTION, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the L 2. 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 L 2 axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger L2(double threshold, EventLoop loop) { + return axisGreaterThan( + DualSenseEdgeController.Axis.L2, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the L 2. 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 L 2 axis exceeds the provided + * threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler + * button loop}. + */ + public Trigger L2(double threshold) { + return L2(threshold, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the L 2. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the L 2 axis exceeds 0.5, + * attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button + * loop}. + */ + public Trigger L2() { + return L2(0.5); + } + + + /** + * Constructs a Trigger instance around the axis value of the R 2. 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 R 2 axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger R2(double threshold, EventLoop loop) { + return axisGreaterThan( + DualSenseEdgeController.Axis.R2, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the R 2. 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 R 2 axis exceeds the provided + * threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler + * button loop}. + */ + public Trigger R2(double threshold) { + return R2(threshold, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the R 2. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the R 2 axis exceeds 0.5, + * attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button + * loop}. + */ + public Trigger R2() { + return R2(0.5); + } + + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan(DualSenseEdgeController.Axis axis, double threshold) { + return m_hid.axisLessThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the trigger to + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan( + DualSenseEdgeController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan(DualSenseEdgeController.Axis axis, double threshold) { + return m_hid.axisGreaterThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan( + DualSenseEdgeController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is greater than the + * provided threshold. + */ + public Trigger axisMagnitudeGreaterThan( + DualSenseEdgeController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command + * scheduler button loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the deadbanded axis value is active (non-zero). + */ + public Trigger axisMagnitudeGreaterThan(DualSenseEdgeController.Axis axis, double threshold) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The value of the axis. + */ + public double getAxis(DualSenseEdgeController.Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return m_controller.getRightX(); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return m_controller.getRightY(); + } + + /** + * Get the L 2 value of the controller. + * + * @return The axis value. + */ + public double getL2() { + return m_controller.getL2(); + } + + /** + * Get the R 2 value of the controller. + * + * @return The axis value. + */ + public double getR2() { + return m_controller.getR2(); + } +} diff --git a/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandDualShock4Controller.java b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandDualShock4Controller.java new file mode 100644 index 0000000000..6c4d13b587 --- /dev/null +++ b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandDualShock4Controller.java @@ -0,0 +1,674 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY + +package org.wpilib.command2.button; + +import java.util.Objects; +import org.wpilib.command2.CommandScheduler; +import org.wpilib.driverstation.DualShock4Controller; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link DualShock4Controller} with {@link Trigger} factories for command-based. + * + * @see DualShock4Controller + */ +@SuppressWarnings("MethodName") +public class CommandDualShock4Controller { + private final CommandGenericHID m_hid; + private final DualShock4Controller m_controller; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandDualShock4Controller(int port) { + m_hid = CommandGenericHID.getCommandGenericHID(port); + m_controller = new DualShock4Controller(m_hid.getHID()); + } + + /** + * Construct an instance of a controller with a DualShock4Controller object. + * + * @param controller The DualShock4Controller object to use for this controller. + */ + public CommandDualShock4Controller(DualShock4Controller controller) { + m_controller = + Objects.requireNonNull(controller, "Provided DualShock4Controller cannot be null"); + m_hid = new CommandGenericHID(m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public DualShock4Controller getController() { + return m_controller; + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @return an event instance representing the button's digital signal attached to the {@link + * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #button(DualShock4Controller.Button, EventLoop) + */ + public Trigger button(DualShock4Controller.Button button) { + return button(button, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public Trigger button(DualShock4Controller.Button button, EventLoop loop) { + return m_hid.button(button.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(DualShock4Controller.Button.CROSS, 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(DualShock4Controller.Button.CIRCLE, loop); + } + + /** + * 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(DualShock4Controller.Button.SQUARE, 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(DualShock4Controller.Button.TRIANGLE, 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(DualShock4Controller.Button.SHARE, loop); + } + + /** + * Constructs a Trigger instance around the PS button's digital signal. + * + * @return a Trigger instance representing the PS 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 PS button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the PS button's digital signal attached + * to the given loop. + */ + public Trigger PS(EventLoop loop) { + return button(DualShock4Controller.Button.PS, 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(DualShock4Controller.Button.OPTIONS, loop); + } + + /** + * Constructs a Trigger instance around the L 3 button's digital signal. + * + * @return a Trigger instance representing the L 3 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 L 3 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L 3 button's digital signal attached + * to the given loop. + */ + public Trigger L3(EventLoop loop) { + return button(DualShock4Controller.Button.L3, loop); + } + + /** + * Constructs a Trigger instance around the R 3 button's digital signal. + * + * @return a Trigger instance representing the R 3 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 R 3 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R 3 button's digital signal attached + * to the given loop. + */ + public Trigger R3(EventLoop loop) { + return button(DualShock4Controller.Button.R3, loop); + } + + /** + * Constructs a Trigger instance around the L 1 button's digital signal. + * + * @return a Trigger instance representing the L 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 L 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L 1 button's digital signal attached + * to the given loop. + */ + public Trigger L1(EventLoop loop) { + return button(DualShock4Controller.Button.L1, loop); + } + + /** + * Constructs a Trigger instance around the R 1 button's digital signal. + * + * @return a Trigger instance representing the R 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 R 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R 1 button's digital signal attached + * to the given loop. + */ + public Trigger R1(EventLoop loop) { + return button(DualShock4Controller.Button.R1, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return button(DualShock4Controller.Button.DPAD_UP, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return button(DualShock4Controller.Button.DPAD_DOWN, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return button(DualShock4Controller.Button.DPAD_LEFT, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return button(DualShock4Controller.Button.DPAD_RIGHT, 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(DualShock4Controller.Button.TOUCHPAD, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the L 2. 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 L 2 axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger L2(double threshold, EventLoop loop) { + return axisGreaterThan( + DualShock4Controller.Axis.L2, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the L 2. 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 L 2 axis exceeds the provided + * threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler + * button loop}. + */ + public Trigger L2(double threshold) { + return L2(threshold, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the L 2. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the L 2 axis exceeds 0.5, + * attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button + * loop}. + */ + public Trigger L2() { + return L2(0.5); + } + + + /** + * Constructs a Trigger instance around the axis value of the R 2. 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 R 2 axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger R2(double threshold, EventLoop loop) { + return axisGreaterThan( + DualShock4Controller.Axis.R2, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the R 2. 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 R 2 axis exceeds the provided + * threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler + * button loop}. + */ + public Trigger R2(double threshold) { + return R2(threshold, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the R 2. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the R 2 axis exceeds 0.5, + * attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button + * loop}. + */ + public Trigger R2() { + return R2(0.5); + } + + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan(DualShock4Controller.Axis axis, double threshold) { + return m_hid.axisLessThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the trigger to + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan( + DualShock4Controller.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan(DualShock4Controller.Axis axis, double threshold) { + return m_hid.axisGreaterThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan( + DualShock4Controller.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is greater than the + * provided threshold. + */ + public Trigger axisMagnitudeGreaterThan( + DualShock4Controller.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command + * scheduler button loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the deadbanded axis value is active (non-zero). + */ + public Trigger axisMagnitudeGreaterThan(DualShock4Controller.Axis axis, double threshold) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The value of the axis. + */ + public double getAxis(DualShock4Controller.Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return m_controller.getRightX(); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return m_controller.getRightY(); + } + + /** + * Get the L 2 value of the controller. + * + * @return The axis value. + */ + public double getL2() { + return m_controller.getL2(); + } + + /** + * Get the R 2 value of the controller. + * + * @return The axis value. + */ + public double getR2() { + return m_controller.getR2(); + } +} diff --git a/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandGameCubeController.java b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandGameCubeController.java new file mode 100644 index 0000000000..992c68fa66 --- /dev/null +++ b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandGameCubeController.java @@ -0,0 +1,586 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY + +package org.wpilib.command2.button; + +import java.util.Objects; +import org.wpilib.command2.CommandScheduler; +import org.wpilib.driverstation.GameCubeController; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link GameCubeController} with {@link Trigger} factories for command-based. + * + * @see GameCubeController + */ +@SuppressWarnings("MethodName") +public class CommandGameCubeController { + private final CommandGenericHID m_hid; + private final GameCubeController m_controller; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandGameCubeController(int port) { + m_hid = CommandGenericHID.getCommandGenericHID(port); + m_controller = new GameCubeController(m_hid.getHID()); + } + + /** + * Construct an instance of a controller with a GameCubeController object. + * + * @param controller The GameCubeController object to use for this controller. + */ + public CommandGameCubeController(GameCubeController controller) { + m_controller = + Objects.requireNonNull(controller, "Provided GameCubeController cannot be null"); + m_hid = new CommandGenericHID(m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public GameCubeController getController() { + return m_controller; + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @return an event instance representing the button's digital signal attached to the {@link + * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #button(GameCubeController.Button, EventLoop) + */ + public Trigger button(GameCubeController.Button button) { + return button(button, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public Trigger button(GameCubeController.Button button, EventLoop loop) { + return m_hid.button(button.value, loop); + } + + /** + * 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(GameCubeController.Button.A, 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(GameCubeController.Button.X, 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(GameCubeController.Button.B, 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(GameCubeController.Button.Y, 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(GameCubeController.Button.START, loop); + } + + /** + * Constructs a Trigger instance around the Z button's digital signal. + * + * @return a Trigger instance representing the Z button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #Z(EventLoop) + */ + public Trigger Z() { + return Z(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Z button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Z button's digital signal attached + * to the given loop. + */ + public Trigger Z(EventLoop loop) { + return button(GameCubeController.Button.Z, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return button(GameCubeController.Button.DPAD_UP, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return button(GameCubeController.Button.DPAD_DOWN, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return button(GameCubeController.Button.DPAD_LEFT, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return button(GameCubeController.Button.DPAD_RIGHT, loop); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @return a Trigger instance representing the L button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #L(EventLoop) + */ + public Trigger L() { + return L(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L button's digital signal attached + * to the given loop. + */ + public Trigger L(EventLoop loop) { + return button(GameCubeController.Button.L, loop); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @return a Trigger instance representing the R button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #R(EventLoop) + */ + public Trigger R() { + return R(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R button's digital signal attached + * to the given loop. + */ + public Trigger R(EventLoop loop) { + return button(GameCubeController.Button.R, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the L 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 L Trigger axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger LTrigger(double threshold, EventLoop loop) { + return axisGreaterThan( + GameCubeController.Axis.L_TRIGGER, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the L 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 L Trigger axis exceeds the provided + * threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler + * button loop}. + */ + public Trigger LTrigger(double threshold) { + return LTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the L 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 L Trigger axis exceeds 0.5, + * attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button + * loop}. + */ + public Trigger LTrigger() { + return LTrigger(0.5); + } + + + /** + * Constructs a Trigger instance around the axis value of the R 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 R Trigger axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger RTrigger(double threshold, EventLoop loop) { + return axisGreaterThan( + GameCubeController.Axis.R_TRIGGER, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the R 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 R Trigger axis exceeds the provided + * threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler + * button loop}. + */ + public Trigger RTrigger(double threshold) { + return RTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the R 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 R Trigger axis exceeds 0.5, + * attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button + * loop}. + */ + public Trigger RTrigger() { + return RTrigger(0.5); + } + + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan(GameCubeController.Axis axis, double threshold) { + return m_hid.axisLessThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the trigger to + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan( + GameCubeController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan(GameCubeController.Axis axis, double threshold) { + return m_hid.axisGreaterThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan( + GameCubeController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is greater than the + * provided threshold. + */ + public Trigger axisMagnitudeGreaterThan( + GameCubeController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command + * scheduler button loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the deadbanded axis value is active (non-zero). + */ + public Trigger axisMagnitudeGreaterThan(GameCubeController.Axis axis, double threshold) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The value of the axis. + */ + public double getAxis(GameCubeController.Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the C Stick X value of the controller. + * + * @return The axis value. + */ + public double getCStickX() { + return m_controller.getCStickX(); + } + + /** + * Get the C Stick Y value of the controller. + * + * @return The axis value. + */ + public double getCStickY() { + return m_controller.getCStickY(); + } + + /** + * Get the L Trigger value of the controller. + * + * @return The axis value. + */ + public double getLTrigger() { + return m_controller.getLTrigger(); + } + + /** + * Get the R Trigger value of the controller. + * + * @return The axis value. + */ + public double getRTrigger() { + return m_controller.getRTrigger(); + } +} diff --git a/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandLogitechF310Controller.java b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandLogitechF310Controller.java new file mode 100644 index 0000000000..2077ad19cd --- /dev/null +++ b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandLogitechF310Controller.java @@ -0,0 +1,652 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY + +package org.wpilib.command2.button; + +import java.util.Objects; +import org.wpilib.command2.CommandScheduler; +import org.wpilib.driverstation.LogitechF310Controller; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link LogitechF310Controller} with {@link Trigger} factories for command-based. + * + * @see LogitechF310Controller + */ +@SuppressWarnings("MethodName") +public class CommandLogitechF310Controller { + private final CommandGenericHID m_hid; + private final LogitechF310Controller m_controller; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandLogitechF310Controller(int port) { + m_hid = CommandGenericHID.getCommandGenericHID(port); + m_controller = new LogitechF310Controller(m_hid.getHID()); + } + + /** + * Construct an instance of a controller with a LogitechF310Controller object. + * + * @param controller The LogitechF310Controller object to use for this controller. + */ + public CommandLogitechF310Controller(LogitechF310Controller controller) { + m_controller = + Objects.requireNonNull(controller, "Provided LogitechF310Controller cannot be null"); + m_hid = new CommandGenericHID(m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public LogitechF310Controller getController() { + return m_controller; + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @return an event instance representing the button's digital signal attached to the {@link + * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #button(LogitechF310Controller.Button, EventLoop) + */ + public Trigger button(LogitechF310Controller.Button button) { + return button(button, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public Trigger button(LogitechF310Controller.Button button, EventLoop loop) { + return m_hid.button(button.value, loop); + } + + /** + * 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(LogitechF310Controller.Button.A, 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(LogitechF310Controller.Button.B, 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(LogitechF310Controller.Button.X, 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(LogitechF310Controller.Button.Y, 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(LogitechF310Controller.Button.BACK, loop); + } + + /** + * Constructs a Trigger instance around the Logitech button's digital signal. + * + * @return a Trigger instance representing the Logitech button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #logitech(EventLoop) + */ + public Trigger logitech() { + return logitech(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Logitech button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Logitech button's digital signal attached + * to the given loop. + */ + public Trigger logitech(EventLoop loop) { + return button(LogitechF310Controller.Button.LOGITECH, 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(LogitechF310Controller.Button.START, 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(LogitechF310Controller.Button.LEFT_STICK, 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(LogitechF310Controller.Button.RIGHT_STICK, 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(LogitechF310Controller.Button.LEFT_BUMPER, 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(LogitechF310Controller.Button.RIGHT_BUMPER, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return button(LogitechF310Controller.Button.DPAD_UP, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return button(LogitechF310Controller.Button.DPAD_DOWN, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return button(LogitechF310Controller.Button.DPAD_LEFT, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return button(LogitechF310Controller.Button.DPAD_RIGHT, 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 axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger leftTrigger(double threshold, EventLoop loop) { + return axisGreaterThan( + LogitechF310Controller.Axis.LEFT_TRIGGER, 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 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 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 axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger rightTrigger(double threshold, EventLoop loop) { + return axisGreaterThan( + LogitechF310Controller.Axis.RIGHT_TRIGGER, 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 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 axis exceeds 0.5, + * attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button + * loop}. + */ + public Trigger rightTrigger() { + return rightTrigger(0.5); + } + + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan(LogitechF310Controller.Axis axis, double threshold) { + return m_hid.axisLessThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the trigger to + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan( + LogitechF310Controller.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan(LogitechF310Controller.Axis axis, double threshold) { + return m_hid.axisGreaterThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan( + LogitechF310Controller.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is greater than the + * provided threshold. + */ + public Trigger axisMagnitudeGreaterThan( + LogitechF310Controller.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command + * scheduler button loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the deadbanded axis value is active (non-zero). + */ + public Trigger axisMagnitudeGreaterThan(LogitechF310Controller.Axis axis, double threshold) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The value of the axis. + */ + public double getAxis(LogitechF310Controller.Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return m_controller.getRightX(); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return m_controller.getRightY(); + } + + /** + * Get the Left Trigger value of the controller. + * + * @return The axis value. + */ + public double getLeftTrigger() { + return m_controller.getLeftTrigger(); + } + + /** + * Get the Right Trigger value of the controller. + * + * @return The axis value. + */ + public double getRightTrigger() { + return m_controller.getRightTrigger(); + } +} diff --git a/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandSteamController.java b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandSteamController.java new file mode 100644 index 0000000000..37cc17c13e --- /dev/null +++ b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandSteamController.java @@ -0,0 +1,894 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY + +package org.wpilib.command2.button; + +import java.util.Objects; +import org.wpilib.command2.CommandScheduler; +import org.wpilib.driverstation.SteamController; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link SteamController} with {@link Trigger} factories for command-based. + * + * @see SteamController + */ +@SuppressWarnings("MethodName") +public class CommandSteamController { + private final CommandGenericHID m_hid; + private final SteamController m_controller; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandSteamController(int port) { + m_hid = CommandGenericHID.getCommandGenericHID(port); + m_controller = new SteamController(m_hid.getHID()); + } + + /** + * Construct an instance of a controller with a SteamController object. + * + * @param controller The SteamController object to use for this controller. + */ + public CommandSteamController(SteamController controller) { + m_controller = + Objects.requireNonNull(controller, "Provided SteamController cannot be null"); + m_hid = new CommandGenericHID(m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public SteamController getController() { + return m_controller; + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @return an event instance representing the button's digital signal attached to the {@link + * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #button(SteamController.Button, EventLoop) + */ + public Trigger button(SteamController.Button button) { + return button(button, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public Trigger button(SteamController.Button button, EventLoop loop) { + return m_hid.button(button.value, loop); + } + + /** + * 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(SteamController.Button.A, 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(SteamController.Button.B, 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(SteamController.Button.X, 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(SteamController.Button.Y, loop); + } + + /** + * Constructs a Trigger instance around the Menu button's digital signal. + * + * @return a Trigger instance representing the Menu button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #menu(EventLoop) + */ + public Trigger menu() { + return menu(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Menu button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Menu button's digital signal attached + * to the given loop. + */ + public Trigger menu(EventLoop loop) { + return button(SteamController.Button.MENU, loop); + } + + /** + * Constructs a Trigger instance around the Steam button's digital signal. + * + * @return a Trigger instance representing the Steam button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #steam(EventLoop) + */ + public Trigger steam() { + return steam(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Steam button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Steam button's digital signal attached + * to the given loop. + */ + public Trigger steam(EventLoop loop) { + return button(SteamController.Button.STEAM, loop); + } + + /** + * Constructs a Trigger instance around the View button's digital signal. + * + * @return a Trigger instance representing the View button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #view(EventLoop) + */ + public Trigger view() { + return view(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the View button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the View button's digital signal attached + * to the given loop. + */ + public Trigger view(EventLoop loop) { + return button(SteamController.Button.VIEW, 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(SteamController.Button.LEFT_STICK, 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(SteamController.Button.RIGHT_STICK, 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(SteamController.Button.LEFT_BUMPER, 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(SteamController.Button.RIGHT_BUMPER, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return button(SteamController.Button.DPAD_UP, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return button(SteamController.Button.DPAD_DOWN, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return button(SteamController.Button.DPAD_LEFT, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return button(SteamController.Button.DPAD_RIGHT, loop); + } + + /** + * Constructs a Trigger instance around the QAM button's digital signal. + * + * @return a Trigger instance representing the QAM button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #QAM(EventLoop) + */ + public Trigger QAM() { + return QAM(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the QAM button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the QAM button's digital signal attached + * to the given loop. + */ + public Trigger QAM(EventLoop loop) { + return button(SteamController.Button.QAM, loop); + } + + /** + * Constructs a Trigger instance around the Right Paddle 1 button's digital signal. + * + * @return a Trigger instance representing the Right Paddle 1 button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #rightPaddle1(EventLoop) + */ + public Trigger rightPaddle1() { + return rightPaddle1(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Right Paddle 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Right Paddle 1 button's digital signal attached + * to the given loop. + */ + public Trigger rightPaddle1(EventLoop loop) { + return button(SteamController.Button.RIGHT_PADDLE_1, loop); + } + + /** + * Constructs a Trigger instance around the Left Paddle 1 button's digital signal. + * + * @return a Trigger instance representing the Left Paddle 1 button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #leftPaddle1(EventLoop) + */ + public Trigger leftPaddle1() { + return leftPaddle1(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Left Paddle 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Left Paddle 1 button's digital signal attached + * to the given loop. + */ + public Trigger leftPaddle1(EventLoop loop) { + return button(SteamController.Button.LEFT_PADDLE_1, loop); + } + + /** + * Constructs a Trigger instance around the Right Paddle 2 button's digital signal. + * + * @return a Trigger instance representing the Right Paddle 2 button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #rightPaddle2(EventLoop) + */ + public Trigger rightPaddle2() { + return rightPaddle2(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Right Paddle 2 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Right Paddle 2 button's digital signal attached + * to the given loop. + */ + public Trigger rightPaddle2(EventLoop loop) { + return button(SteamController.Button.RIGHT_PADDLE_2, loop); + } + + /** + * Constructs a Trigger instance around the Left Paddle 2 button's digital signal. + * + * @return a Trigger instance representing the Left Paddle 2 button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #leftPaddle2(EventLoop) + */ + public Trigger leftPaddle2() { + return leftPaddle2(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Left Paddle 2 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Left Paddle 2 button's digital signal attached + * to the given loop. + */ + public Trigger leftPaddle2(EventLoop loop) { + return button(SteamController.Button.LEFT_PADDLE_2, loop); + } + + /** + * Constructs a Trigger instance around the Left Touchpad button's digital signal. + * + * @return a Trigger instance representing the Left Touchpad button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #leftTouchpad(EventLoop) + */ + public Trigger leftTouchpad() { + return leftTouchpad(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Left Touchpad button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Left Touchpad button's digital signal attached + * to the given loop. + */ + public Trigger leftTouchpad(EventLoop loop) { + return button(SteamController.Button.LEFT_TOUCHPAD, loop); + } + + /** + * Constructs a Trigger instance around the Right Touchpad button's digital signal. + * + * @return a Trigger instance representing the Right Touchpad button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #rightTouchpad(EventLoop) + */ + public Trigger rightTouchpad() { + return rightTouchpad(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Right Touchpad button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Right Touchpad button's digital signal attached + * to the given loop. + */ + public Trigger rightTouchpad(EventLoop loop) { + return button(SteamController.Button.RIGHT_TOUCHPAD, loop); + } + + /** + * Constructs a Trigger instance around the Left Stick Touch button's digital signal. + * + * @return a Trigger instance representing the Left Stick Touch button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #leftStickTouch(EventLoop) + */ + public Trigger leftStickTouch() { + return leftStickTouch(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Left Stick Touch button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Left Stick Touch button's digital signal attached + * to the given loop. + */ + public Trigger leftStickTouch(EventLoop loop) { + return button(SteamController.Button.LEFT_STICK_TOUCH, loop); + } + + /** + * Constructs a Trigger instance around the Right Stick Touch button's digital signal. + * + * @return a Trigger instance representing the Right Stick Touch button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #rightStickTouch(EventLoop) + */ + public Trigger rightStickTouch() { + return rightStickTouch(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Right Stick Touch button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Right Stick Touch button's digital signal attached + * to the given loop. + */ + public Trigger rightStickTouch(EventLoop loop) { + return button(SteamController.Button.RIGHT_STICK_TOUCH, loop); + } + + /** + * Constructs a Trigger instance around the Left Grip Touch button's digital signal. + * + * @return a Trigger instance representing the Left Grip Touch button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #leftGripTouch(EventLoop) + */ + public Trigger leftGripTouch() { + return leftGripTouch(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Left Grip Touch button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Left Grip Touch button's digital signal attached + * to the given loop. + */ + public Trigger leftGripTouch(EventLoop loop) { + return button(SteamController.Button.LEFT_GRIP_TOUCH, loop); + } + + /** + * Constructs a Trigger instance around the Right Grip Touch button's digital signal. + * + * @return a Trigger instance representing the Right Grip Touch button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #rightGripTouch(EventLoop) + */ + public Trigger rightGripTouch() { + return rightGripTouch(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Right Grip Touch button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Right Grip Touch button's digital signal attached + * to the given loop. + */ + public Trigger rightGripTouch(EventLoop loop) { + return button(SteamController.Button.RIGHT_GRIP_TOUCH, 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 axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger leftTrigger(double threshold, EventLoop loop) { + return axisGreaterThan( + SteamController.Axis.LEFT_TRIGGER, 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 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 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 axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger rightTrigger(double threshold, EventLoop loop) { + return axisGreaterThan( + SteamController.Axis.RIGHT_TRIGGER, 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 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 axis exceeds 0.5, + * attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button + * loop}. + */ + public Trigger rightTrigger() { + return rightTrigger(0.5); + } + + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan(SteamController.Axis axis, double threshold) { + return m_hid.axisLessThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the trigger to + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan( + SteamController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan(SteamController.Axis axis, double threshold) { + return m_hid.axisGreaterThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan( + SteamController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is greater than the + * provided threshold. + */ + public Trigger axisMagnitudeGreaterThan( + SteamController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command + * scheduler button loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the deadbanded axis value is active (non-zero). + */ + public Trigger axisMagnitudeGreaterThan(SteamController.Axis axis, double threshold) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The value of the axis. + */ + public double getAxis(SteamController.Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return m_controller.getRightX(); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return m_controller.getRightY(); + } + + /** + * Get the Left Trigger value of the controller. + * + * @return The axis value. + */ + public double getLeftTrigger() { + return m_controller.getLeftTrigger(); + } + + /** + * Get the Right Trigger value of the controller. + * + * @return The axis value. + */ + public double getRightTrigger() { + return m_controller.getRightTrigger(); + } +} diff --git a/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandSwitch2GCController.java b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandSwitch2GCController.java new file mode 100644 index 0000000000..f0691798b5 --- /dev/null +++ b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandSwitch2GCController.java @@ -0,0 +1,674 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY + +package org.wpilib.command2.button; + +import java.util.Objects; +import org.wpilib.command2.CommandScheduler; +import org.wpilib.driverstation.Switch2GCController; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link Switch2GCController} with {@link Trigger} factories for command-based. + * + * @see Switch2GCController + */ +@SuppressWarnings("MethodName") +public class CommandSwitch2GCController { + private final CommandGenericHID m_hid; + private final Switch2GCController m_controller; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandSwitch2GCController(int port) { + m_hid = CommandGenericHID.getCommandGenericHID(port); + m_controller = new Switch2GCController(m_hid.getHID()); + } + + /** + * Construct an instance of a controller with a Switch2GCController object. + * + * @param controller The Switch2GCController object to use for this controller. + */ + public CommandSwitch2GCController(Switch2GCController controller) { + m_controller = + Objects.requireNonNull(controller, "Provided Switch2GCController cannot be null"); + m_hid = new CommandGenericHID(m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public Switch2GCController getController() { + return m_controller; + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @return an event instance representing the button's digital signal attached to the {@link + * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #button(Switch2GCController.Button, EventLoop) + */ + public Trigger button(Switch2GCController.Button button) { + return button(button, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public Trigger button(Switch2GCController.Button button, EventLoop loop) { + return m_hid.button(button.value, loop); + } + + /** + * 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(Switch2GCController.Button.A, 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(Switch2GCController.Button.X, 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(Switch2GCController.Button.B, 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(Switch2GCController.Button.Y, loop); + } + + /** + * Constructs a Trigger instance around the Home button's digital signal. + * + * @return a Trigger instance representing the Home button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #home(EventLoop) + */ + public Trigger home() { + return home(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Home button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Home button's digital signal attached + * to the given loop. + */ + public Trigger home(EventLoop loop) { + return button(Switch2GCController.Button.HOME, 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(Switch2GCController.Button.START, loop); + } + + /** + * Constructs a Trigger instance around the ZL button's digital signal. + * + * @return a Trigger instance representing the ZL button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #ZL(EventLoop) + */ + public Trigger ZL() { + return ZL(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the ZL button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the ZL button's digital signal attached + * to the given loop. + */ + public Trigger ZL(EventLoop loop) { + return button(Switch2GCController.Button.ZL, loop); + } + + /** + * Constructs a Trigger instance around the Z button's digital signal. + * + * @return a Trigger instance representing the Z button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #Z(EventLoop) + */ + public Trigger Z() { + return Z(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Z button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Z button's digital signal attached + * to the given loop. + */ + public Trigger Z(EventLoop loop) { + return button(Switch2GCController.Button.Z, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return button(Switch2GCController.Button.DPAD_UP, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return button(Switch2GCController.Button.DPAD_DOWN, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return button(Switch2GCController.Button.DPAD_LEFT, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return button(Switch2GCController.Button.DPAD_RIGHT, loop); + } + + /** + * Constructs a Trigger instance around the Capture button's digital signal. + * + * @return a Trigger instance representing the Capture button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #capture(EventLoop) + */ + public Trigger capture() { + return capture(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Capture button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Capture button's digital signal attached + * to the given loop. + */ + public Trigger capture(EventLoop loop) { + return button(Switch2GCController.Button.CAPTURE, loop); + } + + /** + * Constructs a Trigger instance around the C button's digital signal. + * + * @return a Trigger instance representing the C button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #C(EventLoop) + */ + public Trigger C() { + return C(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the C button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the C button's digital signal attached + * to the given loop. + */ + public Trigger C(EventLoop loop) { + return button(Switch2GCController.Button.C, loop); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @return a Trigger instance representing the L button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #L(EventLoop) + */ + public Trigger L() { + return L(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L button's digital signal attached + * to the given loop. + */ + public Trigger L(EventLoop loop) { + return button(Switch2GCController.Button.L, loop); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @return a Trigger instance representing the R button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #R(EventLoop) + */ + public Trigger R() { + return R(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R button's digital signal attached + * to the given loop. + */ + public Trigger R(EventLoop loop) { + return button(Switch2GCController.Button.R, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the L 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 L Trigger axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger LTrigger(double threshold, EventLoop loop) { + return axisGreaterThan( + Switch2GCController.Axis.L_TRIGGER, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the L 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 L Trigger axis exceeds the provided + * threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler + * button loop}. + */ + public Trigger LTrigger(double threshold) { + return LTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the L 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 L Trigger axis exceeds 0.5, + * attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button + * loop}. + */ + public Trigger LTrigger() { + return LTrigger(0.5); + } + + + /** + * Constructs a Trigger instance around the axis value of the R 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 R Trigger axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger RTrigger(double threshold, EventLoop loop) { + return axisGreaterThan( + Switch2GCController.Axis.R_TRIGGER, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the R 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 R Trigger axis exceeds the provided + * threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler + * button loop}. + */ + public Trigger RTrigger(double threshold) { + return RTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the R 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 R Trigger axis exceeds 0.5, + * attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button + * loop}. + */ + public Trigger RTrigger() { + return RTrigger(0.5); + } + + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan(Switch2GCController.Axis axis, double threshold) { + return m_hid.axisLessThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the trigger to + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan( + Switch2GCController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan(Switch2GCController.Axis axis, double threshold) { + return m_hid.axisGreaterThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan( + Switch2GCController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is greater than the + * provided threshold. + */ + public Trigger axisMagnitudeGreaterThan( + Switch2GCController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command + * scheduler button loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the deadbanded axis value is active (non-zero). + */ + public Trigger axisMagnitudeGreaterThan(Switch2GCController.Axis axis, double threshold) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The value of the axis. + */ + public double getAxis(Switch2GCController.Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the C Stick X value of the controller. + * + * @return The axis value. + */ + public double getCStickX() { + return m_controller.getCStickX(); + } + + /** + * Get the C Stick Y value of the controller. + * + * @return The axis value. + */ + public double getCStickY() { + return m_controller.getCStickY(); + } + + /** + * Get the L Trigger value of the controller. + * + * @return The axis value. + */ + public double getLTrigger() { + return m_controller.getLTrigger(); + } + + /** + * Get the R Trigger value of the controller. + * + * @return The axis value. + */ + public double getRTrigger() { + return m_controller.getRTrigger(); + } +} diff --git a/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandSwitch2ProController.java b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandSwitch2ProController.java new file mode 100644 index 0000000000..be7bdb07fd --- /dev/null +++ b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandSwitch2ProController.java @@ -0,0 +1,740 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY + +package org.wpilib.command2.button; + +import java.util.Objects; +import org.wpilib.command2.CommandScheduler; +import org.wpilib.driverstation.Switch2ProController; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link Switch2ProController} with {@link Trigger} factories for command-based. + * + * @see Switch2ProController + */ +@SuppressWarnings("MethodName") +public class CommandSwitch2ProController { + private final CommandGenericHID m_hid; + private final Switch2ProController m_controller; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandSwitch2ProController(int port) { + m_hid = CommandGenericHID.getCommandGenericHID(port); + m_controller = new Switch2ProController(m_hid.getHID()); + } + + /** + * Construct an instance of a controller with a Switch2ProController object. + * + * @param controller The Switch2ProController object to use for this controller. + */ + public CommandSwitch2ProController(Switch2ProController controller) { + m_controller = + Objects.requireNonNull(controller, "Provided Switch2ProController cannot be null"); + m_hid = new CommandGenericHID(m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public Switch2ProController getController() { + return m_controller; + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @return an event instance representing the button's digital signal attached to the {@link + * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #button(Switch2ProController.Button, EventLoop) + */ + public Trigger button(Switch2ProController.Button button) { + return button(button, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public Trigger button(Switch2ProController.Button button, EventLoop loop) { + return m_hid.button(button.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(Switch2ProController.Button.B, loop); + } + + /** + * 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(Switch2ProController.Button.A, 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(Switch2ProController.Button.Y, 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(Switch2ProController.Button.X, loop); + } + + /** + * Constructs a Trigger instance around the Minus button's digital signal. + * + * @return a Trigger instance representing the Minus button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #minus(EventLoop) + */ + public Trigger minus() { + return minus(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Minus button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Minus button's digital signal attached + * to the given loop. + */ + public Trigger minus(EventLoop loop) { + return button(Switch2ProController.Button.MINUS, loop); + } + + /** + * Constructs a Trigger instance around the Home button's digital signal. + * + * @return a Trigger instance representing the Home button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #home(EventLoop) + */ + public Trigger home() { + return home(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Home button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Home button's digital signal attached + * to the given loop. + */ + public Trigger home(EventLoop loop) { + return button(Switch2ProController.Button.HOME, loop); + } + + /** + * Constructs a Trigger instance around the Plus button's digital signal. + * + * @return a Trigger instance representing the Plus button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #plus(EventLoop) + */ + public Trigger plus() { + return plus(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Plus button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Plus button's digital signal attached + * to the given loop. + */ + public Trigger plus(EventLoop loop) { + return button(Switch2ProController.Button.PLUS, 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(Switch2ProController.Button.LEFT_STICK, 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(Switch2ProController.Button.RIGHT_STICK, loop); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @return a Trigger instance representing the L button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #L(EventLoop) + */ + public Trigger L() { + return L(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L button's digital signal attached + * to the given loop. + */ + public Trigger L(EventLoop loop) { + return button(Switch2ProController.Button.L, loop); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @return a Trigger instance representing the R button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #R(EventLoop) + */ + public Trigger R() { + return R(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R button's digital signal attached + * to the given loop. + */ + public Trigger R(EventLoop loop) { + return button(Switch2ProController.Button.R, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return button(Switch2ProController.Button.DPAD_UP, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return button(Switch2ProController.Button.DPAD_DOWN, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return button(Switch2ProController.Button.DPAD_LEFT, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return button(Switch2ProController.Button.DPAD_RIGHT, loop); + } + + /** + * Constructs a Trigger instance around the Capture button's digital signal. + * + * @return a Trigger instance representing the Capture button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #capture(EventLoop) + */ + public Trigger capture() { + return capture(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Capture button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Capture button's digital signal attached + * to the given loop. + */ + public Trigger capture(EventLoop loop) { + return button(Switch2ProController.Button.CAPTURE, loop); + } + + /** + * Constructs a Trigger instance around the GR button's digital signal. + * + * @return a Trigger instance representing the GR button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #GR(EventLoop) + */ + public Trigger GR() { + return GR(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the GR button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the GR button's digital signal attached + * to the given loop. + */ + public Trigger GR(EventLoop loop) { + return button(Switch2ProController.Button.GR, loop); + } + + /** + * Constructs a Trigger instance around the GL button's digital signal. + * + * @return a Trigger instance representing the GL button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #GL(EventLoop) + */ + public Trigger GL() { + return GL(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the GL button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the GL button's digital signal attached + * to the given loop. + */ + public Trigger GL(EventLoop loop) { + return button(Switch2ProController.Button.GL, loop); + } + + /** + * Constructs a Trigger instance around the C button's digital signal. + * + * @return a Trigger instance representing the C button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #C(EventLoop) + */ + public Trigger C() { + return C(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the C button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the C button's digital signal attached + * to the given loop. + */ + public Trigger C(EventLoop loop) { + return button(Switch2ProController.Button.C, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the ZL. 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 ZL axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger ZL(double threshold, EventLoop loop) { + return axisGreaterThan( + Switch2ProController.Axis.ZL, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the ZL. 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 ZL axis exceeds the provided + * threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler + * button loop}. + */ + public Trigger ZL(double threshold) { + return ZL(threshold, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the ZL. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the ZL axis exceeds 0.5, + * attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button + * loop}. + */ + public Trigger ZL() { + return ZL(0.5); + } + + + /** + * Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger ZR(double threshold, EventLoop loop) { + return axisGreaterThan( + Switch2ProController.Axis.ZR, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided + * threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler + * button loop}. + */ + public Trigger ZR(double threshold) { + return ZR(threshold, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the ZR. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the ZR axis exceeds 0.5, + * attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button + * loop}. + */ + public Trigger ZR() { + return ZR(0.5); + } + + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan(Switch2ProController.Axis axis, double threshold) { + return m_hid.axisLessThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the trigger to + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan( + Switch2ProController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan(Switch2ProController.Axis axis, double threshold) { + return m_hid.axisGreaterThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan( + Switch2ProController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is greater than the + * provided threshold. + */ + public Trigger axisMagnitudeGreaterThan( + Switch2ProController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command + * scheduler button loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the deadbanded axis value is active (non-zero). + */ + public Trigger axisMagnitudeGreaterThan(Switch2ProController.Axis axis, double threshold) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The value of the axis. + */ + public double getAxis(Switch2ProController.Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return m_controller.getRightX(); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return m_controller.getRightY(); + } + + /** + * Get the ZL value of the controller. + * + * @return The axis value. + */ + public double getZL() { + return m_controller.getZL(); + } + + /** + * Get the ZR value of the controller. + * + * @return The axis value. + */ + public double getZR() { + return m_controller.getZR(); + } +} diff --git a/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandSwitchN64Controller.java b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandSwitchN64Controller.java new file mode 100644 index 0000000000..f1d5758e14 --- /dev/null +++ b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandSwitchN64Controller.java @@ -0,0 +1,591 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY + +package org.wpilib.command2.button; + +import java.util.Objects; +import org.wpilib.command2.CommandScheduler; +import org.wpilib.driverstation.SwitchN64Controller; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link SwitchN64Controller} with {@link Trigger} factories for command-based. + * + * @see SwitchN64Controller + */ +@SuppressWarnings("MethodName") +public class CommandSwitchN64Controller { + private final CommandGenericHID m_hid; + private final SwitchN64Controller m_controller; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandSwitchN64Controller(int port) { + m_hid = CommandGenericHID.getCommandGenericHID(port); + m_controller = new SwitchN64Controller(m_hid.getHID()); + } + + /** + * Construct an instance of a controller with a SwitchN64Controller object. + * + * @param controller The SwitchN64Controller object to use for this controller. + */ + public CommandSwitchN64Controller(SwitchN64Controller controller) { + m_controller = + Objects.requireNonNull(controller, "Provided SwitchN64Controller cannot be null"); + m_hid = new CommandGenericHID(m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public SwitchN64Controller getController() { + return m_controller; + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @return an event instance representing the button's digital signal attached to the {@link + * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #button(SwitchN64Controller.Button, EventLoop) + */ + public Trigger button(SwitchN64Controller.Button button) { + return button(button, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public Trigger button(SwitchN64Controller.Button button, EventLoop loop) { + return m_hid.button(button.value, loop); + } + + /** + * 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(SwitchN64Controller.Button.A, 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(SwitchN64Controller.Button.B, loop); + } + + /** + * Constructs a Trigger instance around the C Left button's digital signal. + * + * @return a Trigger instance representing the C Left button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #CLeft(EventLoop) + */ + public Trigger CLeft() { + return CLeft(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the C Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the C Left button's digital signal attached + * to the given loop. + */ + public Trigger CLeft(EventLoop loop) { + return button(SwitchN64Controller.Button.C_LEFT, loop); + } + + /** + * Constructs a Trigger instance around the C Up button's digital signal. + * + * @return a Trigger instance representing the C Up button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #CUp(EventLoop) + */ + public Trigger CUp() { + return CUp(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the C Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the C Up button's digital signal attached + * to the given loop. + */ + public Trigger CUp(EventLoop loop) { + return button(SwitchN64Controller.Button.C_UP, loop); + } + + /** + * Constructs a Trigger instance around the Capture button's digital signal. + * + * @return a Trigger instance representing the Capture button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #capture(EventLoop) + */ + public Trigger capture() { + return capture(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Capture button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Capture button's digital signal attached + * to the given loop. + */ + public Trigger capture(EventLoop loop) { + return button(SwitchN64Controller.Button.CAPTURE, loop); + } + + /** + * Constructs a Trigger instance around the Home button's digital signal. + * + * @return a Trigger instance representing the Home button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #home(EventLoop) + */ + public Trigger home() { + return home(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Home button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Home button's digital signal attached + * to the given loop. + */ + public Trigger home(EventLoop loop) { + return button(SwitchN64Controller.Button.HOME, 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(SwitchN64Controller.Button.START, loop); + } + + /** + * Constructs a Trigger instance around the C Down button's digital signal. + * + * @return a Trigger instance representing the C Down button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #CDown(EventLoop) + */ + public Trigger CDown() { + return CDown(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the C Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the C Down button's digital signal attached + * to the given loop. + */ + public Trigger CDown(EventLoop loop) { + return button(SwitchN64Controller.Button.C_DOWN, loop); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @return a Trigger instance representing the L button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #L(EventLoop) + */ + public Trigger L() { + return L(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L button's digital signal attached + * to the given loop. + */ + public Trigger L(EventLoop loop) { + return button(SwitchN64Controller.Button.L, loop); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @return a Trigger instance representing the R button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #R(EventLoop) + */ + public Trigger R() { + return R(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R button's digital signal attached + * to the given loop. + */ + public Trigger R(EventLoop loop) { + return button(SwitchN64Controller.Button.R, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return button(SwitchN64Controller.Button.DPAD_UP, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return button(SwitchN64Controller.Button.DPAD_DOWN, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return button(SwitchN64Controller.Button.DPAD_LEFT, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return button(SwitchN64Controller.Button.DPAD_RIGHT, loop); + } + + /** + * Constructs a Trigger instance around the C Right button's digital signal. + * + * @return a Trigger instance representing the C Right button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #CRight(EventLoop) + */ + public Trigger CRight() { + return CRight(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the C Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the C Right button's digital signal attached + * to the given loop. + */ + public Trigger CRight(EventLoop loop) { + return button(SwitchN64Controller.Button.C_RIGHT, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger ZR(double threshold, EventLoop loop) { + return axisGreaterThan( + SwitchN64Controller.Axis.ZR, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided + * threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler + * button loop}. + */ + public Trigger ZR(double threshold) { + return ZR(threshold, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the ZR. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the ZR axis exceeds 0.5, + * attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button + * loop}. + */ + public Trigger ZR() { + return ZR(0.5); + } + + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan(SwitchN64Controller.Axis axis, double threshold) { + return m_hid.axisLessThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the trigger to + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan( + SwitchN64Controller.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan(SwitchN64Controller.Axis axis, double threshold) { + return m_hid.axisGreaterThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan( + SwitchN64Controller.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is greater than the + * provided threshold. + */ + public Trigger axisMagnitudeGreaterThan( + SwitchN64Controller.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command + * scheduler button loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the deadbanded axis value is active (non-zero). + */ + public Trigger axisMagnitudeGreaterThan(SwitchN64Controller.Axis axis, double threshold) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The value of the axis. + */ + public double getAxis(SwitchN64Controller.Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the Z Axis value of the controller. + * + * @return The axis value. + */ + public double getZAxis() { + return m_controller.getZAxis(); + } + + /** + * Get the ZR value of the controller. + * + * @return The axis value. + */ + public double getZR() { + return m_controller.getZR(); + } +} diff --git a/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandSwitchProController.java b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandSwitchProController.java new file mode 100644 index 0000000000..c9eb181f12 --- /dev/null +++ b/commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandSwitchProController.java @@ -0,0 +1,674 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY + +package org.wpilib.command2.button; + +import java.util.Objects; +import org.wpilib.command2.CommandScheduler; +import org.wpilib.driverstation.SwitchProController; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link SwitchProController} with {@link Trigger} factories for command-based. + * + * @see SwitchProController + */ +@SuppressWarnings("MethodName") +public class CommandSwitchProController { + private final CommandGenericHID m_hid; + private final SwitchProController m_controller; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandSwitchProController(int port) { + m_hid = CommandGenericHID.getCommandGenericHID(port); + m_controller = new SwitchProController(m_hid.getHID()); + } + + /** + * Construct an instance of a controller with a SwitchProController object. + * + * @param controller The SwitchProController object to use for this controller. + */ + public CommandSwitchProController(SwitchProController controller) { + m_controller = + Objects.requireNonNull(controller, "Provided SwitchProController cannot be null"); + m_hid = new CommandGenericHID(m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public SwitchProController getController() { + return m_controller; + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @return an event instance representing the button's digital signal attached to the {@link + * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #button(SwitchProController.Button, EventLoop) + */ + public Trigger button(SwitchProController.Button button) { + return button(button, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public Trigger button(SwitchProController.Button button, EventLoop loop) { + return m_hid.button(button.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(SwitchProController.Button.B, loop); + } + + /** + * 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(SwitchProController.Button.A, 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(SwitchProController.Button.Y, 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(SwitchProController.Button.X, loop); + } + + /** + * Constructs a Trigger instance around the Minus button's digital signal. + * + * @return a Trigger instance representing the Minus button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #minus(EventLoop) + */ + public Trigger minus() { + return minus(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Minus button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Minus button's digital signal attached + * to the given loop. + */ + public Trigger minus(EventLoop loop) { + return button(SwitchProController.Button.MINUS, loop); + } + + /** + * Constructs a Trigger instance around the Home button's digital signal. + * + * @return a Trigger instance representing the Home button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #home(EventLoop) + */ + public Trigger home() { + return home(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Home button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Home button's digital signal attached + * to the given loop. + */ + public Trigger home(EventLoop loop) { + return button(SwitchProController.Button.HOME, loop); + } + + /** + * Constructs a Trigger instance around the Plus button's digital signal. + * + * @return a Trigger instance representing the Plus button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #plus(EventLoop) + */ + public Trigger plus() { + return plus(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Plus button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Plus button's digital signal attached + * to the given loop. + */ + public Trigger plus(EventLoop loop) { + return button(SwitchProController.Button.PLUS, 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(SwitchProController.Button.LEFT_STICK, 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(SwitchProController.Button.RIGHT_STICK, loop); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @return a Trigger instance representing the L button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #L(EventLoop) + */ + public Trigger L() { + return L(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L button's digital signal attached + * to the given loop. + */ + public Trigger L(EventLoop loop) { + return button(SwitchProController.Button.L, loop); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @return a Trigger instance representing the R button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #R(EventLoop) + */ + public Trigger R() { + return R(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R button's digital signal attached + * to the given loop. + */ + public Trigger R(EventLoop loop) { + return button(SwitchProController.Button.R, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return button(SwitchProController.Button.DPAD_UP, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return button(SwitchProController.Button.DPAD_DOWN, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return button(SwitchProController.Button.DPAD_LEFT, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return button(SwitchProController.Button.DPAD_RIGHT, loop); + } + + /** + * Constructs a Trigger instance around the Capture button's digital signal. + * + * @return a Trigger instance representing the Capture button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #capture(EventLoop) + */ + public Trigger capture() { + return capture(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the Capture button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Capture button's digital signal attached + * to the given loop. + */ + public Trigger capture(EventLoop loop) { + return button(SwitchProController.Button.CAPTURE, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the ZL. 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 ZL axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger ZL(double threshold, EventLoop loop) { + return axisGreaterThan( + SwitchProController.Axis.ZL, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the ZL. 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 ZL axis exceeds the provided + * threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler + * button loop}. + */ + public Trigger ZL(double threshold) { + return ZL(threshold, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the ZL. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the ZL axis exceeds 0.5, + * attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button + * loop}. + */ + public Trigger ZL() { + return ZL(0.5); + } + + + /** + * Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger ZR(double threshold, EventLoop loop) { + return axisGreaterThan( + SwitchProController.Axis.ZR, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided + * threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler + * button loop}. + */ + public Trigger ZR(double threshold) { + return ZR(threshold, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the ZR. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the ZR axis exceeds 0.5, + * attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button + * loop}. + */ + public Trigger ZR() { + return ZR(0.5); + } + + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan(SwitchProController.Axis axis, double threshold) { + return m_hid.axisLessThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the trigger to + * @return a Trigger instance that is true when the axis value is less than the provided + * threshold. + */ + public Trigger axisLessThan( + SwitchProController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis value is less than {@code threshold}, + * attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button + * loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan(SwitchProController.Axis axis, double threshold) { + return m_hid.axisGreaterThan(axis.value, threshold); + } + + /** + * Constructs a Trigger instance that is true when the axis value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis value is greater than the provided + * threshold. + */ + public Trigger axisGreaterThan( + SwitchProController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is greater than the + * provided threshold. + */ + public Trigger axisMagnitudeGreaterThan( + SwitchProController.Axis axis, double threshold, EventLoop loop) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop); + } + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code + * threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command + * scheduler button loop}. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @return a Trigger instance that is true when the deadbanded axis value is active (non-zero). + */ + public Trigger axisMagnitudeGreaterThan(SwitchProController.Axis axis, double threshold) { + return m_hid.axisMagnitudeGreaterThan(axis.value, threshold); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The value of the axis. + */ + public double getAxis(SwitchProController.Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return m_controller.getRightX(); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return m_controller.getRightY(); + } + + /** + * Get the ZL value of the controller. + * + * @return The axis value. + */ + public double getZL() { + return m_controller.getZL(); + } + + /** + * Get the ZR value of the controller. + * + * @return The axis value. + */ + public double getZR() { + return m_controller.getZR(); + } +} diff --git a/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandDualSenseEdgeController.cpp b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandDualSenseEdgeController.cpp new file mode 100644 index 0000000000..7eb5511682 --- /dev/null +++ b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandDualSenseEdgeController.cpp @@ -0,0 +1,226 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#include "wpi/commands2/button/CommandDualSenseEdgeController.hpp" + +using namespace wpi::cmd; + +CommandDualSenseEdgeController::CommandDualSenseEdgeController(int port) + : m_hid{&CommandGenericHID::GetCommandGenericHID(port)} { + m_ownedController = + std::make_unique(m_hid->GetHID()); + m_controller = m_ownedController.get(); +} + +CommandDualSenseEdgeController::CommandDualSenseEdgeController( + wpi::DualSenseEdgeController* controller) + : m_ownedHid{std::make_unique(controller->GetHID())}, + m_hid{m_ownedHid.get()}, + m_controller{controller} {} + +CommandGenericHID& CommandDualSenseEdgeController::GetHID() { + return *m_hid; +} + +wpi::DualSenseEdgeController& +CommandDualSenseEdgeController::GetController() { + return *m_controller; +} + +const wpi::DualSenseEdgeController& +CommandDualSenseEdgeController::GetController() const { + return *m_controller; +} + +Trigger CommandDualSenseEdgeController::Button( + enum wpi::DualSenseEdgeController::Button button, + wpi::EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + + +Trigger CommandDualSenseEdgeController::Cross( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::CROSS, + loop); +} + +Trigger CommandDualSenseEdgeController::Circle( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::CIRCLE, + loop); +} + +Trigger CommandDualSenseEdgeController::Square( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::SQUARE, + loop); +} + +Trigger CommandDualSenseEdgeController::Triangle( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::TRIANGLE, + loop); +} + +Trigger CommandDualSenseEdgeController::Create( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::CREATE, + loop); +} + +Trigger CommandDualSenseEdgeController::PS( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::PS, + loop); +} + +Trigger CommandDualSenseEdgeController::Options( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::OPTIONS, + loop); +} + +Trigger CommandDualSenseEdgeController::L3( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::L3, + loop); +} + +Trigger CommandDualSenseEdgeController::R3( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::R3, + loop); +} + +Trigger CommandDualSenseEdgeController::L1( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::L1, + loop); +} + +Trigger CommandDualSenseEdgeController::R1( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::R1, + loop); +} + +Trigger CommandDualSenseEdgeController::DpadUp( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::DPAD_UP, + loop); +} + +Trigger CommandDualSenseEdgeController::DpadDown( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::DPAD_DOWN, + loop); +} + +Trigger CommandDualSenseEdgeController::DpadLeft( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::DPAD_LEFT, + loop); +} + +Trigger CommandDualSenseEdgeController::DpadRight( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::DPAD_RIGHT, + loop); +} + +Trigger CommandDualSenseEdgeController::Microphone( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::MICROPHONE, + loop); +} + +Trigger CommandDualSenseEdgeController::RightPaddle1( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::RIGHT_PADDLE_1, + loop); +} + +Trigger CommandDualSenseEdgeController::LeftPaddle1( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::LEFT_PADDLE_1, + loop); +} + +Trigger CommandDualSenseEdgeController::Touchpad( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::TOUCHPAD, + loop); +} + +Trigger CommandDualSenseEdgeController::LeftFunction( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::LEFT_FUNCTION, + loop); +} + +Trigger CommandDualSenseEdgeController::RightFunction( + wpi::EventLoop* loop) const { + return Button(wpi::DualSenseEdgeController::Button::RIGHT_FUNCTION, + loop); +} + +Trigger CommandDualSenseEdgeController::L2( + double threshold, wpi::EventLoop* loop) const { + return AxisGreaterThan( + wpi::DualSenseEdgeController::Axis::L2, + threshold, loop); +} + +Trigger CommandDualSenseEdgeController::R2( + double threshold, wpi::EventLoop* loop) const { + return AxisGreaterThan( + wpi::DualSenseEdgeController::Axis::R2, + threshold, loop); +} + +Trigger CommandDualSenseEdgeController::AxisLessThan( + wpi::DualSenseEdgeController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +Trigger CommandDualSenseEdgeController::AxisGreaterThan( + wpi::DualSenseEdgeController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +Trigger CommandDualSenseEdgeController::AxisMagnitudeGreaterThan( + wpi::DualSenseEdgeController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisMagnitudeGreaterThan(static_cast(axis), threshold, + loop); +} + + +double CommandDualSenseEdgeController::GetLeftX() const { + return m_controller->GetLeftX(); +} + +double CommandDualSenseEdgeController::GetLeftY() const { + return m_controller->GetLeftY(); +} + +double CommandDualSenseEdgeController::GetRightX() const { + return m_controller->GetRightX(); +} + +double CommandDualSenseEdgeController::GetRightY() const { + return m_controller->GetRightY(); +} + +double CommandDualSenseEdgeController::GetL2() const { + return m_controller->GetL2(); +} + +double CommandDualSenseEdgeController::GetR2() const { + return m_controller->GetR2(); +} diff --git a/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandDualShock4Controller.cpp b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandDualShock4Controller.cpp new file mode 100644 index 0000000000..891fd9b171 --- /dev/null +++ b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandDualShock4Controller.cpp @@ -0,0 +1,196 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#include "wpi/commands2/button/CommandDualShock4Controller.hpp" + +using namespace wpi::cmd; + +CommandDualShock4Controller::CommandDualShock4Controller(int port) + : m_hid{&CommandGenericHID::GetCommandGenericHID(port)} { + m_ownedController = + std::make_unique(m_hid->GetHID()); + m_controller = m_ownedController.get(); +} + +CommandDualShock4Controller::CommandDualShock4Controller( + wpi::DualShock4Controller* controller) + : m_ownedHid{std::make_unique(controller->GetHID())}, + m_hid{m_ownedHid.get()}, + m_controller{controller} {} + +CommandGenericHID& CommandDualShock4Controller::GetHID() { + return *m_hid; +} + +wpi::DualShock4Controller& +CommandDualShock4Controller::GetController() { + return *m_controller; +} + +const wpi::DualShock4Controller& +CommandDualShock4Controller::GetController() const { + return *m_controller; +} + +Trigger CommandDualShock4Controller::Button( + enum wpi::DualShock4Controller::Button button, + wpi::EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + + +Trigger CommandDualShock4Controller::Cross( + wpi::EventLoop* loop) const { + return Button(wpi::DualShock4Controller::Button::CROSS, + loop); +} + +Trigger CommandDualShock4Controller::Circle( + wpi::EventLoop* loop) const { + return Button(wpi::DualShock4Controller::Button::CIRCLE, + loop); +} + +Trigger CommandDualShock4Controller::Square( + wpi::EventLoop* loop) const { + return Button(wpi::DualShock4Controller::Button::SQUARE, + loop); +} + +Trigger CommandDualShock4Controller::Triangle( + wpi::EventLoop* loop) const { + return Button(wpi::DualShock4Controller::Button::TRIANGLE, + loop); +} + +Trigger CommandDualShock4Controller::Share( + wpi::EventLoop* loop) const { + return Button(wpi::DualShock4Controller::Button::SHARE, + loop); +} + +Trigger CommandDualShock4Controller::PS( + wpi::EventLoop* loop) const { + return Button(wpi::DualShock4Controller::Button::PS, + loop); +} + +Trigger CommandDualShock4Controller::Options( + wpi::EventLoop* loop) const { + return Button(wpi::DualShock4Controller::Button::OPTIONS, + loop); +} + +Trigger CommandDualShock4Controller::L3( + wpi::EventLoop* loop) const { + return Button(wpi::DualShock4Controller::Button::L3, + loop); +} + +Trigger CommandDualShock4Controller::R3( + wpi::EventLoop* loop) const { + return Button(wpi::DualShock4Controller::Button::R3, + loop); +} + +Trigger CommandDualShock4Controller::L1( + wpi::EventLoop* loop) const { + return Button(wpi::DualShock4Controller::Button::L1, + loop); +} + +Trigger CommandDualShock4Controller::R1( + wpi::EventLoop* loop) const { + return Button(wpi::DualShock4Controller::Button::R1, + loop); +} + +Trigger CommandDualShock4Controller::DpadUp( + wpi::EventLoop* loop) const { + return Button(wpi::DualShock4Controller::Button::DPAD_UP, + loop); +} + +Trigger CommandDualShock4Controller::DpadDown( + wpi::EventLoop* loop) const { + return Button(wpi::DualShock4Controller::Button::DPAD_DOWN, + loop); +} + +Trigger CommandDualShock4Controller::DpadLeft( + wpi::EventLoop* loop) const { + return Button(wpi::DualShock4Controller::Button::DPAD_LEFT, + loop); +} + +Trigger CommandDualShock4Controller::DpadRight( + wpi::EventLoop* loop) const { + return Button(wpi::DualShock4Controller::Button::DPAD_RIGHT, + loop); +} + +Trigger CommandDualShock4Controller::Touchpad( + wpi::EventLoop* loop) const { + return Button(wpi::DualShock4Controller::Button::TOUCHPAD, + loop); +} + +Trigger CommandDualShock4Controller::L2( + double threshold, wpi::EventLoop* loop) const { + return AxisGreaterThan( + wpi::DualShock4Controller::Axis::L2, + threshold, loop); +} + +Trigger CommandDualShock4Controller::R2( + double threshold, wpi::EventLoop* loop) const { + return AxisGreaterThan( + wpi::DualShock4Controller::Axis::R2, + threshold, loop); +} + +Trigger CommandDualShock4Controller::AxisLessThan( + wpi::DualShock4Controller::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +Trigger CommandDualShock4Controller::AxisGreaterThan( + wpi::DualShock4Controller::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +Trigger CommandDualShock4Controller::AxisMagnitudeGreaterThan( + wpi::DualShock4Controller::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisMagnitudeGreaterThan(static_cast(axis), threshold, + loop); +} + + +double CommandDualShock4Controller::GetLeftX() const { + return m_controller->GetLeftX(); +} + +double CommandDualShock4Controller::GetLeftY() const { + return m_controller->GetLeftY(); +} + +double CommandDualShock4Controller::GetRightX() const { + return m_controller->GetRightX(); +} + +double CommandDualShock4Controller::GetRightY() const { + return m_controller->GetRightY(); +} + +double CommandDualShock4Controller::GetL2() const { + return m_controller->GetL2(); +} + +double CommandDualShock4Controller::GetR2() const { + return m_controller->GetR2(); +} diff --git a/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandGameCubeController.cpp b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandGameCubeController.cpp new file mode 100644 index 0000000000..4108a39669 --- /dev/null +++ b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandGameCubeController.cpp @@ -0,0 +1,172 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#include "wpi/commands2/button/CommandGameCubeController.hpp" + +using namespace wpi::cmd; + +CommandGameCubeController::CommandGameCubeController(int port) + : m_hid{&CommandGenericHID::GetCommandGenericHID(port)} { + m_ownedController = + std::make_unique(m_hid->GetHID()); + m_controller = m_ownedController.get(); +} + +CommandGameCubeController::CommandGameCubeController( + wpi::GameCubeController* controller) + : m_ownedHid{std::make_unique(controller->GetHID())}, + m_hid{m_ownedHid.get()}, + m_controller{controller} {} + +CommandGenericHID& CommandGameCubeController::GetHID() { + return *m_hid; +} + +wpi::GameCubeController& +CommandGameCubeController::GetController() { + return *m_controller; +} + +const wpi::GameCubeController& +CommandGameCubeController::GetController() const { + return *m_controller; +} + +Trigger CommandGameCubeController::Button( + enum wpi::GameCubeController::Button button, + wpi::EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + + +Trigger CommandGameCubeController::A( + wpi::EventLoop* loop) const { + return Button(wpi::GameCubeController::Button::A, + loop); +} + +Trigger CommandGameCubeController::X( + wpi::EventLoop* loop) const { + return Button(wpi::GameCubeController::Button::X, + loop); +} + +Trigger CommandGameCubeController::B( + wpi::EventLoop* loop) const { + return Button(wpi::GameCubeController::Button::B, + loop); +} + +Trigger CommandGameCubeController::Y( + wpi::EventLoop* loop) const { + return Button(wpi::GameCubeController::Button::Y, + loop); +} + +Trigger CommandGameCubeController::Start( + wpi::EventLoop* loop) const { + return Button(wpi::GameCubeController::Button::START, + loop); +} + +Trigger CommandGameCubeController::Z( + wpi::EventLoop* loop) const { + return Button(wpi::GameCubeController::Button::Z, + loop); +} + +Trigger CommandGameCubeController::DpadUp( + wpi::EventLoop* loop) const { + return Button(wpi::GameCubeController::Button::DPAD_UP, + loop); +} + +Trigger CommandGameCubeController::DpadDown( + wpi::EventLoop* loop) const { + return Button(wpi::GameCubeController::Button::DPAD_DOWN, + loop); +} + +Trigger CommandGameCubeController::DpadLeft( + wpi::EventLoop* loop) const { + return Button(wpi::GameCubeController::Button::DPAD_LEFT, + loop); +} + +Trigger CommandGameCubeController::DpadRight( + wpi::EventLoop* loop) const { + return Button(wpi::GameCubeController::Button::DPAD_RIGHT, + loop); +} + +Trigger CommandGameCubeController::L( + wpi::EventLoop* loop) const { + return Button(wpi::GameCubeController::Button::L, + loop); +} + +Trigger CommandGameCubeController::R( + wpi::EventLoop* loop) const { + return Button(wpi::GameCubeController::Button::R, + loop); +} + +Trigger CommandGameCubeController::LTrigger( + double threshold, wpi::EventLoop* loop) const { + return AxisGreaterThan( + wpi::GameCubeController::Axis::L_TRIGGER, + threshold, loop); +} + +Trigger CommandGameCubeController::RTrigger( + double threshold, wpi::EventLoop* loop) const { + return AxisGreaterThan( + wpi::GameCubeController::Axis::R_TRIGGER, + threshold, loop); +} + +Trigger CommandGameCubeController::AxisLessThan( + wpi::GameCubeController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +Trigger CommandGameCubeController::AxisGreaterThan( + wpi::GameCubeController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +Trigger CommandGameCubeController::AxisMagnitudeGreaterThan( + wpi::GameCubeController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisMagnitudeGreaterThan(static_cast(axis), threshold, + loop); +} + + +double CommandGameCubeController::GetLeftX() const { + return m_controller->GetLeftX(); +} + +double CommandGameCubeController::GetLeftY() const { + return m_controller->GetLeftY(); +} + +double CommandGameCubeController::GetCStickX() const { + return m_controller->GetCStickX(); +} + +double CommandGameCubeController::GetCStickY() const { + return m_controller->GetCStickY(); +} + +double CommandGameCubeController::GetLTrigger() const { + return m_controller->GetLTrigger(); +} + +double CommandGameCubeController::GetRTrigger() const { + return m_controller->GetRTrigger(); +} diff --git a/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandLogitechF310Controller.cpp b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandLogitechF310Controller.cpp new file mode 100644 index 0000000000..a7e64c68a6 --- /dev/null +++ b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandLogitechF310Controller.cpp @@ -0,0 +1,190 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#include "wpi/commands2/button/CommandLogitechF310Controller.hpp" + +using namespace wpi::cmd; + +CommandLogitechF310Controller::CommandLogitechF310Controller(int port) + : m_hid{&CommandGenericHID::GetCommandGenericHID(port)} { + m_ownedController = + std::make_unique(m_hid->GetHID()); + m_controller = m_ownedController.get(); +} + +CommandLogitechF310Controller::CommandLogitechF310Controller( + wpi::LogitechF310Controller* controller) + : m_ownedHid{std::make_unique(controller->GetHID())}, + m_hid{m_ownedHid.get()}, + m_controller{controller} {} + +CommandGenericHID& CommandLogitechF310Controller::GetHID() { + return *m_hid; +} + +wpi::LogitechF310Controller& +CommandLogitechF310Controller::GetController() { + return *m_controller; +} + +const wpi::LogitechF310Controller& +CommandLogitechF310Controller::GetController() const { + return *m_controller; +} + +Trigger CommandLogitechF310Controller::Button( + enum wpi::LogitechF310Controller::Button button, + wpi::EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + + +Trigger CommandLogitechF310Controller::A( + wpi::EventLoop* loop) const { + return Button(wpi::LogitechF310Controller::Button::A, + loop); +} + +Trigger CommandLogitechF310Controller::B( + wpi::EventLoop* loop) const { + return Button(wpi::LogitechF310Controller::Button::B, + loop); +} + +Trigger CommandLogitechF310Controller::X( + wpi::EventLoop* loop) const { + return Button(wpi::LogitechF310Controller::Button::X, + loop); +} + +Trigger CommandLogitechF310Controller::Y( + wpi::EventLoop* loop) const { + return Button(wpi::LogitechF310Controller::Button::Y, + loop); +} + +Trigger CommandLogitechF310Controller::Back( + wpi::EventLoop* loop) const { + return Button(wpi::LogitechF310Controller::Button::BACK, + loop); +} + +Trigger CommandLogitechF310Controller::Logitech( + wpi::EventLoop* loop) const { + return Button(wpi::LogitechF310Controller::Button::LOGITECH, + loop); +} + +Trigger CommandLogitechF310Controller::Start( + wpi::EventLoop* loop) const { + return Button(wpi::LogitechF310Controller::Button::START, + loop); +} + +Trigger CommandLogitechF310Controller::LeftStick( + wpi::EventLoop* loop) const { + return Button(wpi::LogitechF310Controller::Button::LEFT_STICK, + loop); +} + +Trigger CommandLogitechF310Controller::RightStick( + wpi::EventLoop* loop) const { + return Button(wpi::LogitechF310Controller::Button::RIGHT_STICK, + loop); +} + +Trigger CommandLogitechF310Controller::LeftBumper( + wpi::EventLoop* loop) const { + return Button(wpi::LogitechF310Controller::Button::LEFT_BUMPER, + loop); +} + +Trigger CommandLogitechF310Controller::RightBumper( + wpi::EventLoop* loop) const { + return Button(wpi::LogitechF310Controller::Button::RIGHT_BUMPER, + loop); +} + +Trigger CommandLogitechF310Controller::DpadUp( + wpi::EventLoop* loop) const { + return Button(wpi::LogitechF310Controller::Button::DPAD_UP, + loop); +} + +Trigger CommandLogitechF310Controller::DpadDown( + wpi::EventLoop* loop) const { + return Button(wpi::LogitechF310Controller::Button::DPAD_DOWN, + loop); +} + +Trigger CommandLogitechF310Controller::DpadLeft( + wpi::EventLoop* loop) const { + return Button(wpi::LogitechF310Controller::Button::DPAD_LEFT, + loop); +} + +Trigger CommandLogitechF310Controller::DpadRight( + wpi::EventLoop* loop) const { + return Button(wpi::LogitechF310Controller::Button::DPAD_RIGHT, + loop); +} + +Trigger CommandLogitechF310Controller::LeftTrigger( + double threshold, wpi::EventLoop* loop) const { + return AxisGreaterThan( + wpi::LogitechF310Controller::Axis::LEFT_TRIGGER, + threshold, loop); +} + +Trigger CommandLogitechF310Controller::RightTrigger( + double threshold, wpi::EventLoop* loop) const { + return AxisGreaterThan( + wpi::LogitechF310Controller::Axis::RIGHT_TRIGGER, + threshold, loop); +} + +Trigger CommandLogitechF310Controller::AxisLessThan( + wpi::LogitechF310Controller::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +Trigger CommandLogitechF310Controller::AxisGreaterThan( + wpi::LogitechF310Controller::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +Trigger CommandLogitechF310Controller::AxisMagnitudeGreaterThan( + wpi::LogitechF310Controller::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisMagnitudeGreaterThan(static_cast(axis), threshold, + loop); +} + + +double CommandLogitechF310Controller::GetLeftX() const { + return m_controller->GetLeftX(); +} + +double CommandLogitechF310Controller::GetLeftY() const { + return m_controller->GetLeftY(); +} + +double CommandLogitechF310Controller::GetRightX() const { + return m_controller->GetRightX(); +} + +double CommandLogitechF310Controller::GetRightY() const { + return m_controller->GetRightY(); +} + +double CommandLogitechF310Controller::GetLeftTrigger() const { + return m_controller->GetLeftTrigger(); +} + +double CommandLogitechF310Controller::GetRightTrigger() const { + return m_controller->GetRightTrigger(); +} diff --git a/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandSteamController.cpp b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandSteamController.cpp new file mode 100644 index 0000000000..30c64c3c13 --- /dev/null +++ b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandSteamController.cpp @@ -0,0 +1,256 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#include "wpi/commands2/button/CommandSteamController.hpp" + +using namespace wpi::cmd; + +CommandSteamController::CommandSteamController(int port) + : m_hid{&CommandGenericHID::GetCommandGenericHID(port)} { + m_ownedController = + std::make_unique(m_hid->GetHID()); + m_controller = m_ownedController.get(); +} + +CommandSteamController::CommandSteamController( + wpi::SteamController* controller) + : m_ownedHid{std::make_unique(controller->GetHID())}, + m_hid{m_ownedHid.get()}, + m_controller{controller} {} + +CommandGenericHID& CommandSteamController::GetHID() { + return *m_hid; +} + +wpi::SteamController& +CommandSteamController::GetController() { + return *m_controller; +} + +const wpi::SteamController& +CommandSteamController::GetController() const { + return *m_controller; +} + +Trigger CommandSteamController::Button( + enum wpi::SteamController::Button button, + wpi::EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + + +Trigger CommandSteamController::A( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::A, + loop); +} + +Trigger CommandSteamController::B( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::B, + loop); +} + +Trigger CommandSteamController::X( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::X, + loop); +} + +Trigger CommandSteamController::Y( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::Y, + loop); +} + +Trigger CommandSteamController::Menu( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::MENU, + loop); +} + +Trigger CommandSteamController::Steam( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::STEAM, + loop); +} + +Trigger CommandSteamController::View( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::VIEW, + loop); +} + +Trigger CommandSteamController::LeftStick( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::LEFT_STICK, + loop); +} + +Trigger CommandSteamController::RightStick( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::RIGHT_STICK, + loop); +} + +Trigger CommandSteamController::LeftBumper( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::LEFT_BUMPER, + loop); +} + +Trigger CommandSteamController::RightBumper( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::RIGHT_BUMPER, + loop); +} + +Trigger CommandSteamController::DpadUp( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::DPAD_UP, + loop); +} + +Trigger CommandSteamController::DpadDown( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::DPAD_DOWN, + loop); +} + +Trigger CommandSteamController::DpadLeft( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::DPAD_LEFT, + loop); +} + +Trigger CommandSteamController::DpadRight( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::DPAD_RIGHT, + loop); +} + +Trigger CommandSteamController::QAM( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::QAM, + loop); +} + +Trigger CommandSteamController::RightPaddle1( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::RIGHT_PADDLE_1, + loop); +} + +Trigger CommandSteamController::LeftPaddle1( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::LEFT_PADDLE_1, + loop); +} + +Trigger CommandSteamController::RightPaddle2( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::RIGHT_PADDLE_2, + loop); +} + +Trigger CommandSteamController::LeftPaddle2( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::LEFT_PADDLE_2, + loop); +} + +Trigger CommandSteamController::LeftTouchpad( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::LEFT_TOUCHPAD, + loop); +} + +Trigger CommandSteamController::RightTouchpad( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::RIGHT_TOUCHPAD, + loop); +} + +Trigger CommandSteamController::LeftStickTouch( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::LEFT_STICK_TOUCH, + loop); +} + +Trigger CommandSteamController::RightStickTouch( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::RIGHT_STICK_TOUCH, + loop); +} + +Trigger CommandSteamController::LeftGripTouch( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::LEFT_GRIP_TOUCH, + loop); +} + +Trigger CommandSteamController::RightGripTouch( + wpi::EventLoop* loop) const { + return Button(wpi::SteamController::Button::RIGHT_GRIP_TOUCH, + loop); +} + +Trigger CommandSteamController::LeftTrigger( + double threshold, wpi::EventLoop* loop) const { + return AxisGreaterThan( + wpi::SteamController::Axis::LEFT_TRIGGER, + threshold, loop); +} + +Trigger CommandSteamController::RightTrigger( + double threshold, wpi::EventLoop* loop) const { + return AxisGreaterThan( + wpi::SteamController::Axis::RIGHT_TRIGGER, + threshold, loop); +} + +Trigger CommandSteamController::AxisLessThan( + wpi::SteamController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +Trigger CommandSteamController::AxisGreaterThan( + wpi::SteamController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +Trigger CommandSteamController::AxisMagnitudeGreaterThan( + wpi::SteamController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisMagnitudeGreaterThan(static_cast(axis), threshold, + loop); +} + + +double CommandSteamController::GetLeftX() const { + return m_controller->GetLeftX(); +} + +double CommandSteamController::GetLeftY() const { + return m_controller->GetLeftY(); +} + +double CommandSteamController::GetRightX() const { + return m_controller->GetRightX(); +} + +double CommandSteamController::GetRightY() const { + return m_controller->GetRightY(); +} + +double CommandSteamController::GetLeftTrigger() const { + return m_controller->GetLeftTrigger(); +} + +double CommandSteamController::GetRightTrigger() const { + return m_controller->GetRightTrigger(); +} diff --git a/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandSwitch2GCController.cpp b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandSwitch2GCController.cpp new file mode 100644 index 0000000000..8ab9746d2a --- /dev/null +++ b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandSwitch2GCController.cpp @@ -0,0 +1,196 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#include "wpi/commands2/button/CommandSwitch2GCController.hpp" + +using namespace wpi::cmd; + +CommandSwitch2GCController::CommandSwitch2GCController(int port) + : m_hid{&CommandGenericHID::GetCommandGenericHID(port)} { + m_ownedController = + std::make_unique(m_hid->GetHID()); + m_controller = m_ownedController.get(); +} + +CommandSwitch2GCController::CommandSwitch2GCController( + wpi::Switch2GCController* controller) + : m_ownedHid{std::make_unique(controller->GetHID())}, + m_hid{m_ownedHid.get()}, + m_controller{controller} {} + +CommandGenericHID& CommandSwitch2GCController::GetHID() { + return *m_hid; +} + +wpi::Switch2GCController& +CommandSwitch2GCController::GetController() { + return *m_controller; +} + +const wpi::Switch2GCController& +CommandSwitch2GCController::GetController() const { + return *m_controller; +} + +Trigger CommandSwitch2GCController::Button( + enum wpi::Switch2GCController::Button button, + wpi::EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + + +Trigger CommandSwitch2GCController::A( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2GCController::Button::A, + loop); +} + +Trigger CommandSwitch2GCController::X( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2GCController::Button::X, + loop); +} + +Trigger CommandSwitch2GCController::B( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2GCController::Button::B, + loop); +} + +Trigger CommandSwitch2GCController::Y( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2GCController::Button::Y, + loop); +} + +Trigger CommandSwitch2GCController::Home( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2GCController::Button::HOME, + loop); +} + +Trigger CommandSwitch2GCController::Start( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2GCController::Button::START, + loop); +} + +Trigger CommandSwitch2GCController::ZL( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2GCController::Button::ZL, + loop); +} + +Trigger CommandSwitch2GCController::Z( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2GCController::Button::Z, + loop); +} + +Trigger CommandSwitch2GCController::DpadUp( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2GCController::Button::DPAD_UP, + loop); +} + +Trigger CommandSwitch2GCController::DpadDown( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2GCController::Button::DPAD_DOWN, + loop); +} + +Trigger CommandSwitch2GCController::DpadLeft( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2GCController::Button::DPAD_LEFT, + loop); +} + +Trigger CommandSwitch2GCController::DpadRight( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2GCController::Button::DPAD_RIGHT, + loop); +} + +Trigger CommandSwitch2GCController::Capture( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2GCController::Button::CAPTURE, + loop); +} + +Trigger CommandSwitch2GCController::C( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2GCController::Button::C, + loop); +} + +Trigger CommandSwitch2GCController::L( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2GCController::Button::L, + loop); +} + +Trigger CommandSwitch2GCController::R( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2GCController::Button::R, + loop); +} + +Trigger CommandSwitch2GCController::LTrigger( + double threshold, wpi::EventLoop* loop) const { + return AxisGreaterThan( + wpi::Switch2GCController::Axis::L_TRIGGER, + threshold, loop); +} + +Trigger CommandSwitch2GCController::RTrigger( + double threshold, wpi::EventLoop* loop) const { + return AxisGreaterThan( + wpi::Switch2GCController::Axis::R_TRIGGER, + threshold, loop); +} + +Trigger CommandSwitch2GCController::AxisLessThan( + wpi::Switch2GCController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +Trigger CommandSwitch2GCController::AxisGreaterThan( + wpi::Switch2GCController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +Trigger CommandSwitch2GCController::AxisMagnitudeGreaterThan( + wpi::Switch2GCController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisMagnitudeGreaterThan(static_cast(axis), threshold, + loop); +} + + +double CommandSwitch2GCController::GetLeftX() const { + return m_controller->GetLeftX(); +} + +double CommandSwitch2GCController::GetLeftY() const { + return m_controller->GetLeftY(); +} + +double CommandSwitch2GCController::GetCStickX() const { + return m_controller->GetCStickX(); +} + +double CommandSwitch2GCController::GetCStickY() const { + return m_controller->GetCStickY(); +} + +double CommandSwitch2GCController::GetLTrigger() const { + return m_controller->GetLTrigger(); +} + +double CommandSwitch2GCController::GetRTrigger() const { + return m_controller->GetRTrigger(); +} diff --git a/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandSwitch2ProController.cpp b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandSwitch2ProController.cpp new file mode 100644 index 0000000000..469d835a67 --- /dev/null +++ b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandSwitch2ProController.cpp @@ -0,0 +1,214 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#include "wpi/commands2/button/CommandSwitch2ProController.hpp" + +using namespace wpi::cmd; + +CommandSwitch2ProController::CommandSwitch2ProController(int port) + : m_hid{&CommandGenericHID::GetCommandGenericHID(port)} { + m_ownedController = + std::make_unique(m_hid->GetHID()); + m_controller = m_ownedController.get(); +} + +CommandSwitch2ProController::CommandSwitch2ProController( + wpi::Switch2ProController* controller) + : m_ownedHid{std::make_unique(controller->GetHID())}, + m_hid{m_ownedHid.get()}, + m_controller{controller} {} + +CommandGenericHID& CommandSwitch2ProController::GetHID() { + return *m_hid; +} + +wpi::Switch2ProController& +CommandSwitch2ProController::GetController() { + return *m_controller; +} + +const wpi::Switch2ProController& +CommandSwitch2ProController::GetController() const { + return *m_controller; +} + +Trigger CommandSwitch2ProController::Button( + enum wpi::Switch2ProController::Button button, + wpi::EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + + +Trigger CommandSwitch2ProController::B( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::B, + loop); +} + +Trigger CommandSwitch2ProController::A( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::A, + loop); +} + +Trigger CommandSwitch2ProController::Y( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::Y, + loop); +} + +Trigger CommandSwitch2ProController::X( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::X, + loop); +} + +Trigger CommandSwitch2ProController::Minus( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::MINUS, + loop); +} + +Trigger CommandSwitch2ProController::Home( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::HOME, + loop); +} + +Trigger CommandSwitch2ProController::Plus( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::PLUS, + loop); +} + +Trigger CommandSwitch2ProController::LeftStick( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::LEFT_STICK, + loop); +} + +Trigger CommandSwitch2ProController::RightStick( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::RIGHT_STICK, + loop); +} + +Trigger CommandSwitch2ProController::L( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::L, + loop); +} + +Trigger CommandSwitch2ProController::R( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::R, + loop); +} + +Trigger CommandSwitch2ProController::DpadUp( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::DPAD_UP, + loop); +} + +Trigger CommandSwitch2ProController::DpadDown( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::DPAD_DOWN, + loop); +} + +Trigger CommandSwitch2ProController::DpadLeft( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::DPAD_LEFT, + loop); +} + +Trigger CommandSwitch2ProController::DpadRight( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::DPAD_RIGHT, + loop); +} + +Trigger CommandSwitch2ProController::Capture( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::CAPTURE, + loop); +} + +Trigger CommandSwitch2ProController::GR( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::GR, + loop); +} + +Trigger CommandSwitch2ProController::GL( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::GL, + loop); +} + +Trigger CommandSwitch2ProController::C( + wpi::EventLoop* loop) const { + return Button(wpi::Switch2ProController::Button::C, + loop); +} + +Trigger CommandSwitch2ProController::ZL( + double threshold, wpi::EventLoop* loop) const { + return AxisGreaterThan( + wpi::Switch2ProController::Axis::ZL, + threshold, loop); +} + +Trigger CommandSwitch2ProController::ZR( + double threshold, wpi::EventLoop* loop) const { + return AxisGreaterThan( + wpi::Switch2ProController::Axis::ZR, + threshold, loop); +} + +Trigger CommandSwitch2ProController::AxisLessThan( + wpi::Switch2ProController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +Trigger CommandSwitch2ProController::AxisGreaterThan( + wpi::Switch2ProController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +Trigger CommandSwitch2ProController::AxisMagnitudeGreaterThan( + wpi::Switch2ProController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisMagnitudeGreaterThan(static_cast(axis), threshold, + loop); +} + + +double CommandSwitch2ProController::GetLeftX() const { + return m_controller->GetLeftX(); +} + +double CommandSwitch2ProController::GetLeftY() const { + return m_controller->GetLeftY(); +} + +double CommandSwitch2ProController::GetRightX() const { + return m_controller->GetRightX(); +} + +double CommandSwitch2ProController::GetRightY() const { + return m_controller->GetRightY(); +} + +double CommandSwitch2ProController::GetZL() const { + return m_controller->GetZL(); +} + +double CommandSwitch2ProController::GetZR() const { + return m_controller->GetZR(); +} diff --git a/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandSwitchN64Controller.cpp b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandSwitchN64Controller.cpp new file mode 100644 index 0000000000..67fd4007ac --- /dev/null +++ b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandSwitchN64Controller.cpp @@ -0,0 +1,175 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#include "wpi/commands2/button/CommandSwitchN64Controller.hpp" + +using namespace wpi::cmd; + +CommandSwitchN64Controller::CommandSwitchN64Controller(int port) + : m_hid{&CommandGenericHID::GetCommandGenericHID(port)} { + m_ownedController = + std::make_unique(m_hid->GetHID()); + m_controller = m_ownedController.get(); +} + +CommandSwitchN64Controller::CommandSwitchN64Controller( + wpi::SwitchN64Controller* controller) + : m_ownedHid{std::make_unique(controller->GetHID())}, + m_hid{m_ownedHid.get()}, + m_controller{controller} {} + +CommandGenericHID& CommandSwitchN64Controller::GetHID() { + return *m_hid; +} + +wpi::SwitchN64Controller& +CommandSwitchN64Controller::GetController() { + return *m_controller; +} + +const wpi::SwitchN64Controller& +CommandSwitchN64Controller::GetController() const { + return *m_controller; +} + +Trigger CommandSwitchN64Controller::Button( + enum wpi::SwitchN64Controller::Button button, + wpi::EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + + +Trigger CommandSwitchN64Controller::A( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchN64Controller::Button::A, + loop); +} + +Trigger CommandSwitchN64Controller::B( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchN64Controller::Button::B, + loop); +} + +Trigger CommandSwitchN64Controller::CLeft( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchN64Controller::Button::C_LEFT, + loop); +} + +Trigger CommandSwitchN64Controller::CUp( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchN64Controller::Button::C_UP, + loop); +} + +Trigger CommandSwitchN64Controller::Capture( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchN64Controller::Button::CAPTURE, + loop); +} + +Trigger CommandSwitchN64Controller::Home( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchN64Controller::Button::HOME, + loop); +} + +Trigger CommandSwitchN64Controller::Start( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchN64Controller::Button::START, + loop); +} + +Trigger CommandSwitchN64Controller::CDown( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchN64Controller::Button::C_DOWN, + loop); +} + +Trigger CommandSwitchN64Controller::L( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchN64Controller::Button::L, + loop); +} + +Trigger CommandSwitchN64Controller::R( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchN64Controller::Button::R, + loop); +} + +Trigger CommandSwitchN64Controller::DpadUp( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchN64Controller::Button::DPAD_UP, + loop); +} + +Trigger CommandSwitchN64Controller::DpadDown( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchN64Controller::Button::DPAD_DOWN, + loop); +} + +Trigger CommandSwitchN64Controller::DpadLeft( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchN64Controller::Button::DPAD_LEFT, + loop); +} + +Trigger CommandSwitchN64Controller::DpadRight( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchN64Controller::Button::DPAD_RIGHT, + loop); +} + +Trigger CommandSwitchN64Controller::CRight( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchN64Controller::Button::C_RIGHT, + loop); +} + +Trigger CommandSwitchN64Controller::ZR( + double threshold, wpi::EventLoop* loop) const { + return AxisGreaterThan( + wpi::SwitchN64Controller::Axis::ZR, + threshold, loop); +} + +Trigger CommandSwitchN64Controller::AxisLessThan( + wpi::SwitchN64Controller::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +Trigger CommandSwitchN64Controller::AxisGreaterThan( + wpi::SwitchN64Controller::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +Trigger CommandSwitchN64Controller::AxisMagnitudeGreaterThan( + wpi::SwitchN64Controller::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisMagnitudeGreaterThan(static_cast(axis), threshold, + loop); +} + + +double CommandSwitchN64Controller::GetLeftX() const { + return m_controller->GetLeftX(); +} + +double CommandSwitchN64Controller::GetLeftY() const { + return m_controller->GetLeftY(); +} + +double CommandSwitchN64Controller::GetZAxis() const { + return m_controller->GetZAxis(); +} + +double CommandSwitchN64Controller::GetZR() const { + return m_controller->GetZR(); +} diff --git a/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandSwitchProController.cpp b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandSwitchProController.cpp new file mode 100644 index 0000000000..bf1f3a2295 --- /dev/null +++ b/commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandSwitchProController.cpp @@ -0,0 +1,196 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#include "wpi/commands2/button/CommandSwitchProController.hpp" + +using namespace wpi::cmd; + +CommandSwitchProController::CommandSwitchProController(int port) + : m_hid{&CommandGenericHID::GetCommandGenericHID(port)} { + m_ownedController = + std::make_unique(m_hid->GetHID()); + m_controller = m_ownedController.get(); +} + +CommandSwitchProController::CommandSwitchProController( + wpi::SwitchProController* controller) + : m_ownedHid{std::make_unique(controller->GetHID())}, + m_hid{m_ownedHid.get()}, + m_controller{controller} {} + +CommandGenericHID& CommandSwitchProController::GetHID() { + return *m_hid; +} + +wpi::SwitchProController& +CommandSwitchProController::GetController() { + return *m_controller; +} + +const wpi::SwitchProController& +CommandSwitchProController::GetController() const { + return *m_controller; +} + +Trigger CommandSwitchProController::Button( + enum wpi::SwitchProController::Button button, + wpi::EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + + +Trigger CommandSwitchProController::B( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchProController::Button::B, + loop); +} + +Trigger CommandSwitchProController::A( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchProController::Button::A, + loop); +} + +Trigger CommandSwitchProController::Y( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchProController::Button::Y, + loop); +} + +Trigger CommandSwitchProController::X( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchProController::Button::X, + loop); +} + +Trigger CommandSwitchProController::Minus( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchProController::Button::MINUS, + loop); +} + +Trigger CommandSwitchProController::Home( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchProController::Button::HOME, + loop); +} + +Trigger CommandSwitchProController::Plus( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchProController::Button::PLUS, + loop); +} + +Trigger CommandSwitchProController::LeftStick( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchProController::Button::LEFT_STICK, + loop); +} + +Trigger CommandSwitchProController::RightStick( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchProController::Button::RIGHT_STICK, + loop); +} + +Trigger CommandSwitchProController::L( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchProController::Button::L, + loop); +} + +Trigger CommandSwitchProController::R( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchProController::Button::R, + loop); +} + +Trigger CommandSwitchProController::DpadUp( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchProController::Button::DPAD_UP, + loop); +} + +Trigger CommandSwitchProController::DpadDown( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchProController::Button::DPAD_DOWN, + loop); +} + +Trigger CommandSwitchProController::DpadLeft( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchProController::Button::DPAD_LEFT, + loop); +} + +Trigger CommandSwitchProController::DpadRight( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchProController::Button::DPAD_RIGHT, + loop); +} + +Trigger CommandSwitchProController::Capture( + wpi::EventLoop* loop) const { + return Button(wpi::SwitchProController::Button::CAPTURE, + loop); +} + +Trigger CommandSwitchProController::ZL( + double threshold, wpi::EventLoop* loop) const { + return AxisGreaterThan( + wpi::SwitchProController::Axis::ZL, + threshold, loop); +} + +Trigger CommandSwitchProController::ZR( + double threshold, wpi::EventLoop* loop) const { + return AxisGreaterThan( + wpi::SwitchProController::Axis::ZR, + threshold, loop); +} + +Trigger CommandSwitchProController::AxisLessThan( + wpi::SwitchProController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +Trigger CommandSwitchProController::AxisGreaterThan( + wpi::SwitchProController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +Trigger CommandSwitchProController::AxisMagnitudeGreaterThan( + wpi::SwitchProController::Axis axis, double threshold, + wpi::EventLoop* loop) const { + return m_hid->AxisMagnitudeGreaterThan(static_cast(axis), threshold, + loop); +} + + +double CommandSwitchProController::GetLeftX() const { + return m_controller->GetLeftX(); +} + +double CommandSwitchProController::GetLeftY() const { + return m_controller->GetLeftY(); +} + +double CommandSwitchProController::GetRightX() const { + return m_controller->GetRightX(); +} + +double CommandSwitchProController::GetRightY() const { + return m_controller->GetRightY(); +} + +double CommandSwitchProController::GetZL() const { + return m_controller->GetZL(); +} + +double CommandSwitchProController::GetZR() const { + return m_controller->GetZR(); +} diff --git a/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandDualSenseEdgeController.hpp b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandDualSenseEdgeController.hpp new file mode 100644 index 0000000000..86fcfb0807 --- /dev/null +++ b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandDualSenseEdgeController.hpp @@ -0,0 +1,484 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#pragma once + +#include + +#include "wpi/driverstation/DualSenseEdgeController.hpp" + +#include "wpi/commands2/CommandScheduler.hpp" +#include "wpi/commands2/button/CommandGenericHID.hpp" +#include "wpi/commands2/button/Trigger.hpp" + +namespace wpi::cmd { +/** + * A version of {@link wpi::DualSenseEdgeController} with {@link Trigger} + * factories for command-based. + * + * @see wpi::DualSenseEdgeController + */ +class CommandDualSenseEdgeController { + public: + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is + * plugged into. + */ + explicit CommandDualSenseEdgeController(int port); + + /** + * Construct an instance of a controller with a DualSenseEdgeController object. + * + * @param controller The DualSenseEdgeController object to use for this controller. + */ + explicit CommandDualSenseEdgeController(wpi::DualSenseEdgeController* controller); + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + CommandGenericHID& GetHID(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + wpi::DualSenseEdgeController& GetController(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + const wpi::DualSenseEdgeController& GetController() const; + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + Trigger Button(enum wpi::DualSenseEdgeController::Button button, + wpi::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( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * 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( + wpi::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( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the PS 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 PS button's + * digital signal attached to the given loop. + */ + Trigger PS( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the L 3 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 L 3 button's + * digital signal attached to the given loop. + */ + Trigger L3( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the R 3 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 R 3 button's + * digital signal attached to the given loop. + */ + Trigger R3( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the L 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 L 1 button's + * digital signal attached to the given loop. + */ + Trigger L1( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the R 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 R 1 button's + * digital signal attached to the given loop. + */ + Trigger R1( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's + * digital signal attached to the given loop. + */ + Trigger DpadUp( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's + * digital signal attached to the given loop. + */ + Trigger DpadDown( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's + * digital signal attached to the given loop. + */ + Trigger DpadLeft( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's + * digital signal attached to the given loop. + */ + Trigger DpadRight( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Microphone 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 Microphone button's + * digital signal attached to the given loop. + */ + Trigger Microphone( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Right Paddle 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 Paddle 1 button's + * digital signal attached to the given loop. + */ + Trigger RightPaddle1( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Left Paddle 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 Paddle 1 button's + * digital signal attached to the given loop. + */ + Trigger LeftPaddle1( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Left Function 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 Function button's + * digital signal attached to the given loop. + */ + Trigger LeftFunction( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Right Function 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 Function button's + * digital signal attached to the given loop. + */ + Trigger RightFunction( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the axis value of the + * L 2. The returned Trigger will be true when the axis value + * is greater than 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 L 2 axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger L2( + double threshold = 0.5, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the axis value of the + * R 2. The returned Trigger will be true when the axis value + * is greater than 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 R 2 axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger R2( + double threshold = 0.5, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is less than + * {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read, starting at 0. + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is less than + * the provided threshold. + */ + Trigger AxisLessThan( + wpi::DualSenseEdgeController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is greater + * than {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is greater than + * the provided threshold. + */ + Trigger AxisGreaterThan( + wpi::DualSenseEdgeController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is + * greater than {@code threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is + * greater than the provided threshold. + */ + Trigger AxisMagnitudeGreaterThan( + wpi::DualSenseEdgeController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the Right X value of the controller. + * + * @return the axis value. + */ + double GetRightX() const; + + /** + * Get the Right Y value of the controller. + * + * @return the axis value. + */ + double GetRightY() const; + + /** + * Get the L 2 value of the controller. + * + * @return the axis value. + */ + double GetL2() const; + + /** + * Get the R 2 value of the controller. + * + * @return the axis value. + */ + double GetR2() const; + + private: + std::unique_ptr m_ownedHid; + CommandGenericHID* m_hid = nullptr; + std::unique_ptr m_ownedController; + wpi::DualSenseEdgeController* m_controller = nullptr; +}; +} // namespace wpi::cmd diff --git a/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandDualShock4Controller.hpp b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandDualShock4Controller.hpp new file mode 100644 index 0000000000..d1bb7af3a8 --- /dev/null +++ b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandDualShock4Controller.hpp @@ -0,0 +1,419 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#pragma once + +#include + +#include "wpi/driverstation/DualShock4Controller.hpp" + +#include "wpi/commands2/CommandScheduler.hpp" +#include "wpi/commands2/button/CommandGenericHID.hpp" +#include "wpi/commands2/button/Trigger.hpp" + +namespace wpi::cmd { +/** + * A version of {@link wpi::DualShock4Controller} with {@link Trigger} + * factories for command-based. + * + * @see wpi::DualShock4Controller + */ +class CommandDualShock4Controller { + public: + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is + * plugged into. + */ + explicit CommandDualShock4Controller(int port); + + /** + * Construct an instance of a controller with a DualShock4Controller object. + * + * @param controller The DualShock4Controller object to use for this controller. + */ + explicit CommandDualShock4Controller(wpi::DualShock4Controller* controller); + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + CommandGenericHID& GetHID(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + wpi::DualShock4Controller& GetController(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + const wpi::DualShock4Controller& GetController() const; + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + Trigger Button(enum wpi::DualShock4Controller::Button button, + wpi::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( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * 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( + wpi::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( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the PS 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 PS button's + * digital signal attached to the given loop. + */ + Trigger PS( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the L 3 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 L 3 button's + * digital signal attached to the given loop. + */ + Trigger L3( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the R 3 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 R 3 button's + * digital signal attached to the given loop. + */ + Trigger R3( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the L 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 L 1 button's + * digital signal attached to the given loop. + */ + Trigger L1( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the R 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 R 1 button's + * digital signal attached to the given loop. + */ + Trigger R1( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's + * digital signal attached to the given loop. + */ + Trigger DpadUp( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's + * digital signal attached to the given loop. + */ + Trigger DpadDown( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's + * digital signal attached to the given loop. + */ + Trigger DpadLeft( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's + * digital signal attached to the given loop. + */ + Trigger DpadRight( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the axis value of the + * L 2. The returned Trigger will be true when the axis value + * is greater than 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 L 2 axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger L2( + double threshold = 0.5, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the axis value of the + * R 2. The returned Trigger will be true when the axis value + * is greater than 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 R 2 axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger R2( + double threshold = 0.5, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is less than + * {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read, starting at 0. + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is less than + * the provided threshold. + */ + Trigger AxisLessThan( + wpi::DualShock4Controller::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is greater + * than {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is greater than + * the provided threshold. + */ + Trigger AxisGreaterThan( + wpi::DualShock4Controller::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is + * greater than {@code threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is + * greater than the provided threshold. + */ + Trigger AxisMagnitudeGreaterThan( + wpi::DualShock4Controller::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the Right X value of the controller. + * + * @return the axis value. + */ + double GetRightX() const; + + /** + * Get the Right Y value of the controller. + * + * @return the axis value. + */ + double GetRightY() const; + + /** + * Get the L 2 value of the controller. + * + * @return the axis value. + */ + double GetL2() const; + + /** + * Get the R 2 value of the controller. + * + * @return the axis value. + */ + double GetR2() const; + + private: + std::unique_ptr m_ownedHid; + CommandGenericHID* m_hid = nullptr; + std::unique_ptr m_ownedController; + wpi::DualShock4Controller* m_controller = nullptr; +}; +} // namespace wpi::cmd diff --git a/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandGameCubeController.hpp b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandGameCubeController.hpp new file mode 100644 index 0000000000..29fe3eb543 --- /dev/null +++ b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandGameCubeController.hpp @@ -0,0 +1,367 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#pragma once + +#include + +#include "wpi/driverstation/GameCubeController.hpp" + +#include "wpi/commands2/CommandScheduler.hpp" +#include "wpi/commands2/button/CommandGenericHID.hpp" +#include "wpi/commands2/button/Trigger.hpp" + +namespace wpi::cmd { +/** + * A version of {@link wpi::GameCubeController} with {@link Trigger} + * factories for command-based. + * + * @see wpi::GameCubeController + */ +class CommandGameCubeController { + public: + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is + * plugged into. + */ + explicit CommandGameCubeController(int port); + + /** + * Construct an instance of a controller with a GameCubeController object. + * + * @param controller The GameCubeController object to use for this controller. + */ + explicit CommandGameCubeController(wpi::GameCubeController* controller); + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + CommandGenericHID& GetHID(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + wpi::GameCubeController& GetController(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + const wpi::GameCubeController& GetController() const; + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + Trigger Button(enum wpi::GameCubeController::Button button, + wpi::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + + /** + * 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( + wpi::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( + wpi::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( + wpi::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( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Z 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 Z button's + * digital signal attached to the given loop. + */ + Trigger Z( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's + * digital signal attached to the given loop. + */ + Trigger DpadUp( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's + * digital signal attached to the given loop. + */ + Trigger DpadDown( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's + * digital signal attached to the given loop. + */ + Trigger DpadLeft( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's + * digital signal attached to the given loop. + */ + Trigger DpadRight( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the L 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 L button's + * digital signal attached to the given loop. + */ + Trigger L( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the R 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 R button's + * digital signal attached to the given loop. + */ + Trigger R( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the axis value of the + * L Trigger. The returned Trigger will be true when the axis value + * is greater than 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 L Trigger axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger LTrigger( + double threshold = 0.5, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the axis value of the + * R Trigger. The returned Trigger will be true when the axis value + * is greater than 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 R Trigger axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger RTrigger( + double threshold = 0.5, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is less than + * {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read, starting at 0. + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is less than + * the provided threshold. + */ + Trigger AxisLessThan( + wpi::GameCubeController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is greater + * than {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is greater than + * the provided threshold. + */ + Trigger AxisGreaterThan( + wpi::GameCubeController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is + * greater than {@code threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is + * greater than the provided threshold. + */ + Trigger AxisMagnitudeGreaterThan( + wpi::GameCubeController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the C Stick X value of the controller. + * + * @return the axis value. + */ + double GetCStickX() const; + + /** + * Get the C Stick Y value of the controller. + * + * @return the axis value. + */ + double GetCStickY() const; + + /** + * Get the L Trigger value of the controller. + * + * @return the axis value. + */ + double GetLTrigger() const; + + /** + * Get the R Trigger value of the controller. + * + * @return the axis value. + */ + double GetRTrigger() const; + + private: + std::unique_ptr m_ownedHid; + CommandGenericHID* m_hid = nullptr; + std::unique_ptr m_ownedController; + wpi::GameCubeController* m_controller = nullptr; +}; +} // namespace wpi::cmd diff --git a/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandLogitechF310Controller.hpp b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandLogitechF310Controller.hpp new file mode 100644 index 0000000000..4fd9a32b4e --- /dev/null +++ b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandLogitechF310Controller.hpp @@ -0,0 +1,406 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#pragma once + +#include + +#include "wpi/driverstation/LogitechF310Controller.hpp" + +#include "wpi/commands2/CommandScheduler.hpp" +#include "wpi/commands2/button/CommandGenericHID.hpp" +#include "wpi/commands2/button/Trigger.hpp" + +namespace wpi::cmd { +/** + * A version of {@link wpi::LogitechF310Controller} with {@link Trigger} + * factories for command-based. + * + * @see wpi::LogitechF310Controller + */ +class CommandLogitechF310Controller { + public: + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is + * plugged into. + */ + explicit CommandLogitechF310Controller(int port); + + /** + * Construct an instance of a controller with a LogitechF310Controller object. + * + * @param controller The LogitechF310Controller object to use for this controller. + */ + explicit CommandLogitechF310Controller(wpi::LogitechF310Controller* controller); + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + CommandGenericHID& GetHID(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + wpi::LogitechF310Controller& GetController(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + const wpi::LogitechF310Controller& GetController() const; + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + Trigger Button(enum wpi::LogitechF310Controller::Button button, + wpi::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + + /** + * 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( + wpi::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( + wpi::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( + wpi::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( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Logitech 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 Logitech button's + * digital signal attached to the given loop. + */ + Trigger Logitech( + wpi::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( + wpi::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( + wpi::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( + wpi::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( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's + * digital signal attached to the given loop. + */ + Trigger DpadUp( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's + * digital signal attached to the given loop. + */ + Trigger DpadDown( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's + * digital signal attached to the given loop. + */ + Trigger DpadLeft( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's + * digital signal attached to the given loop. + */ + Trigger DpadRight( + wpi::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 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 axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger LeftTrigger( + double threshold = 0.5, + wpi::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 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 axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger RightTrigger( + double threshold = 0.5, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is less than + * {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read, starting at 0. + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is less than + * the provided threshold. + */ + Trigger AxisLessThan( + wpi::LogitechF310Controller::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is greater + * than {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is greater than + * the provided threshold. + */ + Trigger AxisGreaterThan( + wpi::LogitechF310Controller::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is + * greater than {@code threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is + * greater than the provided threshold. + */ + Trigger AxisMagnitudeGreaterThan( + wpi::LogitechF310Controller::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the Right X value of the controller. + * + * @return the axis value. + */ + double GetRightX() const; + + /** + * Get the Right Y value of the controller. + * + * @return the axis value. + */ + double GetRightY() const; + + /** + * Get the Left Trigger value of the controller. + * + * @return the axis value. + */ + double GetLeftTrigger() const; + + /** + * Get the Right Trigger value of the controller. + * + * @return the axis value. + */ + double GetRightTrigger() const; + + private: + std::unique_ptr m_ownedHid; + CommandGenericHID* m_hid = nullptr; + std::unique_ptr m_ownedController; + wpi::LogitechF310Controller* m_controller = nullptr; +}; +} // namespace wpi::cmd diff --git a/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandSteamController.hpp b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandSteamController.hpp new file mode 100644 index 0000000000..49993c91a0 --- /dev/null +++ b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandSteamController.hpp @@ -0,0 +1,549 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#pragma once + +#include + +#include "wpi/driverstation/SteamController.hpp" + +#include "wpi/commands2/CommandScheduler.hpp" +#include "wpi/commands2/button/CommandGenericHID.hpp" +#include "wpi/commands2/button/Trigger.hpp" + +namespace wpi::cmd { +/** + * A version of {@link wpi::SteamController} with {@link Trigger} + * factories for command-based. + * + * @see wpi::SteamController + */ +class CommandSteamController { + public: + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is + * plugged into. + */ + explicit CommandSteamController(int port); + + /** + * Construct an instance of a controller with a SteamController object. + * + * @param controller The SteamController object to use for this controller. + */ + explicit CommandSteamController(wpi::SteamController* controller); + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + CommandGenericHID& GetHID(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + wpi::SteamController& GetController(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + const wpi::SteamController& GetController() const; + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + Trigger Button(enum wpi::SteamController::Button button, + wpi::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + + /** + * 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( + wpi::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( + wpi::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( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Menu 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 Menu button's + * digital signal attached to the given loop. + */ + Trigger Menu( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Steam 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 Steam button's + * digital signal attached to the given loop. + */ + Trigger Steam( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the View 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 View button's + * digital signal attached to the given loop. + */ + Trigger View( + wpi::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( + wpi::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( + wpi::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( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's + * digital signal attached to the given loop. + */ + Trigger DpadUp( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's + * digital signal attached to the given loop. + */ + Trigger DpadDown( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's + * digital signal attached to the given loop. + */ + Trigger DpadLeft( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's + * digital signal attached to the given loop. + */ + Trigger DpadRight( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the QAM 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 QAM button's + * digital signal attached to the given loop. + */ + Trigger QAM( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Right Paddle 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 Paddle 1 button's + * digital signal attached to the given loop. + */ + Trigger RightPaddle1( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Left Paddle 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 Paddle 1 button's + * digital signal attached to the given loop. + */ + Trigger LeftPaddle1( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Right Paddle 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 Paddle 2 button's + * digital signal attached to the given loop. + */ + Trigger RightPaddle2( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Left Paddle 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 Paddle 2 button's + * digital signal attached to the given loop. + */ + Trigger LeftPaddle2( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Left 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 Left Touchpad button's + * digital signal attached to the given loop. + */ + Trigger LeftTouchpad( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Right 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 Right Touchpad button's + * digital signal attached to the given loop. + */ + Trigger RightTouchpad( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Left Stick Touch 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 Touch button's + * digital signal attached to the given loop. + */ + Trigger LeftStickTouch( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Right Stick Touch 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 Touch button's + * digital signal attached to the given loop. + */ + Trigger RightStickTouch( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Left Grip Touch 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 Grip Touch button's + * digital signal attached to the given loop. + */ + Trigger LeftGripTouch( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Right Grip Touch 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 Grip Touch button's + * digital signal attached to the given loop. + */ + Trigger RightGripTouch( + wpi::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 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 axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger LeftTrigger( + double threshold = 0.5, + wpi::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 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 axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger RightTrigger( + double threshold = 0.5, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is less than + * {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read, starting at 0. + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is less than + * the provided threshold. + */ + Trigger AxisLessThan( + wpi::SteamController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is greater + * than {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is greater than + * the provided threshold. + */ + Trigger AxisGreaterThan( + wpi::SteamController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is + * greater than {@code threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is + * greater than the provided threshold. + */ + Trigger AxisMagnitudeGreaterThan( + wpi::SteamController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the Right X value of the controller. + * + * @return the axis value. + */ + double GetRightX() const; + + /** + * Get the Right Y value of the controller. + * + * @return the axis value. + */ + double GetRightY() const; + + /** + * Get the Left Trigger value of the controller. + * + * @return the axis value. + */ + double GetLeftTrigger() const; + + /** + * Get the Right Trigger value of the controller. + * + * @return the axis value. + */ + double GetRightTrigger() const; + + private: + std::unique_ptr m_ownedHid; + CommandGenericHID* m_hid = nullptr; + std::unique_ptr m_ownedController; + wpi::SteamController* m_controller = nullptr; +}; +} // namespace wpi::cmd diff --git a/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandSwitch2GCController.hpp b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandSwitch2GCController.hpp new file mode 100644 index 0000000000..01243ad1b2 --- /dev/null +++ b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandSwitch2GCController.hpp @@ -0,0 +1,419 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#pragma once + +#include + +#include "wpi/driverstation/Switch2GCController.hpp" + +#include "wpi/commands2/CommandScheduler.hpp" +#include "wpi/commands2/button/CommandGenericHID.hpp" +#include "wpi/commands2/button/Trigger.hpp" + +namespace wpi::cmd { +/** + * A version of {@link wpi::Switch2GCController} with {@link Trigger} + * factories for command-based. + * + * @see wpi::Switch2GCController + */ +class CommandSwitch2GCController { + public: + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is + * plugged into. + */ + explicit CommandSwitch2GCController(int port); + + /** + * Construct an instance of a controller with a Switch2GCController object. + * + * @param controller The Switch2GCController object to use for this controller. + */ + explicit CommandSwitch2GCController(wpi::Switch2GCController* controller); + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + CommandGenericHID& GetHID(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + wpi::Switch2GCController& GetController(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + const wpi::Switch2GCController& GetController() const; + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + Trigger Button(enum wpi::Switch2GCController::Button button, + wpi::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + + /** + * 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( + wpi::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( + wpi::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( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Home 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 Home button's + * digital signal attached to the given loop. + */ + Trigger Home( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the ZL 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 ZL button's + * digital signal attached to the given loop. + */ + Trigger ZL( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Z 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 Z button's + * digital signal attached to the given loop. + */ + Trigger Z( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's + * digital signal attached to the given loop. + */ + Trigger DpadUp( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's + * digital signal attached to the given loop. + */ + Trigger DpadDown( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's + * digital signal attached to the given loop. + */ + Trigger DpadLeft( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's + * digital signal attached to the given loop. + */ + Trigger DpadRight( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Capture 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 Capture button's + * digital signal attached to the given loop. + */ + Trigger Capture( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the C 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 C button's + * digital signal attached to the given loop. + */ + Trigger C( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the L 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 L button's + * digital signal attached to the given loop. + */ + Trigger L( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the R 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 R button's + * digital signal attached to the given loop. + */ + Trigger R( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the axis value of the + * L Trigger. The returned Trigger will be true when the axis value + * is greater than 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 L Trigger axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger LTrigger( + double threshold = 0.5, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the axis value of the + * R Trigger. The returned Trigger will be true when the axis value + * is greater than 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 R Trigger axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger RTrigger( + double threshold = 0.5, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is less than + * {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read, starting at 0. + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is less than + * the provided threshold. + */ + Trigger AxisLessThan( + wpi::Switch2GCController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is greater + * than {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is greater than + * the provided threshold. + */ + Trigger AxisGreaterThan( + wpi::Switch2GCController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is + * greater than {@code threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is + * greater than the provided threshold. + */ + Trigger AxisMagnitudeGreaterThan( + wpi::Switch2GCController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the C Stick X value of the controller. + * + * @return the axis value. + */ + double GetCStickX() const; + + /** + * Get the C Stick Y value of the controller. + * + * @return the axis value. + */ + double GetCStickY() const; + + /** + * Get the L Trigger value of the controller. + * + * @return the axis value. + */ + double GetLTrigger() const; + + /** + * Get the R Trigger value of the controller. + * + * @return the axis value. + */ + double GetRTrigger() const; + + private: + std::unique_ptr m_ownedHid; + CommandGenericHID* m_hid = nullptr; + std::unique_ptr m_ownedController; + wpi::Switch2GCController* m_controller = nullptr; +}; +} // namespace wpi::cmd diff --git a/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandSwitch2ProController.hpp b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandSwitch2ProController.hpp new file mode 100644 index 0000000000..c4b07bd744 --- /dev/null +++ b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandSwitch2ProController.hpp @@ -0,0 +1,458 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#pragma once + +#include + +#include "wpi/driverstation/Switch2ProController.hpp" + +#include "wpi/commands2/CommandScheduler.hpp" +#include "wpi/commands2/button/CommandGenericHID.hpp" +#include "wpi/commands2/button/Trigger.hpp" + +namespace wpi::cmd { +/** + * A version of {@link wpi::Switch2ProController} with {@link Trigger} + * factories for command-based. + * + * @see wpi::Switch2ProController + */ +class CommandSwitch2ProController { + public: + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is + * plugged into. + */ + explicit CommandSwitch2ProController(int port); + + /** + * Construct an instance of a controller with a Switch2ProController object. + * + * @param controller The Switch2ProController object to use for this controller. + */ + explicit CommandSwitch2ProController(wpi::Switch2ProController* controller); + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + CommandGenericHID& GetHID(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + wpi::Switch2ProController& GetController(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + const wpi::Switch2ProController& GetController() const; + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + Trigger Button(enum wpi::Switch2ProController::Button button, + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * 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( + wpi::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( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Minus 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 Minus button's + * digital signal attached to the given loop. + */ + Trigger Minus( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Home 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 Home button's + * digital signal attached to the given loop. + */ + Trigger Home( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Plus 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 Plus button's + * digital signal attached to the given loop. + */ + Trigger Plus( + wpi::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( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the L 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 L button's + * digital signal attached to the given loop. + */ + Trigger L( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the R 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 R button's + * digital signal attached to the given loop. + */ + Trigger R( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's + * digital signal attached to the given loop. + */ + Trigger DpadUp( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's + * digital signal attached to the given loop. + */ + Trigger DpadDown( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's + * digital signal attached to the given loop. + */ + Trigger DpadLeft( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's + * digital signal attached to the given loop. + */ + Trigger DpadRight( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Capture 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 Capture button's + * digital signal attached to the given loop. + */ + Trigger Capture( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the GR 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 GR button's + * digital signal attached to the given loop. + */ + Trigger GR( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the GL 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 GL button's + * digital signal attached to the given loop. + */ + Trigger GL( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the C 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 C button's + * digital signal attached to the given loop. + */ + Trigger C( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the axis value of the + * ZL. The returned Trigger will be true when the axis value + * is greater than 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 ZL axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger ZL( + double threshold = 0.5, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the axis value of the + * ZR. The returned Trigger will be true when the axis value + * is greater than 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 ZR axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger ZR( + double threshold = 0.5, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is less than + * {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read, starting at 0. + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is less than + * the provided threshold. + */ + Trigger AxisLessThan( + wpi::Switch2ProController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is greater + * than {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is greater than + * the provided threshold. + */ + Trigger AxisGreaterThan( + wpi::Switch2ProController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is + * greater than {@code threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is + * greater than the provided threshold. + */ + Trigger AxisMagnitudeGreaterThan( + wpi::Switch2ProController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the Right X value of the controller. + * + * @return the axis value. + */ + double GetRightX() const; + + /** + * Get the Right Y value of the controller. + * + * @return the axis value. + */ + double GetRightY() const; + + /** + * Get the ZL value of the controller. + * + * @return the axis value. + */ + double GetZL() const; + + /** + * Get the ZR value of the controller. + * + * @return the axis value. + */ + double GetZR() const; + + private: + std::unique_ptr m_ownedHid; + CommandGenericHID* m_hid = nullptr; + std::unique_ptr m_ownedController; + wpi::Switch2ProController* m_controller = nullptr; +}; +} // namespace wpi::cmd diff --git a/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandSwitchN64Controller.hpp b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandSwitchN64Controller.hpp new file mode 100644 index 0000000000..3fa74b5a4b --- /dev/null +++ b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandSwitchN64Controller.hpp @@ -0,0 +1,374 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#pragma once + +#include + +#include "wpi/driverstation/SwitchN64Controller.hpp" + +#include "wpi/commands2/CommandScheduler.hpp" +#include "wpi/commands2/button/CommandGenericHID.hpp" +#include "wpi/commands2/button/Trigger.hpp" + +namespace wpi::cmd { +/** + * A version of {@link wpi::SwitchN64Controller} with {@link Trigger} + * factories for command-based. + * + * @see wpi::SwitchN64Controller + */ +class CommandSwitchN64Controller { + public: + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is + * plugged into. + */ + explicit CommandSwitchN64Controller(int port); + + /** + * Construct an instance of a controller with a SwitchN64Controller object. + * + * @param controller The SwitchN64Controller object to use for this controller. + */ + explicit CommandSwitchN64Controller(wpi::SwitchN64Controller* controller); + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + CommandGenericHID& GetHID(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + wpi::SwitchN64Controller& GetController(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + const wpi::SwitchN64Controller& GetController() const; + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + Trigger Button(enum wpi::SwitchN64Controller::Button button, + wpi::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + + /** + * 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( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the C Left 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 C Left button's + * digital signal attached to the given loop. + */ + Trigger CLeft( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the C Up 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 C Up button's + * digital signal attached to the given loop. + */ + Trigger CUp( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Capture 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 Capture button's + * digital signal attached to the given loop. + */ + Trigger Capture( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Home 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 Home button's + * digital signal attached to the given loop. + */ + Trigger Home( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the C Down 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 C Down button's + * digital signal attached to the given loop. + */ + Trigger CDown( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the L 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 L button's + * digital signal attached to the given loop. + */ + Trigger L( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the R 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 R button's + * digital signal attached to the given loop. + */ + Trigger R( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's + * digital signal attached to the given loop. + */ + Trigger DpadUp( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's + * digital signal attached to the given loop. + */ + Trigger DpadDown( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's + * digital signal attached to the given loop. + */ + Trigger DpadLeft( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's + * digital signal attached to the given loop. + */ + Trigger DpadRight( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the C Right 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 C Right button's + * digital signal attached to the given loop. + */ + Trigger CRight( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the axis value of the + * ZR. The returned Trigger will be true when the axis value + * is greater than 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 ZR axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger ZR( + double threshold = 0.5, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is less than + * {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read, starting at 0. + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is less than + * the provided threshold. + */ + Trigger AxisLessThan( + wpi::SwitchN64Controller::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is greater + * than {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is greater than + * the provided threshold. + */ + Trigger AxisGreaterThan( + wpi::SwitchN64Controller::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is + * greater than {@code threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is + * greater than the provided threshold. + */ + Trigger AxisMagnitudeGreaterThan( + wpi::SwitchN64Controller::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the Z Axis value of the controller. + * + * @return the axis value. + */ + double GetZAxis() const; + + /** + * Get the ZR value of the controller. + * + * @return the axis value. + */ + double GetZR() const; + + private: + std::unique_ptr m_ownedHid; + CommandGenericHID* m_hid = nullptr; + std::unique_ptr m_ownedController; + wpi::SwitchN64Controller* m_controller = nullptr; +}; +} // namespace wpi::cmd diff --git a/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandSwitchProController.hpp b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandSwitchProController.hpp new file mode 100644 index 0000000000..b8e4d5e2cf --- /dev/null +++ b/commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandSwitchProController.hpp @@ -0,0 +1,419 @@ +// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY +#pragma once + +#include + +#include "wpi/driverstation/SwitchProController.hpp" + +#include "wpi/commands2/CommandScheduler.hpp" +#include "wpi/commands2/button/CommandGenericHID.hpp" +#include "wpi/commands2/button/Trigger.hpp" + +namespace wpi::cmd { +/** + * A version of {@link wpi::SwitchProController} with {@link Trigger} + * factories for command-based. + * + * @see wpi::SwitchProController + */ +class CommandSwitchProController { + public: + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is + * plugged into. + */ + explicit CommandSwitchProController(int port); + + /** + * Construct an instance of a controller with a SwitchProController object. + * + * @param controller The SwitchProController object to use for this controller. + */ + explicit CommandSwitchProController(wpi::SwitchProController* controller); + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + CommandGenericHID& GetHID(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + wpi::SwitchProController& GetController(); + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + const wpi::SwitchProController& GetController() const; + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + Trigger Button(enum wpi::SwitchProController::Button button, + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * 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( + wpi::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( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Minus 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 Minus button's + * digital signal attached to the given loop. + */ + Trigger Minus( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Home 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 Home button's + * digital signal attached to the given loop. + */ + Trigger Home( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Plus 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 Plus button's + * digital signal attached to the given loop. + */ + Trigger Plus( + wpi::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( + wpi::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( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the L 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 L button's + * digital signal attached to the given loop. + */ + Trigger L( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the R 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 R button's + * digital signal attached to the given loop. + */ + Trigger R( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's + * digital signal attached to the given loop. + */ + Trigger DpadUp( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's + * digital signal attached to the given loop. + */ + Trigger DpadDown( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's + * digital signal attached to the given loop. + */ + Trigger DpadLeft( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's + * digital signal attached to the given loop. + */ + Trigger DpadRight( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Capture 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 Capture button's + * digital signal attached to the given loop. + */ + Trigger Capture( + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the axis value of the + * ZL. The returned Trigger will be true when the axis value + * is greater than 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 ZL axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger ZL( + double threshold = 0.5, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the axis value of the + * ZR. The returned Trigger will be true when the axis value + * is greater than 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 ZR axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger ZR( + double threshold = 0.5, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is less than + * {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read, starting at 0. + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is less than + * the provided threshold. + */ + Trigger AxisLessThan( + wpi::SwitchProController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis value is greater + * than {@code threshold}, attached to {@link + * CommandScheduler::GetDefaultButtonLoop() the default command scheduler + * button loop}. + * @param axis The axis to read + * @param threshold The value below which this trigger should return true. + * @param loop the event loop instance to attach the event to. Defaults to + * {@link CommandScheduler::GetDefaultButtonLoop() the default command + * scheduler button loop}. + * @return a Trigger instance that is true when the axis value is greater than + * the provided threshold. + */ + Trigger AxisGreaterThan( + wpi::SwitchProController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance that is true when the axis magnitude value is + * greater than {@code threshold}, attached to the given loop. + * + * @param axis The axis to read + * @param threshold The value above which this trigger should return true. + * @param loop the event loop instance to attach the trigger to. + * @return a Trigger instance that is true when the axis magnitude value is + * greater than the provided threshold. + */ + Trigger AxisMagnitudeGreaterThan( + wpi::SwitchProController::Axis axis, double threshold, + wpi::EventLoop* loop = + CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the Right X value of the controller. + * + * @return the axis value. + */ + double GetRightX() const; + + /** + * Get the Right Y value of the controller. + * + * @return the axis value. + */ + double GetRightY() const; + + /** + * Get the ZL value of the controller. + * + * @return the axis value. + */ + double GetZL() const; + + /** + * Get the ZR value of the controller. + * + * @return the axis value. + */ + double GetZR() const; + + private: + std::unique_ptr m_ownedHid; + CommandGenericHID* m_hid = nullptr; + std::unique_ptr m_ownedController; + wpi::SwitchProController* m_controller = nullptr; +}; +} // namespace wpi::cmd diff --git a/commandsv2/src/main/python/commands2/button/__init__.py b/commandsv2/src/main/python/commands2/button/__init__.py index dd6d31a581..7c82fe37d7 100644 --- a/commandsv2/src/main/python/commands2/button/__init__.py +++ b/commandsv2/src/main/python/commands2/button/__init__.py @@ -1,9 +1,18 @@ from .commandgenerichid import CommandGenericHID from .commanddualsensecontroller import CommandDualSenseController +from .commanddualsenseedgecontroller import CommandDualSenseEdgeController +from .commanddualshock4controller import CommandDualShock4Controller from .commandgamepad import CommandGamepad +from .commandgamecubecontroller import CommandGameCubeController from .commandjoystick import CommandJoystick +from .commandlogitechf310controller import CommandLogitechF310Controller from .commandnidsps4controller import CommandNiDsPS4Controller from .commandnidsxboxcontroller import CommandNiDsXboxController +from .commandsteamcontroller import CommandSteamController +from .commandswitch2gccontroller import CommandSwitch2GCController +from .commandswitch2procontroller import CommandSwitch2ProController +from .commandswitchn64controller import CommandSwitchN64Controller +from .commandswitchprocontroller import CommandSwitchProController from .commandxboxcontroller import CommandXboxController from .joystickbutton import JoystickButton from .networkbutton import NetworkButton @@ -13,11 +22,20 @@ from .trigger import Trigger __all__ = [ "Trigger", "CommandDualSenseController", + "CommandDualSenseEdgeController", + "CommandDualShock4Controller", "CommandGenericHID", "CommandGamepad", + "CommandGameCubeController", "CommandJoystick", + "CommandLogitechF310Controller", "CommandNiDsPS4Controller", "CommandNiDsXboxController", + "CommandSteamController", + "CommandSwitch2GCController", + "CommandSwitch2ProController", + "CommandSwitchN64Controller", + "CommandSwitchProController", "CommandXboxController", "JoystickButton", "NetworkButton", diff --git a/commandsv2/src/main/python/commands2/button/commanddualsenseedgecontroller.py b/commandsv2/src/main/python/commands2/button/commanddualsenseedgecontroller.py new file mode 100644 index 0000000000..4237d2978c --- /dev/null +++ b/commandsv2/src/main/python/commands2/button/commanddualsenseedgecontroller.py @@ -0,0 +1,471 @@ +# THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY + +from typing import Optional, Union + +from wpilib import EventLoop, DualSenseEdgeController + +from .commandgenerichid import CommandGenericHID +from .trigger import Trigger + + +class CommandDualSenseEdgeController: + """ + A version of :class:`wpilib.DualSenseEdgeController` with :class:`.Trigger` factories for command-based. + """ + + _hid: CommandGenericHID + _controller: DualSenseEdgeController + + def __init__(self, hid: Union[int, DualSenseEdgeController]): + """ + Construct an instance of a controller. + + :param hid: The port index on the Driver Station that the controller is plugged into, + or the DualSenseEdgeController object to use for this controller. + """ + if isinstance(hid, int): + self._hid = CommandGenericHID.getCommandGenericHID(hid) + self._controller = DualSenseEdgeController(self._hid.getHID()) + else: + self._hid = CommandGenericHID(hid.getHID()) + self._controller = hid + + def getHID(self) -> CommandGenericHID: + """ + Get the underlying CommandGenericHID object. + + :returns: the wrapped CommandGenericHID object + """ + return self._hid + + def getController(self) -> DualSenseEdgeController: + """ + Get the wrapped controller object. + + :returns: the wrapped controller object + """ + return self._controller + + def button( + self, + button: DualSenseEdgeController.Button, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs an event instance around this button's digital signal. + + :param button: the :class:`wpilib.DualSenseEdgeController.Button` to read + :param loop: the event loop instance to attach the event to + """ + return self._hid.button(button.value, loop) + + def cross(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Cross button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Cross button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.CROSS, loop) + + def circle(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Circle button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Circle button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.CIRCLE, loop) + + def square(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Square button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Square button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.SQUARE, loop) + + def triangle(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Triangle button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Triangle button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.TRIANGLE, loop) + + def create(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Create button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Create button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.CREATE, loop) + + def PS(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the PS button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the PS button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.PS, loop) + + def options(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Options button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Options button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.OPTIONS, loop) + + def L3(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the L 3 button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the L 3 button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.L3, loop) + + def R3(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the R 3 button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the R 3 button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.R3, loop) + + def L1(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the L 1 button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the L 1 button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.L1, loop) + + def R1(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the R 1 button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the R 1 button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.R1, loop) + + def dpadUp(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Up button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Up button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.DPAD_UP, loop) + + def dpadDown(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Down button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Down button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.DPAD_DOWN, loop) + + def dpadLeft(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Left button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Left button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.DPAD_LEFT, loop) + + def dpadRight(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Right button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Right button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.DPAD_RIGHT, loop) + + def microphone(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Microphone button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Microphone button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.MICROPHONE, loop) + + def rightPaddle1(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Right Paddle 1 button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Right Paddle 1 button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.RIGHT_PADDLE_1, loop) + + def leftPaddle1(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Left Paddle 1 button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Left Paddle 1 button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.LEFT_PADDLE_1, loop) + + def touchpad(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Touchpad button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Touchpad button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.TOUCHPAD, loop) + + def leftFunction(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Left Function button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Left Function button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.LEFT_FUNCTION, loop) + + def rightFunction(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Right Function button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Right Function button's digital signal + attached to the given loop. + """ + return self.button(DualSenseEdgeController.Button.RIGHT_FUNCTION, loop) + + def L2( + self, + threshold: float = 0.5, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance around the L 2 axis value. The returned + Trigger will be true when the axis value is greater than ``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. + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance that is true when the L 2 axis exceeds the + provided threshold, attached to the given event loop. + """ + return self.axisGreaterThan( + DualSenseEdgeController.Axis.L2, + threshold, + loop, + ) + + def R2( + self, + threshold: float = 0.5, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance around the R 2 axis value. The returned + Trigger will be true when the axis value is greater than ``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. + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance that is true when the R 2 axis exceeds the + provided threshold, attached to the given event loop. + """ + return self.axisGreaterThan( + DualSenseEdgeController.Axis.R2, + threshold, + loop, + ) + + def axisLessThan( + self, + axis: DualSenseEdgeController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is less than + ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.DualSenseEdgeController.Axis` to read + :param threshold: the value below which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to + + :returns: a Trigger instance that is true when the axis value is less than + the provided threshold. + """ + return self._hid.axisLessThan(axis.value, threshold, loop) + + def axisGreaterThan( + self, + axis: DualSenseEdgeController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is greater + than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.DualSenseEdgeController.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis value is greater + than the provided threshold. + """ + return self._hid.axisGreaterThan(axis.value, threshold, loop) + + def axisMagnitudeGreaterThan( + self, + axis: DualSenseEdgeController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis magnitude is + greater than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.DualSenseEdgeController.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis magnitude is + greater than the provided threshold. + """ + return self._hid.axisMagnitudeGreaterThan(axis.value, threshold, loop) + + def getAxis(self, axis: DualSenseEdgeController.Axis) -> float: + """ + Get the value of the axis. + + :param axis: the :class:`wpilib.DualSenseEdgeController.Axis` to read + """ + return self._hid.getRawAxis(axis.value) + + def getLeftX(self) -> float: + """ + Get the Left X value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftX() + + def getLeftY(self) -> float: + """ + Get the Left Y value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftY() + + def getRightX(self) -> float: + """ + Get the Right X value of the controller. + + :returns: the axis value. + """ + return self._controller.getRightX() + + def getRightY(self) -> float: + """ + Get the Right Y value of the controller. + + :returns: the axis value. + """ + return self._controller.getRightY() + + def getL2(self) -> float: + """ + Get the L 2 value of the controller. + + :returns: the axis value. + """ + return self._controller.getL2() + + def getR2(self) -> float: + """ + Get the R 2 value of the controller. + + :returns: the axis value. + """ + return self._controller.getR2() diff --git a/commandsv2/src/main/python/commands2/button/commanddualshock4controller.py b/commandsv2/src/main/python/commands2/button/commanddualshock4controller.py new file mode 100644 index 0000000000..f242b574e5 --- /dev/null +++ b/commandsv2/src/main/python/commands2/button/commanddualshock4controller.py @@ -0,0 +1,411 @@ +# THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY + +from typing import Optional, Union + +from wpilib import EventLoop, DualShock4Controller + +from .commandgenerichid import CommandGenericHID +from .trigger import Trigger + + +class CommandDualShock4Controller: + """ + A version of :class:`wpilib.DualShock4Controller` with :class:`.Trigger` factories for command-based. + """ + + _hid: CommandGenericHID + _controller: DualShock4Controller + + def __init__(self, hid: Union[int, DualShock4Controller]): + """ + Construct an instance of a controller. + + :param hid: The port index on the Driver Station that the controller is plugged into, + or the DualShock4Controller object to use for this controller. + """ + if isinstance(hid, int): + self._hid = CommandGenericHID.getCommandGenericHID(hid) + self._controller = DualShock4Controller(self._hid.getHID()) + else: + self._hid = CommandGenericHID(hid.getHID()) + self._controller = hid + + def getHID(self) -> CommandGenericHID: + """ + Get the underlying CommandGenericHID object. + + :returns: the wrapped CommandGenericHID object + """ + return self._hid + + def getController(self) -> DualShock4Controller: + """ + Get the wrapped controller object. + + :returns: the wrapped controller object + """ + return self._controller + + def button( + self, + button: DualShock4Controller.Button, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs an event instance around this button's digital signal. + + :param button: the :class:`wpilib.DualShock4Controller.Button` to read + :param loop: the event loop instance to attach the event to + """ + return self._hid.button(button.value, loop) + + def cross(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Cross button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Cross button's digital signal + attached to the given loop. + """ + return self.button(DualShock4Controller.Button.CROSS, loop) + + def circle(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Circle button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Circle button's digital signal + attached to the given loop. + """ + return self.button(DualShock4Controller.Button.CIRCLE, loop) + + def square(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Square button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Square button's digital signal + attached to the given loop. + """ + return self.button(DualShock4Controller.Button.SQUARE, loop) + + def triangle(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Triangle button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Triangle button's digital signal + attached to the given loop. + """ + return self.button(DualShock4Controller.Button.TRIANGLE, loop) + + def share(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Share button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Share button's digital signal + attached to the given loop. + """ + return self.button(DualShock4Controller.Button.SHARE, loop) + + def PS(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the PS button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the PS button's digital signal + attached to the given loop. + """ + return self.button(DualShock4Controller.Button.PS, loop) + + def options(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Options button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Options button's digital signal + attached to the given loop. + """ + return self.button(DualShock4Controller.Button.OPTIONS, loop) + + def L3(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the L 3 button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the L 3 button's digital signal + attached to the given loop. + """ + return self.button(DualShock4Controller.Button.L3, loop) + + def R3(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the R 3 button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the R 3 button's digital signal + attached to the given loop. + """ + return self.button(DualShock4Controller.Button.R3, loop) + + def L1(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the L 1 button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the L 1 button's digital signal + attached to the given loop. + """ + return self.button(DualShock4Controller.Button.L1, loop) + + def R1(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the R 1 button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the R 1 button's digital signal + attached to the given loop. + """ + return self.button(DualShock4Controller.Button.R1, loop) + + def dpadUp(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Up button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Up button's digital signal + attached to the given loop. + """ + return self.button(DualShock4Controller.Button.DPAD_UP, loop) + + def dpadDown(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Down button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Down button's digital signal + attached to the given loop. + """ + return self.button(DualShock4Controller.Button.DPAD_DOWN, loop) + + def dpadLeft(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Left button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Left button's digital signal + attached to the given loop. + """ + return self.button(DualShock4Controller.Button.DPAD_LEFT, loop) + + def dpadRight(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Right button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Right button's digital signal + attached to the given loop. + """ + return self.button(DualShock4Controller.Button.DPAD_RIGHT, loop) + + def touchpad(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Touchpad button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Touchpad button's digital signal + attached to the given loop. + """ + return self.button(DualShock4Controller.Button.TOUCHPAD, loop) + + def L2( + self, + threshold: float = 0.5, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance around the L 2 axis value. The returned + Trigger will be true when the axis value is greater than ``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. + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance that is true when the L 2 axis exceeds the + provided threshold, attached to the given event loop. + """ + return self.axisGreaterThan( + DualShock4Controller.Axis.L2, + threshold, + loop, + ) + + def R2( + self, + threshold: float = 0.5, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance around the R 2 axis value. The returned + Trigger will be true when the axis value is greater than ``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. + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance that is true when the R 2 axis exceeds the + provided threshold, attached to the given event loop. + """ + return self.axisGreaterThan( + DualShock4Controller.Axis.R2, + threshold, + loop, + ) + + def axisLessThan( + self, + axis: DualShock4Controller.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is less than + ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.DualShock4Controller.Axis` to read + :param threshold: the value below which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to + + :returns: a Trigger instance that is true when the axis value is less than + the provided threshold. + """ + return self._hid.axisLessThan(axis.value, threshold, loop) + + def axisGreaterThan( + self, + axis: DualShock4Controller.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is greater + than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.DualShock4Controller.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis value is greater + than the provided threshold. + """ + return self._hid.axisGreaterThan(axis.value, threshold, loop) + + def axisMagnitudeGreaterThan( + self, + axis: DualShock4Controller.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis magnitude is + greater than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.DualShock4Controller.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis magnitude is + greater than the provided threshold. + """ + return self._hid.axisMagnitudeGreaterThan(axis.value, threshold, loop) + + def getAxis(self, axis: DualShock4Controller.Axis) -> float: + """ + Get the value of the axis. + + :param axis: the :class:`wpilib.DualShock4Controller.Axis` to read + """ + return self._hid.getRawAxis(axis.value) + + def getLeftX(self) -> float: + """ + Get the Left X value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftX() + + def getLeftY(self) -> float: + """ + Get the Left Y value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftY() + + def getRightX(self) -> float: + """ + Get the Right X value of the controller. + + :returns: the axis value. + """ + return self._controller.getRightX() + + def getRightY(self) -> float: + """ + Get the Right Y value of the controller. + + :returns: the axis value. + """ + return self._controller.getRightY() + + def getL2(self) -> float: + """ + Get the L 2 value of the controller. + + :returns: the axis value. + """ + return self._controller.getL2() + + def getR2(self) -> float: + """ + Get the R 2 value of the controller. + + :returns: the axis value. + """ + return self._controller.getR2() diff --git a/commandsv2/src/main/python/commands2/button/commandgamecubecontroller.py b/commandsv2/src/main/python/commands2/button/commandgamecubecontroller.py new file mode 100644 index 0000000000..db862f6765 --- /dev/null +++ b/commandsv2/src/main/python/commands2/button/commandgamecubecontroller.py @@ -0,0 +1,363 @@ +# THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY + +from typing import Optional, Union + +from wpilib import EventLoop, GameCubeController + +from .commandgenerichid import CommandGenericHID +from .trigger import Trigger + + +class CommandGameCubeController: + """ + A version of :class:`wpilib.GameCubeController` with :class:`.Trigger` factories for command-based. + """ + + _hid: CommandGenericHID + _controller: GameCubeController + + def __init__(self, hid: Union[int, GameCubeController]): + """ + Construct an instance of a controller. + + :param hid: The port index on the Driver Station that the controller is plugged into, + or the GameCubeController object to use for this controller. + """ + if isinstance(hid, int): + self._hid = CommandGenericHID.getCommandGenericHID(hid) + self._controller = GameCubeController(self._hid.getHID()) + else: + self._hid = CommandGenericHID(hid.getHID()) + self._controller = hid + + def getHID(self) -> CommandGenericHID: + """ + Get the underlying CommandGenericHID object. + + :returns: the wrapped CommandGenericHID object + """ + return self._hid + + def getController(self) -> GameCubeController: + """ + Get the wrapped controller object. + + :returns: the wrapped controller object + """ + return self._controller + + def button( + self, + button: GameCubeController.Button, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs an event instance around this button's digital signal. + + :param button: the :class:`wpilib.GameCubeController.Button` to read + :param loop: the event loop instance to attach the event to + """ + return self._hid.button(button.value, loop) + + def a(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the A button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the A button's digital signal + attached to the given loop. + """ + return self.button(GameCubeController.Button.A, loop) + + def x(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the X button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the X button's digital signal + attached to the given loop. + """ + return self.button(GameCubeController.Button.X, loop) + + def b(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the B button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the B button's digital signal + attached to the given loop. + """ + return self.button(GameCubeController.Button.B, loop) + + def y(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Y button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Y button's digital signal + attached to the given loop. + """ + return self.button(GameCubeController.Button.Y, loop) + + def start(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Start button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Start button's digital signal + attached to the given loop. + """ + return self.button(GameCubeController.Button.START, loop) + + def Z(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Z button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Z button's digital signal + attached to the given loop. + """ + return self.button(GameCubeController.Button.Z, loop) + + def dpadUp(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Up button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Up button's digital signal + attached to the given loop. + """ + return self.button(GameCubeController.Button.DPAD_UP, loop) + + def dpadDown(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Down button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Down button's digital signal + attached to the given loop. + """ + return self.button(GameCubeController.Button.DPAD_DOWN, loop) + + def dpadLeft(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Left button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Left button's digital signal + attached to the given loop. + """ + return self.button(GameCubeController.Button.DPAD_LEFT, loop) + + def dpadRight(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Right button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Right button's digital signal + attached to the given loop. + """ + return self.button(GameCubeController.Button.DPAD_RIGHT, loop) + + def L(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the L button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the L button's digital signal + attached to the given loop. + """ + return self.button(GameCubeController.Button.L, loop) + + def R(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the R button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the R button's digital signal + attached to the given loop. + """ + return self.button(GameCubeController.Button.R, loop) + + def LTrigger( + self, + threshold: float = 0.5, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance around the L Trigger axis value. The returned + Trigger will be true when the axis value is greater than ``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. + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance that is true when the L Trigger axis exceeds the + provided threshold, attached to the given event loop. + """ + return self.axisGreaterThan( + GameCubeController.Axis.L_TRIGGER, + threshold, + loop, + ) + + def RTrigger( + self, + threshold: float = 0.5, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance around the R Trigger axis value. The returned + Trigger will be true when the axis value is greater than ``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. + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance that is true when the R Trigger axis exceeds the + provided threshold, attached to the given event loop. + """ + return self.axisGreaterThan( + GameCubeController.Axis.R_TRIGGER, + threshold, + loop, + ) + + def axisLessThan( + self, + axis: GameCubeController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is less than + ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.GameCubeController.Axis` to read + :param threshold: the value below which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to + + :returns: a Trigger instance that is true when the axis value is less than + the provided threshold. + """ + return self._hid.axisLessThan(axis.value, threshold, loop) + + def axisGreaterThan( + self, + axis: GameCubeController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is greater + than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.GameCubeController.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis value is greater + than the provided threshold. + """ + return self._hid.axisGreaterThan(axis.value, threshold, loop) + + def axisMagnitudeGreaterThan( + self, + axis: GameCubeController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis magnitude is + greater than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.GameCubeController.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis magnitude is + greater than the provided threshold. + """ + return self._hid.axisMagnitudeGreaterThan(axis.value, threshold, loop) + + def getAxis(self, axis: GameCubeController.Axis) -> float: + """ + Get the value of the axis. + + :param axis: the :class:`wpilib.GameCubeController.Axis` to read + """ + return self._hid.getRawAxis(axis.value) + + def getLeftX(self) -> float: + """ + Get the Left X value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftX() + + def getLeftY(self) -> float: + """ + Get the Left Y value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftY() + + def getCStickX(self) -> float: + """ + Get the C Stick X value of the controller. + + :returns: the axis value. + """ + return self._controller.getCStickX() + + def getCStickY(self) -> float: + """ + Get the C Stick Y value of the controller. + + :returns: the axis value. + """ + return self._controller.getCStickY() + + def getLTrigger(self) -> float: + """ + Get the L Trigger value of the controller. + + :returns: the axis value. + """ + return self._controller.getLTrigger() + + def getRTrigger(self) -> float: + """ + Get the R Trigger value of the controller. + + :returns: the axis value. + """ + return self._controller.getRTrigger() diff --git a/commandsv2/src/main/python/commands2/button/commandlogitechf310controller.py b/commandsv2/src/main/python/commands2/button/commandlogitechf310controller.py new file mode 100644 index 0000000000..196ae286b4 --- /dev/null +++ b/commandsv2/src/main/python/commands2/button/commandlogitechf310controller.py @@ -0,0 +1,399 @@ +# THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY + +from typing import Optional, Union + +from wpilib import EventLoop, LogitechF310Controller + +from .commandgenerichid import CommandGenericHID +from .trigger import Trigger + + +class CommandLogitechF310Controller: + """ + A version of :class:`wpilib.LogitechF310Controller` with :class:`.Trigger` factories for command-based. + """ + + _hid: CommandGenericHID + _controller: LogitechF310Controller + + def __init__(self, hid: Union[int, LogitechF310Controller]): + """ + Construct an instance of a controller. + + :param hid: The port index on the Driver Station that the controller is plugged into, + or the LogitechF310Controller object to use for this controller. + """ + if isinstance(hid, int): + self._hid = CommandGenericHID.getCommandGenericHID(hid) + self._controller = LogitechF310Controller(self._hid.getHID()) + else: + self._hid = CommandGenericHID(hid.getHID()) + self._controller = hid + + def getHID(self) -> CommandGenericHID: + """ + Get the underlying CommandGenericHID object. + + :returns: the wrapped CommandGenericHID object + """ + return self._hid + + def getController(self) -> LogitechF310Controller: + """ + Get the wrapped controller object. + + :returns: the wrapped controller object + """ + return self._controller + + def button( + self, + button: LogitechF310Controller.Button, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs an event instance around this button's digital signal. + + :param button: the :class:`wpilib.LogitechF310Controller.Button` to read + :param loop: the event loop instance to attach the event to + """ + return self._hid.button(button.value, loop) + + def a(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the A button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the A button's digital signal + attached to the given loop. + """ + return self.button(LogitechF310Controller.Button.A, loop) + + def b(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the B button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the B button's digital signal + attached to the given loop. + """ + return self.button(LogitechF310Controller.Button.B, loop) + + def x(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the X button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the X button's digital signal + attached to the given loop. + """ + return self.button(LogitechF310Controller.Button.X, loop) + + def y(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Y button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Y button's digital signal + attached to the given loop. + """ + return self.button(LogitechF310Controller.Button.Y, loop) + + def back(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Back button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Back button's digital signal + attached to the given loop. + """ + return self.button(LogitechF310Controller.Button.BACK, loop) + + def logitech(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Logitech button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Logitech button's digital signal + attached to the given loop. + """ + return self.button(LogitechF310Controller.Button.LOGITECH, loop) + + def start(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Start button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Start button's digital signal + attached to the given loop. + """ + return self.button(LogitechF310Controller.Button.START, loop) + + def leftStick(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Left Stick button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Left Stick button's digital signal + attached to the given loop. + """ + return self.button(LogitechF310Controller.Button.LEFT_STICK, loop) + + def rightStick(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Right Stick button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Right Stick button's digital signal + attached to the given loop. + """ + return self.button(LogitechF310Controller.Button.RIGHT_STICK, loop) + + def leftBumper(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Left Bumper button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Left Bumper button's digital signal + attached to the given loop. + """ + return self.button(LogitechF310Controller.Button.LEFT_BUMPER, loop) + + def rightBumper(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Right Bumper button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Right Bumper button's digital signal + attached to the given loop. + """ + return self.button(LogitechF310Controller.Button.RIGHT_BUMPER, loop) + + def dpadUp(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Up button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Up button's digital signal + attached to the given loop. + """ + return self.button(LogitechF310Controller.Button.DPAD_UP, loop) + + def dpadDown(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Down button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Down button's digital signal + attached to the given loop. + """ + return self.button(LogitechF310Controller.Button.DPAD_DOWN, loop) + + def dpadLeft(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Left button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Left button's digital signal + attached to the given loop. + """ + return self.button(LogitechF310Controller.Button.DPAD_LEFT, loop) + + def dpadRight(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Right button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Right button's digital signal + attached to the given loop. + """ + return self.button(LogitechF310Controller.Button.DPAD_RIGHT, loop) + + def leftTrigger( + self, + threshold: float = 0.5, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance around the Left Trigger axis value. The returned + Trigger will be true when the axis value is greater than ``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. + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance that is true when the Left Trigger axis exceeds the + provided threshold, attached to the given event loop. + """ + return self.axisGreaterThan( + LogitechF310Controller.Axis.LEFT_TRIGGER, + threshold, + loop, + ) + + def rightTrigger( + self, + threshold: float = 0.5, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance around the Right Trigger axis value. The returned + Trigger will be true when the axis value is greater than ``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. + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance that is true when the Right Trigger axis exceeds the + provided threshold, attached to the given event loop. + """ + return self.axisGreaterThan( + LogitechF310Controller.Axis.RIGHT_TRIGGER, + threshold, + loop, + ) + + def axisLessThan( + self, + axis: LogitechF310Controller.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is less than + ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.LogitechF310Controller.Axis` to read + :param threshold: the value below which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to + + :returns: a Trigger instance that is true when the axis value is less than + the provided threshold. + """ + return self._hid.axisLessThan(axis.value, threshold, loop) + + def axisGreaterThan( + self, + axis: LogitechF310Controller.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is greater + than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.LogitechF310Controller.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis value is greater + than the provided threshold. + """ + return self._hid.axisGreaterThan(axis.value, threshold, loop) + + def axisMagnitudeGreaterThan( + self, + axis: LogitechF310Controller.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis magnitude is + greater than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.LogitechF310Controller.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis magnitude is + greater than the provided threshold. + """ + return self._hid.axisMagnitudeGreaterThan(axis.value, threshold, loop) + + def getAxis(self, axis: LogitechF310Controller.Axis) -> float: + """ + Get the value of the axis. + + :param axis: the :class:`wpilib.LogitechF310Controller.Axis` to read + """ + return self._hid.getRawAxis(axis.value) + + def getLeftX(self) -> float: + """ + Get the Left X value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftX() + + def getLeftY(self) -> float: + """ + Get the Left Y value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftY() + + def getRightX(self) -> float: + """ + Get the Right X value of the controller. + + :returns: the axis value. + """ + return self._controller.getRightX() + + def getRightY(self) -> float: + """ + Get the Right Y value of the controller. + + :returns: the axis value. + """ + return self._controller.getRightY() + + def getLeftTrigger(self) -> float: + """ + Get the Left Trigger value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftTrigger() + + def getRightTrigger(self) -> float: + """ + Get the Right Trigger value of the controller. + + :returns: the axis value. + """ + return self._controller.getRightTrigger() diff --git a/commandsv2/src/main/python/commands2/button/commandsteamcontroller.py b/commandsv2/src/main/python/commands2/button/commandsteamcontroller.py new file mode 100644 index 0000000000..2e20f26122 --- /dev/null +++ b/commandsv2/src/main/python/commands2/button/commandsteamcontroller.py @@ -0,0 +1,531 @@ +# THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY + +from typing import Optional, Union + +from wpilib import EventLoop, SteamController + +from .commandgenerichid import CommandGenericHID +from .trigger import Trigger + + +class CommandSteamController: + """ + A version of :class:`wpilib.SteamController` with :class:`.Trigger` factories for command-based. + """ + + _hid: CommandGenericHID + _controller: SteamController + + def __init__(self, hid: Union[int, SteamController]): + """ + Construct an instance of a controller. + + :param hid: The port index on the Driver Station that the controller is plugged into, + or the SteamController object to use for this controller. + """ + if isinstance(hid, int): + self._hid = CommandGenericHID.getCommandGenericHID(hid) + self._controller = SteamController(self._hid.getHID()) + else: + self._hid = CommandGenericHID(hid.getHID()) + self._controller = hid + + def getHID(self) -> CommandGenericHID: + """ + Get the underlying CommandGenericHID object. + + :returns: the wrapped CommandGenericHID object + """ + return self._hid + + def getController(self) -> SteamController: + """ + Get the wrapped controller object. + + :returns: the wrapped controller object + """ + return self._controller + + def button( + self, + button: SteamController.Button, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs an event instance around this button's digital signal. + + :param button: the :class:`wpilib.SteamController.Button` to read + :param loop: the event loop instance to attach the event to + """ + return self._hid.button(button.value, loop) + + def a(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the A button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the A button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.A, loop) + + def b(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the B button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the B button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.B, loop) + + def x(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the X button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the X button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.X, loop) + + def y(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Y button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Y button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.Y, loop) + + def menu(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Menu button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Menu button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.MENU, loop) + + def steam(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Steam button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Steam button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.STEAM, loop) + + def view(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the View button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the View button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.VIEW, loop) + + def leftStick(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Left Stick button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Left Stick button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.LEFT_STICK, loop) + + def rightStick(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Right Stick button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Right Stick button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.RIGHT_STICK, loop) + + def leftBumper(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Left Bumper button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Left Bumper button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.LEFT_BUMPER, loop) + + def rightBumper(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Right Bumper button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Right Bumper button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.RIGHT_BUMPER, loop) + + def dpadUp(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Up button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Up button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.DPAD_UP, loop) + + def dpadDown(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Down button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Down button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.DPAD_DOWN, loop) + + def dpadLeft(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Left button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Left button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.DPAD_LEFT, loop) + + def dpadRight(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Right button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Right button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.DPAD_RIGHT, loop) + + def QAM(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the QAM button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the QAM button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.QAM, loop) + + def rightPaddle1(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Right Paddle 1 button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Right Paddle 1 button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.RIGHT_PADDLE_1, loop) + + def leftPaddle1(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Left Paddle 1 button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Left Paddle 1 button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.LEFT_PADDLE_1, loop) + + def rightPaddle2(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Right Paddle 2 button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Right Paddle 2 button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.RIGHT_PADDLE_2, loop) + + def leftPaddle2(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Left Paddle 2 button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Left Paddle 2 button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.LEFT_PADDLE_2, loop) + + def leftTouchpad(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Left Touchpad button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Left Touchpad button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.LEFT_TOUCHPAD, loop) + + def rightTouchpad(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Right Touchpad button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Right Touchpad button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.RIGHT_TOUCHPAD, loop) + + def leftStickTouch(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Left Stick Touch button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Left Stick Touch button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.LEFT_STICK_TOUCH, loop) + + def rightStickTouch(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Right Stick Touch button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Right Stick Touch button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.RIGHT_STICK_TOUCH, loop) + + def leftGripTouch(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Left Grip Touch button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Left Grip Touch button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.LEFT_GRIP_TOUCH, loop) + + def rightGripTouch(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Right Grip Touch button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Right Grip Touch button's digital signal + attached to the given loop. + """ + return self.button(SteamController.Button.RIGHT_GRIP_TOUCH, loop) + + def leftTrigger( + self, + threshold: float = 0.5, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance around the Left Trigger axis value. The returned + Trigger will be true when the axis value is greater than ``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. + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance that is true when the Left Trigger axis exceeds the + provided threshold, attached to the given event loop. + """ + return self.axisGreaterThan( + SteamController.Axis.LEFT_TRIGGER, + threshold, + loop, + ) + + def rightTrigger( + self, + threshold: float = 0.5, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance around the Right Trigger axis value. The returned + Trigger will be true when the axis value is greater than ``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. + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance that is true when the Right Trigger axis exceeds the + provided threshold, attached to the given event loop. + """ + return self.axisGreaterThan( + SteamController.Axis.RIGHT_TRIGGER, + threshold, + loop, + ) + + def axisLessThan( + self, + axis: SteamController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is less than + ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.SteamController.Axis` to read + :param threshold: the value below which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to + + :returns: a Trigger instance that is true when the axis value is less than + the provided threshold. + """ + return self._hid.axisLessThan(axis.value, threshold, loop) + + def axisGreaterThan( + self, + axis: SteamController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is greater + than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.SteamController.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis value is greater + than the provided threshold. + """ + return self._hid.axisGreaterThan(axis.value, threshold, loop) + + def axisMagnitudeGreaterThan( + self, + axis: SteamController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis magnitude is + greater than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.SteamController.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis magnitude is + greater than the provided threshold. + """ + return self._hid.axisMagnitudeGreaterThan(axis.value, threshold, loop) + + def getAxis(self, axis: SteamController.Axis) -> float: + """ + Get the value of the axis. + + :param axis: the :class:`wpilib.SteamController.Axis` to read + """ + return self._hid.getRawAxis(axis.value) + + def getLeftX(self) -> float: + """ + Get the Left X value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftX() + + def getLeftY(self) -> float: + """ + Get the Left Y value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftY() + + def getRightX(self) -> float: + """ + Get the Right X value of the controller. + + :returns: the axis value. + """ + return self._controller.getRightX() + + def getRightY(self) -> float: + """ + Get the Right Y value of the controller. + + :returns: the axis value. + """ + return self._controller.getRightY() + + def getLeftTrigger(self) -> float: + """ + Get the Left Trigger value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftTrigger() + + def getRightTrigger(self) -> float: + """ + Get the Right Trigger value of the controller. + + :returns: the axis value. + """ + return self._controller.getRightTrigger() diff --git a/commandsv2/src/main/python/commands2/button/commandswitch2gccontroller.py b/commandsv2/src/main/python/commands2/button/commandswitch2gccontroller.py new file mode 100644 index 0000000000..3ca93bd9e7 --- /dev/null +++ b/commandsv2/src/main/python/commands2/button/commandswitch2gccontroller.py @@ -0,0 +1,411 @@ +# THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY + +from typing import Optional, Union + +from wpilib import EventLoop, Switch2GCController + +from .commandgenerichid import CommandGenericHID +from .trigger import Trigger + + +class CommandSwitch2GCController: + """ + A version of :class:`wpilib.Switch2GCController` with :class:`.Trigger` factories for command-based. + """ + + _hid: CommandGenericHID + _controller: Switch2GCController + + def __init__(self, hid: Union[int, Switch2GCController]): + """ + Construct an instance of a controller. + + :param hid: The port index on the Driver Station that the controller is plugged into, + or the Switch2GCController object to use for this controller. + """ + if isinstance(hid, int): + self._hid = CommandGenericHID.getCommandGenericHID(hid) + self._controller = Switch2GCController(self._hid.getHID()) + else: + self._hid = CommandGenericHID(hid.getHID()) + self._controller = hid + + def getHID(self) -> CommandGenericHID: + """ + Get the underlying CommandGenericHID object. + + :returns: the wrapped CommandGenericHID object + """ + return self._hid + + def getController(self) -> Switch2GCController: + """ + Get the wrapped controller object. + + :returns: the wrapped controller object + """ + return self._controller + + def button( + self, + button: Switch2GCController.Button, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs an event instance around this button's digital signal. + + :param button: the :class:`wpilib.Switch2GCController.Button` to read + :param loop: the event loop instance to attach the event to + """ + return self._hid.button(button.value, loop) + + def a(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the A button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the A button's digital signal + attached to the given loop. + """ + return self.button(Switch2GCController.Button.A, loop) + + def x(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the X button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the X button's digital signal + attached to the given loop. + """ + return self.button(Switch2GCController.Button.X, loop) + + def b(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the B button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the B button's digital signal + attached to the given loop. + """ + return self.button(Switch2GCController.Button.B, loop) + + def y(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Y button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Y button's digital signal + attached to the given loop. + """ + return self.button(Switch2GCController.Button.Y, loop) + + def home(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Home button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Home button's digital signal + attached to the given loop. + """ + return self.button(Switch2GCController.Button.HOME, loop) + + def start(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Start button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Start button's digital signal + attached to the given loop. + """ + return self.button(Switch2GCController.Button.START, loop) + + def ZL(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the ZL button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the ZL button's digital signal + attached to the given loop. + """ + return self.button(Switch2GCController.Button.ZL, loop) + + def Z(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Z button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Z button's digital signal + attached to the given loop. + """ + return self.button(Switch2GCController.Button.Z, loop) + + def dpadUp(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Up button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Up button's digital signal + attached to the given loop. + """ + return self.button(Switch2GCController.Button.DPAD_UP, loop) + + def dpadDown(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Down button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Down button's digital signal + attached to the given loop. + """ + return self.button(Switch2GCController.Button.DPAD_DOWN, loop) + + def dpadLeft(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Left button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Left button's digital signal + attached to the given loop. + """ + return self.button(Switch2GCController.Button.DPAD_LEFT, loop) + + def dpadRight(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Right button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Right button's digital signal + attached to the given loop. + """ + return self.button(Switch2GCController.Button.DPAD_RIGHT, loop) + + def capture(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Capture button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Capture button's digital signal + attached to the given loop. + """ + return self.button(Switch2GCController.Button.CAPTURE, loop) + + def C(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the C button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the C button's digital signal + attached to the given loop. + """ + return self.button(Switch2GCController.Button.C, loop) + + def L(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the L button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the L button's digital signal + attached to the given loop. + """ + return self.button(Switch2GCController.Button.L, loop) + + def R(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the R button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the R button's digital signal + attached to the given loop. + """ + return self.button(Switch2GCController.Button.R, loop) + + def LTrigger( + self, + threshold: float = 0.5, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance around the L Trigger axis value. The returned + Trigger will be true when the axis value is greater than ``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. + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance that is true when the L Trigger axis exceeds the + provided threshold, attached to the given event loop. + """ + return self.axisGreaterThan( + Switch2GCController.Axis.L_TRIGGER, + threshold, + loop, + ) + + def RTrigger( + self, + threshold: float = 0.5, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance around the R Trigger axis value. The returned + Trigger will be true when the axis value is greater than ``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. + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance that is true when the R Trigger axis exceeds the + provided threshold, attached to the given event loop. + """ + return self.axisGreaterThan( + Switch2GCController.Axis.R_TRIGGER, + threshold, + loop, + ) + + def axisLessThan( + self, + axis: Switch2GCController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is less than + ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.Switch2GCController.Axis` to read + :param threshold: the value below which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to + + :returns: a Trigger instance that is true when the axis value is less than + the provided threshold. + """ + return self._hid.axisLessThan(axis.value, threshold, loop) + + def axisGreaterThan( + self, + axis: Switch2GCController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is greater + than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.Switch2GCController.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis value is greater + than the provided threshold. + """ + return self._hid.axisGreaterThan(axis.value, threshold, loop) + + def axisMagnitudeGreaterThan( + self, + axis: Switch2GCController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis magnitude is + greater than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.Switch2GCController.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis magnitude is + greater than the provided threshold. + """ + return self._hid.axisMagnitudeGreaterThan(axis.value, threshold, loop) + + def getAxis(self, axis: Switch2GCController.Axis) -> float: + """ + Get the value of the axis. + + :param axis: the :class:`wpilib.Switch2GCController.Axis` to read + """ + return self._hid.getRawAxis(axis.value) + + def getLeftX(self) -> float: + """ + Get the Left X value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftX() + + def getLeftY(self) -> float: + """ + Get the Left Y value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftY() + + def getCStickX(self) -> float: + """ + Get the C Stick X value of the controller. + + :returns: the axis value. + """ + return self._controller.getCStickX() + + def getCStickY(self) -> float: + """ + Get the C Stick Y value of the controller. + + :returns: the axis value. + """ + return self._controller.getCStickY() + + def getLTrigger(self) -> float: + """ + Get the L Trigger value of the controller. + + :returns: the axis value. + """ + return self._controller.getLTrigger() + + def getRTrigger(self) -> float: + """ + Get the R Trigger value of the controller. + + :returns: the axis value. + """ + return self._controller.getRTrigger() diff --git a/commandsv2/src/main/python/commands2/button/commandswitch2procontroller.py b/commandsv2/src/main/python/commands2/button/commandswitch2procontroller.py new file mode 100644 index 0000000000..ac985477d6 --- /dev/null +++ b/commandsv2/src/main/python/commands2/button/commandswitch2procontroller.py @@ -0,0 +1,447 @@ +# THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY + +from typing import Optional, Union + +from wpilib import EventLoop, Switch2ProController + +from .commandgenerichid import CommandGenericHID +from .trigger import Trigger + + +class CommandSwitch2ProController: + """ + A version of :class:`wpilib.Switch2ProController` with :class:`.Trigger` factories for command-based. + """ + + _hid: CommandGenericHID + _controller: Switch2ProController + + def __init__(self, hid: Union[int, Switch2ProController]): + """ + Construct an instance of a controller. + + :param hid: The port index on the Driver Station that the controller is plugged into, + or the Switch2ProController object to use for this controller. + """ + if isinstance(hid, int): + self._hid = CommandGenericHID.getCommandGenericHID(hid) + self._controller = Switch2ProController(self._hid.getHID()) + else: + self._hid = CommandGenericHID(hid.getHID()) + self._controller = hid + + def getHID(self) -> CommandGenericHID: + """ + Get the underlying CommandGenericHID object. + + :returns: the wrapped CommandGenericHID object + """ + return self._hid + + def getController(self) -> Switch2ProController: + """ + Get the wrapped controller object. + + :returns: the wrapped controller object + """ + return self._controller + + def button( + self, + button: Switch2ProController.Button, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs an event instance around this button's digital signal. + + :param button: the :class:`wpilib.Switch2ProController.Button` to read + :param loop: the event loop instance to attach the event to + """ + return self._hid.button(button.value, loop) + + def b(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the B button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the B button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.B, loop) + + def a(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the A button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the A button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.A, loop) + + def y(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Y button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Y button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.Y, loop) + + def x(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the X button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the X button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.X, loop) + + def minus(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Minus button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Minus button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.MINUS, loop) + + def home(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Home button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Home button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.HOME, loop) + + def plus(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Plus button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Plus button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.PLUS, loop) + + def leftStick(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Left Stick button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Left Stick button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.LEFT_STICK, loop) + + def rightStick(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Right Stick button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Right Stick button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.RIGHT_STICK, loop) + + def L(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the L button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the L button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.L, loop) + + def R(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the R button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the R button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.R, loop) + + def dpadUp(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Up button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Up button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.DPAD_UP, loop) + + def dpadDown(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Down button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Down button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.DPAD_DOWN, loop) + + def dpadLeft(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Left button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Left button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.DPAD_LEFT, loop) + + def dpadRight(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Right button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Right button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.DPAD_RIGHT, loop) + + def capture(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Capture button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Capture button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.CAPTURE, loop) + + def GR(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the GR button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the GR button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.GR, loop) + + def GL(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the GL button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the GL button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.GL, loop) + + def C(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the C button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the C button's digital signal + attached to the given loop. + """ + return self.button(Switch2ProController.Button.C, loop) + + def ZL( + self, + threshold: float = 0.5, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance around the ZL axis value. The returned + Trigger will be true when the axis value is greater than ``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. + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance that is true when the ZL axis exceeds the + provided threshold, attached to the given event loop. + """ + return self.axisGreaterThan( + Switch2ProController.Axis.ZL, + threshold, + loop, + ) + + def ZR( + self, + threshold: float = 0.5, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance around the ZR axis value. The returned + Trigger will be true when the axis value is greater than ``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. + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance that is true when the ZR axis exceeds the + provided threshold, attached to the given event loop. + """ + return self.axisGreaterThan( + Switch2ProController.Axis.ZR, + threshold, + loop, + ) + + def axisLessThan( + self, + axis: Switch2ProController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is less than + ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.Switch2ProController.Axis` to read + :param threshold: the value below which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to + + :returns: a Trigger instance that is true when the axis value is less than + the provided threshold. + """ + return self._hid.axisLessThan(axis.value, threshold, loop) + + def axisGreaterThan( + self, + axis: Switch2ProController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is greater + than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.Switch2ProController.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis value is greater + than the provided threshold. + """ + return self._hid.axisGreaterThan(axis.value, threshold, loop) + + def axisMagnitudeGreaterThan( + self, + axis: Switch2ProController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis magnitude is + greater than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.Switch2ProController.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis magnitude is + greater than the provided threshold. + """ + return self._hid.axisMagnitudeGreaterThan(axis.value, threshold, loop) + + def getAxis(self, axis: Switch2ProController.Axis) -> float: + """ + Get the value of the axis. + + :param axis: the :class:`wpilib.Switch2ProController.Axis` to read + """ + return self._hid.getRawAxis(axis.value) + + def getLeftX(self) -> float: + """ + Get the Left X value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftX() + + def getLeftY(self) -> float: + """ + Get the Left Y value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftY() + + def getRightX(self) -> float: + """ + Get the Right X value of the controller. + + :returns: the axis value. + """ + return self._controller.getRightX() + + def getRightY(self) -> float: + """ + Get the Right Y value of the controller. + + :returns: the axis value. + """ + return self._controller.getRightY() + + def getZL(self) -> float: + """ + Get the ZL value of the controller. + + :returns: the axis value. + """ + return self._controller.getZL() + + def getZR(self) -> float: + """ + Get the ZR value of the controller. + + :returns: the axis value. + """ + return self._controller.getZR() diff --git a/commandsv2/src/main/python/commands2/button/commandswitchn64controller.py b/commandsv2/src/main/python/commands2/button/commandswitchn64controller.py new file mode 100644 index 0000000000..01538fa3a7 --- /dev/null +++ b/commandsv2/src/main/python/commands2/button/commandswitchn64controller.py @@ -0,0 +1,360 @@ +# THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY + +from typing import Optional, Union + +from wpilib import EventLoop, SwitchN64Controller + +from .commandgenerichid import CommandGenericHID +from .trigger import Trigger + + +class CommandSwitchN64Controller: + """ + A version of :class:`wpilib.SwitchN64Controller` with :class:`.Trigger` factories for command-based. + """ + + _hid: CommandGenericHID + _controller: SwitchN64Controller + + def __init__(self, hid: Union[int, SwitchN64Controller]): + """ + Construct an instance of a controller. + + :param hid: The port index on the Driver Station that the controller is plugged into, + or the SwitchN64Controller object to use for this controller. + """ + if isinstance(hid, int): + self._hid = CommandGenericHID.getCommandGenericHID(hid) + self._controller = SwitchN64Controller(self._hid.getHID()) + else: + self._hid = CommandGenericHID(hid.getHID()) + self._controller = hid + + def getHID(self) -> CommandGenericHID: + """ + Get the underlying CommandGenericHID object. + + :returns: the wrapped CommandGenericHID object + """ + return self._hid + + def getController(self) -> SwitchN64Controller: + """ + Get the wrapped controller object. + + :returns: the wrapped controller object + """ + return self._controller + + def button( + self, + button: SwitchN64Controller.Button, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs an event instance around this button's digital signal. + + :param button: the :class:`wpilib.SwitchN64Controller.Button` to read + :param loop: the event loop instance to attach the event to + """ + return self._hid.button(button.value, loop) + + def a(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the A button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the A button's digital signal + attached to the given loop. + """ + return self.button(SwitchN64Controller.Button.A, loop) + + def b(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the B button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the B button's digital signal + attached to the given loop. + """ + return self.button(SwitchN64Controller.Button.B, loop) + + def CLeft(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the C Left button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the C Left button's digital signal + attached to the given loop. + """ + return self.button(SwitchN64Controller.Button.C_LEFT, loop) + + def CUp(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the C Up button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the C Up button's digital signal + attached to the given loop. + """ + return self.button(SwitchN64Controller.Button.C_UP, loop) + + def capture(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Capture button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Capture button's digital signal + attached to the given loop. + """ + return self.button(SwitchN64Controller.Button.CAPTURE, loop) + + def home(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Home button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Home button's digital signal + attached to the given loop. + """ + return self.button(SwitchN64Controller.Button.HOME, loop) + + def start(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Start button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Start button's digital signal + attached to the given loop. + """ + return self.button(SwitchN64Controller.Button.START, loop) + + def CDown(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the C Down button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the C Down button's digital signal + attached to the given loop. + """ + return self.button(SwitchN64Controller.Button.C_DOWN, loop) + + def L(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the L button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the L button's digital signal + attached to the given loop. + """ + return self.button(SwitchN64Controller.Button.L, loop) + + def R(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the R button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the R button's digital signal + attached to the given loop. + """ + return self.button(SwitchN64Controller.Button.R, loop) + + def dpadUp(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Up button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Up button's digital signal + attached to the given loop. + """ + return self.button(SwitchN64Controller.Button.DPAD_UP, loop) + + def dpadDown(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Down button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Down button's digital signal + attached to the given loop. + """ + return self.button(SwitchN64Controller.Button.DPAD_DOWN, loop) + + def dpadLeft(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Left button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Left button's digital signal + attached to the given loop. + """ + return self.button(SwitchN64Controller.Button.DPAD_LEFT, loop) + + def dpadRight(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Right button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Right button's digital signal + attached to the given loop. + """ + return self.button(SwitchN64Controller.Button.DPAD_RIGHT, loop) + + def CRight(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the C Right button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the C Right button's digital signal + attached to the given loop. + """ + return self.button(SwitchN64Controller.Button.C_RIGHT, loop) + + def ZR( + self, + threshold: float = 0.5, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance around the ZR axis value. The returned + Trigger will be true when the axis value is greater than ``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. + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance that is true when the ZR axis exceeds the + provided threshold, attached to the given event loop. + """ + return self.axisGreaterThan( + SwitchN64Controller.Axis.ZR, + threshold, + loop, + ) + + def axisLessThan( + self, + axis: SwitchN64Controller.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is less than + ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.SwitchN64Controller.Axis` to read + :param threshold: the value below which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to + + :returns: a Trigger instance that is true when the axis value is less than + the provided threshold. + """ + return self._hid.axisLessThan(axis.value, threshold, loop) + + def axisGreaterThan( + self, + axis: SwitchN64Controller.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is greater + than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.SwitchN64Controller.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis value is greater + than the provided threshold. + """ + return self._hid.axisGreaterThan(axis.value, threshold, loop) + + def axisMagnitudeGreaterThan( + self, + axis: SwitchN64Controller.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis magnitude is + greater than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.SwitchN64Controller.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis magnitude is + greater than the provided threshold. + """ + return self._hid.axisMagnitudeGreaterThan(axis.value, threshold, loop) + + def getAxis(self, axis: SwitchN64Controller.Axis) -> float: + """ + Get the value of the axis. + + :param axis: the :class:`wpilib.SwitchN64Controller.Axis` to read + """ + return self._hid.getRawAxis(axis.value) + + def getLeftX(self) -> float: + """ + Get the Left X value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftX() + + def getLeftY(self) -> float: + """ + Get the Left Y value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftY() + + def getZAxis(self) -> float: + """ + Get the Z Axis value of the controller. + + :returns: the axis value. + """ + return self._controller.getZAxis() + + def getZR(self) -> float: + """ + Get the ZR value of the controller. + + :returns: the axis value. + """ + return self._controller.getZR() diff --git a/commandsv2/src/main/python/commands2/button/commandswitchprocontroller.py b/commandsv2/src/main/python/commands2/button/commandswitchprocontroller.py new file mode 100644 index 0000000000..940c6f83be --- /dev/null +++ b/commandsv2/src/main/python/commands2/button/commandswitchprocontroller.py @@ -0,0 +1,411 @@ +# THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY + +from typing import Optional, Union + +from wpilib import EventLoop, SwitchProController + +from .commandgenerichid import CommandGenericHID +from .trigger import Trigger + + +class CommandSwitchProController: + """ + A version of :class:`wpilib.SwitchProController` with :class:`.Trigger` factories for command-based. + """ + + _hid: CommandGenericHID + _controller: SwitchProController + + def __init__(self, hid: Union[int, SwitchProController]): + """ + Construct an instance of a controller. + + :param hid: The port index on the Driver Station that the controller is plugged into, + or the SwitchProController object to use for this controller. + """ + if isinstance(hid, int): + self._hid = CommandGenericHID.getCommandGenericHID(hid) + self._controller = SwitchProController(self._hid.getHID()) + else: + self._hid = CommandGenericHID(hid.getHID()) + self._controller = hid + + def getHID(self) -> CommandGenericHID: + """ + Get the underlying CommandGenericHID object. + + :returns: the wrapped CommandGenericHID object + """ + return self._hid + + def getController(self) -> SwitchProController: + """ + Get the wrapped controller object. + + :returns: the wrapped controller object + """ + return self._controller + + def button( + self, + button: SwitchProController.Button, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs an event instance around this button's digital signal. + + :param button: the :class:`wpilib.SwitchProController.Button` to read + :param loop: the event loop instance to attach the event to + """ + return self._hid.button(button.value, loop) + + def b(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the B button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the B button's digital signal + attached to the given loop. + """ + return self.button(SwitchProController.Button.B, loop) + + def a(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the A button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the A button's digital signal + attached to the given loop. + """ + return self.button(SwitchProController.Button.A, loop) + + def y(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Y button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Y button's digital signal + attached to the given loop. + """ + return self.button(SwitchProController.Button.Y, loop) + + def x(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the X button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the X button's digital signal + attached to the given loop. + """ + return self.button(SwitchProController.Button.X, loop) + + def minus(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Minus button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Minus button's digital signal + attached to the given loop. + """ + return self.button(SwitchProController.Button.MINUS, loop) + + def home(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Home button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Home button's digital signal + attached to the given loop. + """ + return self.button(SwitchProController.Button.HOME, loop) + + def plus(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Plus button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Plus button's digital signal + attached to the given loop. + """ + return self.button(SwitchProController.Button.PLUS, loop) + + def leftStick(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Left Stick button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Left Stick button's digital signal + attached to the given loop. + """ + return self.button(SwitchProController.Button.LEFT_STICK, loop) + + def rightStick(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Right Stick button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Right Stick button's digital signal + attached to the given loop. + """ + return self.button(SwitchProController.Button.RIGHT_STICK, loop) + + def L(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the L button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the L button's digital signal + attached to the given loop. + """ + return self.button(SwitchProController.Button.L, loop) + + def R(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the R button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the R button's digital signal + attached to the given loop. + """ + return self.button(SwitchProController.Button.R, loop) + + def dpadUp(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Up button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Up button's digital signal + attached to the given loop. + """ + return self.button(SwitchProController.Button.DPAD_UP, loop) + + def dpadDown(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Down button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Down button's digital signal + attached to the given loop. + """ + return self.button(SwitchProController.Button.DPAD_DOWN, loop) + + def dpadLeft(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Left button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Left button's digital signal + attached to the given loop. + """ + return self.button(SwitchProController.Button.DPAD_LEFT, loop) + + def dpadRight(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Dpad Right button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Dpad Right button's digital signal + attached to the given loop. + """ + return self.button(SwitchProController.Button.DPAD_RIGHT, loop) + + def capture(self, loop: Optional[EventLoop] = None) -> Trigger: + """ + Constructs a Trigger instance around the Capture button's digital signal. + + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance representing the Capture button's digital signal + attached to the given loop. + """ + return self.button(SwitchProController.Button.CAPTURE, loop) + + def ZL( + self, + threshold: float = 0.5, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance around the ZL axis value. The returned + Trigger will be true when the axis value is greater than ``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. + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance that is true when the ZL axis exceeds the + provided threshold, attached to the given event loop. + """ + return self.axisGreaterThan( + SwitchProController.Axis.ZL, + threshold, + loop, + ) + + def ZR( + self, + threshold: float = 0.5, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance around the ZR axis value. The returned + Trigger will be true when the axis value is greater than ``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. + :param loop: the event loop instance to attach the Trigger to, defaults + to :func:`commands2.CommandScheduler.getDefaultButtonLoop` + + :returns: a Trigger instance that is true when the ZR axis exceeds the + provided threshold, attached to the given event loop. + """ + return self.axisGreaterThan( + SwitchProController.Axis.ZR, + threshold, + loop, + ) + + def axisLessThan( + self, + axis: SwitchProController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is less than + ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.SwitchProController.Axis` to read + :param threshold: the value below which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to + + :returns: a Trigger instance that is true when the axis value is less than + the provided threshold. + """ + return self._hid.axisLessThan(axis.value, threshold, loop) + + def axisGreaterThan( + self, + axis: SwitchProController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis value is greater + than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.SwitchProController.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis value is greater + than the provided threshold. + """ + return self._hid.axisGreaterThan(axis.value, threshold, loop) + + def axisMagnitudeGreaterThan( + self, + axis: SwitchProController.Axis, + threshold: float, + loop: Optional[EventLoop] = None, + ) -> Trigger: + """ + Constructs a Trigger instance that is true when the axis magnitude is + greater than ``threshold``, attached to the given loop. + + :param axis: the :class:`wpilib.SwitchProController.Axis` to read + :param threshold: the value above which this Trigger should return true. + :param loop: the event loop instance to attach the Trigger to. + + :returns: a Trigger instance that is true when the axis magnitude is + greater than the provided threshold. + """ + return self._hid.axisMagnitudeGreaterThan(axis.value, threshold, loop) + + def getAxis(self, axis: SwitchProController.Axis) -> float: + """ + Get the value of the axis. + + :param axis: the :class:`wpilib.SwitchProController.Axis` to read + """ + return self._hid.getRawAxis(axis.value) + + def getLeftX(self) -> float: + """ + Get the Left X value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftX() + + def getLeftY(self) -> float: + """ + Get the Left Y value of the controller. + + :returns: the axis value. + """ + return self._controller.getLeftY() + + def getRightX(self) -> float: + """ + Get the Right X value of the controller. + + :returns: the axis value. + """ + return self._controller.getRightX() + + def getRightY(self) -> float: + """ + Get the Right Y value of the controller. + + :returns: the axis value. + """ + return self._controller.getRightY() + + def getZL(self) -> float: + """ + Get the ZL value of the controller. + + :returns: the axis value. + """ + return self._controller.getZL() + + def getZR(self) -> float: + """ + Get the ZR value of the controller. + + :returns: the axis value. + """ + return self._controller.getZR() diff --git a/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandDualSenseEdgeController.java b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandDualSenseEdgeController.java new file mode 100644 index 0000000000..63a5ae098c --- /dev/null +++ b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandDualSenseEdgeController.java @@ -0,0 +1,733 @@ +// 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 ./commandsv3/generate_files.py. DO NOT MODIFY + +package org.wpilib.command3.button; + +import java.util.Objects; +import org.wpilib.command3.Scheduler; +import org.wpilib.command3.Trigger; +import org.wpilib.driverstation.DualSenseEdgeController; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link DualSenseEdgeController} with {@link Trigger} factories for command-based. + * + * @see DualSenseEdgeController + */ +@SuppressWarnings("MethodName") +public class CommandDualSenseEdgeController { + private final CommandGenericHID m_hid; + private final DualSenseEdgeController m_controller; + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandDualSenseEdgeController(int port) { + this(Scheduler.getDefault(), port); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param controller The DualSenseEdgeController object to use for this controller. + */ + public CommandDualSenseEdgeController(DualSenseEdgeController controller) { + this(Scheduler.getDefault(), controller); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandDualSenseEdgeController(Scheduler scheduler, int port) { + m_hid = CommandGenericHID.getCommandGenericHID(scheduler, port); + m_controller = new DualSenseEdgeController(m_hid.getHID()); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param controller The DualSenseEdgeController object to use for this controller. + */ + public CommandDualSenseEdgeController(Scheduler scheduler, DualSenseEdgeController controller) { + m_controller = + Objects.requireNonNull(controller, "Provided DualSenseEdgeController cannot be null"); + m_hid = new CommandGenericHID(scheduler, m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public DualSenseEdgeController getController() { + return m_controller; + } + + /** + * 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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #cross(EventLoop) + */ + public Trigger cross() { + return cross(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(DualSenseEdgeController.Button.CROSS.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #circle(EventLoop) + */ + public Trigger circle() { + return circle(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(DualSenseEdgeController.Button.CIRCLE.value, loop); + } + + /** + * 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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #square(EventLoop) + */ + public Trigger square() { + return square(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(DualSenseEdgeController.Button.SQUARE.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #triangle(EventLoop) + */ + public Trigger triangle() { + return triangle(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(DualSenseEdgeController.Button.TRIANGLE.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #create(EventLoop) + */ + public Trigger create() { + return create(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(DualSenseEdgeController.Button.CREATE.value, loop); + } + + /** + * Constructs a Trigger instance around the PS button's digital signal. + * + * @return a Trigger instance representing the PS button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #PS(EventLoop) + */ + public Trigger PS() { + return PS(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the PS button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the PS button's digital signal attached + * to the given loop. + */ + public Trigger PS(EventLoop loop) { + return m_hid.button(DualSenseEdgeController.Button.PS.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #options(EventLoop) + */ + public Trigger options() { + return options(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(DualSenseEdgeController.Button.OPTIONS.value, loop); + } + + /** + * Constructs a Trigger instance around the L 3 button's digital signal. + * + * @return a Trigger instance representing the L 3 button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #L3(EventLoop) + */ + public Trigger L3() { + return L3(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the L 3 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L 3 button's digital signal attached + * to the given loop. + */ + public Trigger L3(EventLoop loop) { + return m_hid.button(DualSenseEdgeController.Button.L3.value, loop); + } + + /** + * Constructs a Trigger instance around the R 3 button's digital signal. + * + * @return a Trigger instance representing the R 3 button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #R3(EventLoop) + */ + public Trigger R3() { + return R3(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the R 3 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R 3 button's digital signal attached + * to the given loop. + */ + public Trigger R3(EventLoop loop) { + return m_hid.button(DualSenseEdgeController.Button.R3.value, loop); + } + + /** + * Constructs a Trigger instance around the L 1 button's digital signal. + * + * @return a Trigger instance representing the L 1 button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #L1(EventLoop) + */ + public Trigger L1() { + return L1(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the L 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L 1 button's digital signal attached + * to the given loop. + */ + public Trigger L1(EventLoop loop) { + return m_hid.button(DualSenseEdgeController.Button.L1.value, loop); + } + + /** + * Constructs a Trigger instance around the R 1 button's digital signal. + * + * @return a Trigger instance representing the R 1 button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #R1(EventLoop) + */ + public Trigger R1() { + return R1(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the R 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R 1 button's digital signal attached + * to the given loop. + */ + public Trigger R1(EventLoop loop) { + return m_hid.button(DualSenseEdgeController.Button.R1.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return m_hid.button(DualSenseEdgeController.Button.DPAD_UP.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return m_hid.button(DualSenseEdgeController.Button.DPAD_DOWN.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return m_hid.button(DualSenseEdgeController.Button.DPAD_LEFT.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return m_hid.button(DualSenseEdgeController.Button.DPAD_RIGHT.value, loop); + } + + /** + * Constructs a Trigger instance around the Microphone button's digital signal. + * + * @return a Trigger instance representing the Microphone button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #microphone(EventLoop) + */ + public Trigger microphone() { + return microphone(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Microphone button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Microphone button's digital signal attached + * to the given loop. + */ + public Trigger microphone(EventLoop loop) { + return m_hid.button(DualSenseEdgeController.Button.MICROPHONE.value, loop); + } + + /** + * Constructs a Trigger instance around the Right Paddle 1 button's digital signal. + * + * @return a Trigger instance representing the Right Paddle 1 button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #rightPaddle1(EventLoop) + */ + public Trigger rightPaddle1() { + return rightPaddle1(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Right Paddle 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Right Paddle 1 button's digital signal attached + * to the given loop. + */ + public Trigger rightPaddle1(EventLoop loop) { + return m_hid.button(DualSenseEdgeController.Button.RIGHT_PADDLE_1.value, loop); + } + + /** + * Constructs a Trigger instance around the Left Paddle 1 button's digital signal. + * + * @return a Trigger instance representing the Left Paddle 1 button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #leftPaddle1(EventLoop) + */ + public Trigger leftPaddle1() { + return leftPaddle1(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Left Paddle 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Left Paddle 1 button's digital signal attached + * to the given loop. + */ + public Trigger leftPaddle1(EventLoop loop) { + return m_hid.button(DualSenseEdgeController.Button.LEFT_PADDLE_1.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #touchpad(EventLoop) + */ + public Trigger touchpad() { + return touchpad(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(DualSenseEdgeController.Button.TOUCHPAD.value, loop); + } + + /** + * Constructs a Trigger instance around the Left Function button's digital signal. + * + * @return a Trigger instance representing the Left Function button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #leftFunction(EventLoop) + */ + public Trigger leftFunction() { + return leftFunction(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Left Function button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Left Function button's digital signal attached + * to the given loop. + */ + public Trigger leftFunction(EventLoop loop) { + return m_hid.button(DualSenseEdgeController.Button.LEFT_FUNCTION.value, loop); + } + + /** + * Constructs a Trigger instance around the Right Function button's digital signal. + * + * @return a Trigger instance representing the Right Function button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #rightFunction(EventLoop) + */ + public Trigger rightFunction() { + return rightFunction(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Right Function button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Right Function button's digital signal attached + * to the given loop. + */ + public Trigger rightFunction(EventLoop loop) { + return m_hid.button(DualSenseEdgeController.Button.RIGHT_FUNCTION.value, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the L 2. 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 L 2 axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger L2(double threshold, EventLoop loop) { + return m_hid.axisGreaterThan( + DualSenseEdgeController.Axis.L2.value, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the L 2. 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 L 2 axis exceeds the provided + * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler event + * loop} on the scheduler passed to the controller's constructor, or the {@link + * Scheduler#getDefault default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger L2(double threshold) { + return L2(threshold, m_hid.getScheduler().getDefaultEventLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the L 2. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the L 2 axis exceeds 0.5, attached to + * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger L2() { + return L2(0.5); + } + + /** + * Constructs a Trigger instance around the axis value of the R 2. 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 R 2 axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger R2(double threshold, EventLoop loop) { + return m_hid.axisGreaterThan( + DualSenseEdgeController.Axis.R2.value, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the R 2. 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 R 2 axis exceeds the provided + * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler event + * loop} on the scheduler passed to the controller's constructor, or the {@link + * Scheduler#getDefault default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger R2(double threshold) { + return R2(threshold, m_hid.getScheduler().getDefaultEventLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the R 2. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the R 2 axis exceeds 0.5, attached to + * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger R2() { + return R2(0.5); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return m_controller.getRightX(); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return m_controller.getRightY(); + } + + /** + * Get the L 2 value of the controller. + * + * @return The axis value. + */ + public double getL2() { + return m_controller.getL2(); + } + + /** + * Get the R 2 value of the controller. + * + * @return The axis value. + */ + public double getR2() { + return m_controller.getR2(); + } +} diff --git a/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandDualShock4Controller.java b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandDualShock4Controller.java new file mode 100644 index 0000000000..e3464b5a55 --- /dev/null +++ b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandDualShock4Controller.java @@ -0,0 +1,613 @@ +// 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 ./commandsv3/generate_files.py. DO NOT MODIFY + +package org.wpilib.command3.button; + +import java.util.Objects; +import org.wpilib.command3.Scheduler; +import org.wpilib.command3.Trigger; +import org.wpilib.driverstation.DualShock4Controller; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link DualShock4Controller} with {@link Trigger} factories for command-based. + * + * @see DualShock4Controller + */ +@SuppressWarnings("MethodName") +public class CommandDualShock4Controller { + private final CommandGenericHID m_hid; + private final DualShock4Controller m_controller; + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandDualShock4Controller(int port) { + this(Scheduler.getDefault(), port); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param controller The DualShock4Controller object to use for this controller. + */ + public CommandDualShock4Controller(DualShock4Controller controller) { + this(Scheduler.getDefault(), controller); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandDualShock4Controller(Scheduler scheduler, int port) { + m_hid = CommandGenericHID.getCommandGenericHID(scheduler, port); + m_controller = new DualShock4Controller(m_hid.getHID()); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param controller The DualShock4Controller object to use for this controller. + */ + public CommandDualShock4Controller(Scheduler scheduler, DualShock4Controller controller) { + m_controller = + Objects.requireNonNull(controller, "Provided DualShock4Controller cannot be null"); + m_hid = new CommandGenericHID(scheduler, m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public DualShock4Controller getController() { + return m_controller; + } + + /** + * 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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #cross(EventLoop) + */ + public Trigger cross() { + return cross(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(DualShock4Controller.Button.CROSS.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #circle(EventLoop) + */ + public Trigger circle() { + return circle(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(DualShock4Controller.Button.CIRCLE.value, loop); + } + + /** + * 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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #square(EventLoop) + */ + public Trigger square() { + return square(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(DualShock4Controller.Button.SQUARE.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #triangle(EventLoop) + */ + public Trigger triangle() { + return triangle(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(DualShock4Controller.Button.TRIANGLE.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #share(EventLoop) + */ + public Trigger share() { + return share(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(DualShock4Controller.Button.SHARE.value, loop); + } + + /** + * Constructs a Trigger instance around the PS button's digital signal. + * + * @return a Trigger instance representing the PS button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #PS(EventLoop) + */ + public Trigger PS() { + return PS(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the PS button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the PS button's digital signal attached + * to the given loop. + */ + public Trigger PS(EventLoop loop) { + return m_hid.button(DualShock4Controller.Button.PS.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #options(EventLoop) + */ + public Trigger options() { + return options(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(DualShock4Controller.Button.OPTIONS.value, loop); + } + + /** + * Constructs a Trigger instance around the L 3 button's digital signal. + * + * @return a Trigger instance representing the L 3 button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #L3(EventLoop) + */ + public Trigger L3() { + return L3(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the L 3 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L 3 button's digital signal attached + * to the given loop. + */ + public Trigger L3(EventLoop loop) { + return m_hid.button(DualShock4Controller.Button.L3.value, loop); + } + + /** + * Constructs a Trigger instance around the R 3 button's digital signal. + * + * @return a Trigger instance representing the R 3 button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #R3(EventLoop) + */ + public Trigger R3() { + return R3(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the R 3 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R 3 button's digital signal attached + * to the given loop. + */ + public Trigger R3(EventLoop loop) { + return m_hid.button(DualShock4Controller.Button.R3.value, loop); + } + + /** + * Constructs a Trigger instance around the L 1 button's digital signal. + * + * @return a Trigger instance representing the L 1 button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #L1(EventLoop) + */ + public Trigger L1() { + return L1(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the L 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L 1 button's digital signal attached + * to the given loop. + */ + public Trigger L1(EventLoop loop) { + return m_hid.button(DualShock4Controller.Button.L1.value, loop); + } + + /** + * Constructs a Trigger instance around the R 1 button's digital signal. + * + * @return a Trigger instance representing the R 1 button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #R1(EventLoop) + */ + public Trigger R1() { + return R1(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the R 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R 1 button's digital signal attached + * to the given loop. + */ + public Trigger R1(EventLoop loop) { + return m_hid.button(DualShock4Controller.Button.R1.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return m_hid.button(DualShock4Controller.Button.DPAD_UP.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return m_hid.button(DualShock4Controller.Button.DPAD_DOWN.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return m_hid.button(DualShock4Controller.Button.DPAD_LEFT.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return m_hid.button(DualShock4Controller.Button.DPAD_RIGHT.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #touchpad(EventLoop) + */ + public Trigger touchpad() { + return touchpad(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(DualShock4Controller.Button.TOUCHPAD.value, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the L 2. 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 L 2 axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger L2(double threshold, EventLoop loop) { + return m_hid.axisGreaterThan( + DualShock4Controller.Axis.L2.value, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the L 2. 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 L 2 axis exceeds the provided + * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler event + * loop} on the scheduler passed to the controller's constructor, or the {@link + * Scheduler#getDefault default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger L2(double threshold) { + return L2(threshold, m_hid.getScheduler().getDefaultEventLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the L 2. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the L 2 axis exceeds 0.5, attached to + * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger L2() { + return L2(0.5); + } + + /** + * Constructs a Trigger instance around the axis value of the R 2. 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 R 2 axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger R2(double threshold, EventLoop loop) { + return m_hid.axisGreaterThan( + DualShock4Controller.Axis.R2.value, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the R 2. 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 R 2 axis exceeds the provided + * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler event + * loop} on the scheduler passed to the controller's constructor, or the {@link + * Scheduler#getDefault default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger R2(double threshold) { + return R2(threshold, m_hid.getScheduler().getDefaultEventLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the R 2. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the R 2 axis exceeds 0.5, attached to + * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger R2() { + return R2(0.5); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return m_controller.getRightX(); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return m_controller.getRightY(); + } + + /** + * Get the L 2 value of the controller. + * + * @return The axis value. + */ + public double getL2() { + return m_controller.getL2(); + } + + /** + * Get the R 2 value of the controller. + * + * @return The axis value. + */ + public double getR2() { + return m_controller.getR2(); + } +} diff --git a/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandGameCubeController.java b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandGameCubeController.java new file mode 100644 index 0000000000..c5b0e52571 --- /dev/null +++ b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandGameCubeController.java @@ -0,0 +1,517 @@ +// 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 ./commandsv3/generate_files.py. DO NOT MODIFY + +package org.wpilib.command3.button; + +import java.util.Objects; +import org.wpilib.command3.Scheduler; +import org.wpilib.command3.Trigger; +import org.wpilib.driverstation.GameCubeController; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link GameCubeController} with {@link Trigger} factories for command-based. + * + * @see GameCubeController + */ +@SuppressWarnings("MethodName") +public class CommandGameCubeController { + private final CommandGenericHID m_hid; + private final GameCubeController m_controller; + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandGameCubeController(int port) { + this(Scheduler.getDefault(), port); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param controller The GameCubeController object to use for this controller. + */ + public CommandGameCubeController(GameCubeController controller) { + this(Scheduler.getDefault(), controller); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandGameCubeController(Scheduler scheduler, int port) { + m_hid = CommandGenericHID.getCommandGenericHID(scheduler, port); + m_controller = new GameCubeController(m_hid.getHID()); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param controller The GameCubeController object to use for this controller. + */ + public CommandGameCubeController(Scheduler scheduler, GameCubeController controller) { + m_controller = + Objects.requireNonNull(controller, "Provided GameCubeController cannot be null"); + m_hid = new CommandGenericHID(scheduler, m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public GameCubeController getController() { + return m_controller; + } + + /** + * 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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #a(EventLoop) + */ + public Trigger a() { + return a(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(GameCubeController.Button.A.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #x(EventLoop) + */ + public Trigger x() { + return x(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(GameCubeController.Button.X.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #b(EventLoop) + */ + public Trigger b() { + return b(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(GameCubeController.Button.B.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #y(EventLoop) + */ + public Trigger y() { + return y(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(GameCubeController.Button.Y.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #start(EventLoop) + */ + public Trigger start() { + return start(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(GameCubeController.Button.START.value, loop); + } + + /** + * Constructs a Trigger instance around the Z button's digital signal. + * + * @return a Trigger instance representing the Z button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #Z(EventLoop) + */ + public Trigger Z() { + return Z(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Z button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Z button's digital signal attached + * to the given loop. + */ + public Trigger Z(EventLoop loop) { + return m_hid.button(GameCubeController.Button.Z.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return m_hid.button(GameCubeController.Button.DPAD_UP.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return m_hid.button(GameCubeController.Button.DPAD_DOWN.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return m_hid.button(GameCubeController.Button.DPAD_LEFT.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return m_hid.button(GameCubeController.Button.DPAD_RIGHT.value, loop); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @return a Trigger instance representing the L button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #L(EventLoop) + */ + public Trigger L() { + return L(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L button's digital signal attached + * to the given loop. + */ + public Trigger L(EventLoop loop) { + return m_hid.button(GameCubeController.Button.L.value, loop); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @return a Trigger instance representing the R button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #R(EventLoop) + */ + public Trigger R() { + return R(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R button's digital signal attached + * to the given loop. + */ + public Trigger R(EventLoop loop) { + return m_hid.button(GameCubeController.Button.R.value, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the L 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 L Trigger axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger LTrigger(double threshold, EventLoop loop) { + return m_hid.axisGreaterThan( + GameCubeController.Axis.L_TRIGGER.value, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the L 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 L Trigger axis exceeds the provided + * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler event + * loop} on the scheduler passed to the controller's constructor, or the {@link + * Scheduler#getDefault default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger LTrigger(double threshold) { + return LTrigger(threshold, m_hid.getScheduler().getDefaultEventLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the L 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 L Trigger axis exceeds 0.5, attached to + * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger LTrigger() { + return LTrigger(0.5); + } + + /** + * Constructs a Trigger instance around the axis value of the R 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 R Trigger axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger RTrigger(double threshold, EventLoop loop) { + return m_hid.axisGreaterThan( + GameCubeController.Axis.R_TRIGGER.value, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the R 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 R Trigger axis exceeds the provided + * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler event + * loop} on the scheduler passed to the controller's constructor, or the {@link + * Scheduler#getDefault default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger RTrigger(double threshold) { + return RTrigger(threshold, m_hid.getScheduler().getDefaultEventLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the R 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 R Trigger axis exceeds 0.5, attached to + * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger RTrigger() { + return RTrigger(0.5); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the C Stick X value of the controller. + * + * @return The axis value. + */ + public double getCStickX() { + return m_controller.getCStickX(); + } + + /** + * Get the C Stick Y value of the controller. + * + * @return The axis value. + */ + public double getCStickY() { + return m_controller.getCStickY(); + } + + /** + * Get the L Trigger value of the controller. + * + * @return The axis value. + */ + public double getLTrigger() { + return m_controller.getLTrigger(); + } + + /** + * Get the R Trigger value of the controller. + * + * @return The axis value. + */ + public double getRTrigger() { + return m_controller.getRTrigger(); + } +} diff --git a/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandLogitechF310Controller.java b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandLogitechF310Controller.java new file mode 100644 index 0000000000..7d29f38588 --- /dev/null +++ b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandLogitechF310Controller.java @@ -0,0 +1,589 @@ +// 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 ./commandsv3/generate_files.py. DO NOT MODIFY + +package org.wpilib.command3.button; + +import java.util.Objects; +import org.wpilib.command3.Scheduler; +import org.wpilib.command3.Trigger; +import org.wpilib.driverstation.LogitechF310Controller; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link LogitechF310Controller} with {@link Trigger} factories for command-based. + * + * @see LogitechF310Controller + */ +@SuppressWarnings("MethodName") +public class CommandLogitechF310Controller { + private final CommandGenericHID m_hid; + private final LogitechF310Controller m_controller; + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandLogitechF310Controller(int port) { + this(Scheduler.getDefault(), port); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param controller The LogitechF310Controller object to use for this controller. + */ + public CommandLogitechF310Controller(LogitechF310Controller controller) { + this(Scheduler.getDefault(), controller); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandLogitechF310Controller(Scheduler scheduler, int port) { + m_hid = CommandGenericHID.getCommandGenericHID(scheduler, port); + m_controller = new LogitechF310Controller(m_hid.getHID()); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param controller The LogitechF310Controller object to use for this controller. + */ + public CommandLogitechF310Controller(Scheduler scheduler, LogitechF310Controller controller) { + m_controller = + Objects.requireNonNull(controller, "Provided LogitechF310Controller cannot be null"); + m_hid = new CommandGenericHID(scheduler, m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public LogitechF310Controller getController() { + return m_controller; + } + + /** + * 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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #a(EventLoop) + */ + public Trigger a() { + return a(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(LogitechF310Controller.Button.A.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #b(EventLoop) + */ + public Trigger b() { + return b(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(LogitechF310Controller.Button.B.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #x(EventLoop) + */ + public Trigger x() { + return x(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(LogitechF310Controller.Button.X.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #y(EventLoop) + */ + public Trigger y() { + return y(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(LogitechF310Controller.Button.Y.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #back(EventLoop) + */ + public Trigger back() { + return back(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(LogitechF310Controller.Button.BACK.value, loop); + } + + /** + * Constructs a Trigger instance around the Logitech button's digital signal. + * + * @return a Trigger instance representing the Logitech button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #logitech(EventLoop) + */ + public Trigger logitech() { + return logitech(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Logitech button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Logitech button's digital signal attached + * to the given loop. + */ + public Trigger logitech(EventLoop loop) { + return m_hid.button(LogitechF310Controller.Button.LOGITECH.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #start(EventLoop) + */ + public Trigger start() { + return start(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(LogitechF310Controller.Button.START.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #leftStick(EventLoop) + */ + public Trigger leftStick() { + return leftStick(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(LogitechF310Controller.Button.LEFT_STICK.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #rightStick(EventLoop) + */ + public Trigger rightStick() { + return rightStick(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(LogitechF310Controller.Button.RIGHT_STICK.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #leftBumper(EventLoop) + */ + public Trigger leftBumper() { + return leftBumper(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(LogitechF310Controller.Button.LEFT_BUMPER.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #rightBumper(EventLoop) + */ + public Trigger rightBumper() { + return rightBumper(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(LogitechF310Controller.Button.RIGHT_BUMPER.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return m_hid.button(LogitechF310Controller.Button.DPAD_UP.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return m_hid.button(LogitechF310Controller.Button.DPAD_DOWN.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return m_hid.button(LogitechF310Controller.Button.DPAD_LEFT.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return m_hid.button(LogitechF310Controller.Button.DPAD_RIGHT.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 axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger leftTrigger(double threshold, EventLoop loop) { + return m_hid.axisGreaterThan( + LogitechF310Controller.Axis.LEFT_TRIGGER.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 axis exceeds the provided + * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler event + * loop} on the scheduler passed to the controller's constructor, or the {@link + * Scheduler#getDefault default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger leftTrigger(double threshold) { + return leftTrigger(threshold, m_hid.getScheduler().getDefaultEventLoop()); + } + + + /** + * 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 axis exceeds 0.5, attached to + * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + */ + 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 axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger rightTrigger(double threshold, EventLoop loop) { + return m_hid.axisGreaterThan( + LogitechF310Controller.Axis.RIGHT_TRIGGER.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 axis exceeds the provided + * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler event + * loop} on the scheduler passed to the controller's constructor, or the {@link + * Scheduler#getDefault default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger rightTrigger(double threshold) { + return rightTrigger(threshold, m_hid.getScheduler().getDefaultEventLoop()); + } + + + /** + * 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 axis exceeds 0.5, attached to + * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger rightTrigger() { + return rightTrigger(0.5); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return m_controller.getRightX(); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return m_controller.getRightY(); + } + + /** + * Get the Left Trigger value of the controller. + * + * @return The axis value. + */ + public double getLeftTrigger() { + return m_controller.getLeftTrigger(); + } + + /** + * Get the Right Trigger value of the controller. + * + * @return The axis value. + */ + public double getRightTrigger() { + return m_controller.getRightTrigger(); + } +} diff --git a/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandSteamController.java b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandSteamController.java new file mode 100644 index 0000000000..ab95ce327a --- /dev/null +++ b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandSteamController.java @@ -0,0 +1,853 @@ +// 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 ./commandsv3/generate_files.py. DO NOT MODIFY + +package org.wpilib.command3.button; + +import java.util.Objects; +import org.wpilib.command3.Scheduler; +import org.wpilib.command3.Trigger; +import org.wpilib.driverstation.SteamController; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link SteamController} with {@link Trigger} factories for command-based. + * + * @see SteamController + */ +@SuppressWarnings("MethodName") +public class CommandSteamController { + private final CommandGenericHID m_hid; + private final SteamController m_controller; + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandSteamController(int port) { + this(Scheduler.getDefault(), port); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param controller The SteamController object to use for this controller. + */ + public CommandSteamController(SteamController controller) { + this(Scheduler.getDefault(), controller); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandSteamController(Scheduler scheduler, int port) { + m_hid = CommandGenericHID.getCommandGenericHID(scheduler, port); + m_controller = new SteamController(m_hid.getHID()); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param controller The SteamController object to use for this controller. + */ + public CommandSteamController(Scheduler scheduler, SteamController controller) { + m_controller = + Objects.requireNonNull(controller, "Provided SteamController cannot be null"); + m_hid = new CommandGenericHID(scheduler, m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public SteamController getController() { + return m_controller; + } + + /** + * 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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #a(EventLoop) + */ + public Trigger a() { + return a(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(SteamController.Button.A.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #b(EventLoop) + */ + public Trigger b() { + return b(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(SteamController.Button.B.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #x(EventLoop) + */ + public Trigger x() { + return x(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(SteamController.Button.X.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #y(EventLoop) + */ + public Trigger y() { + return y(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(SteamController.Button.Y.value, loop); + } + + /** + * Constructs a Trigger instance around the Menu button's digital signal. + * + * @return a Trigger instance representing the Menu button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #menu(EventLoop) + */ + public Trigger menu() { + return menu(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Menu button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Menu button's digital signal attached + * to the given loop. + */ + public Trigger menu(EventLoop loop) { + return m_hid.button(SteamController.Button.MENU.value, loop); + } + + /** + * Constructs a Trigger instance around the Steam button's digital signal. + * + * @return a Trigger instance representing the Steam button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #steam(EventLoop) + */ + public Trigger steam() { + return steam(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Steam button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Steam button's digital signal attached + * to the given loop. + */ + public Trigger steam(EventLoop loop) { + return m_hid.button(SteamController.Button.STEAM.value, loop); + } + + /** + * Constructs a Trigger instance around the View button's digital signal. + * + * @return a Trigger instance representing the View button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #view(EventLoop) + */ + public Trigger view() { + return view(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the View button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the View button's digital signal attached + * to the given loop. + */ + public Trigger view(EventLoop loop) { + return m_hid.button(SteamController.Button.VIEW.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #leftStick(EventLoop) + */ + public Trigger leftStick() { + return leftStick(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(SteamController.Button.LEFT_STICK.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #rightStick(EventLoop) + */ + public Trigger rightStick() { + return rightStick(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(SteamController.Button.RIGHT_STICK.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #leftBumper(EventLoop) + */ + public Trigger leftBumper() { + return leftBumper(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(SteamController.Button.LEFT_BUMPER.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #rightBumper(EventLoop) + */ + public Trigger rightBumper() { + return rightBumper(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(SteamController.Button.RIGHT_BUMPER.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return m_hid.button(SteamController.Button.DPAD_UP.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return m_hid.button(SteamController.Button.DPAD_DOWN.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return m_hid.button(SteamController.Button.DPAD_LEFT.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return m_hid.button(SteamController.Button.DPAD_RIGHT.value, loop); + } + + /** + * Constructs a Trigger instance around the QAM button's digital signal. + * + * @return a Trigger instance representing the QAM button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #QAM(EventLoop) + */ + public Trigger QAM() { + return QAM(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the QAM button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the QAM button's digital signal attached + * to the given loop. + */ + public Trigger QAM(EventLoop loop) { + return m_hid.button(SteamController.Button.QAM.value, loop); + } + + /** + * Constructs a Trigger instance around the Right Paddle 1 button's digital signal. + * + * @return a Trigger instance representing the Right Paddle 1 button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #rightPaddle1(EventLoop) + */ + public Trigger rightPaddle1() { + return rightPaddle1(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Right Paddle 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Right Paddle 1 button's digital signal attached + * to the given loop. + */ + public Trigger rightPaddle1(EventLoop loop) { + return m_hid.button(SteamController.Button.RIGHT_PADDLE_1.value, loop); + } + + /** + * Constructs a Trigger instance around the Left Paddle 1 button's digital signal. + * + * @return a Trigger instance representing the Left Paddle 1 button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #leftPaddle1(EventLoop) + */ + public Trigger leftPaddle1() { + return leftPaddle1(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Left Paddle 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Left Paddle 1 button's digital signal attached + * to the given loop. + */ + public Trigger leftPaddle1(EventLoop loop) { + return m_hid.button(SteamController.Button.LEFT_PADDLE_1.value, loop); + } + + /** + * Constructs a Trigger instance around the Right Paddle 2 button's digital signal. + * + * @return a Trigger instance representing the Right Paddle 2 button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #rightPaddle2(EventLoop) + */ + public Trigger rightPaddle2() { + return rightPaddle2(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Right Paddle 2 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Right Paddle 2 button's digital signal attached + * to the given loop. + */ + public Trigger rightPaddle2(EventLoop loop) { + return m_hid.button(SteamController.Button.RIGHT_PADDLE_2.value, loop); + } + + /** + * Constructs a Trigger instance around the Left Paddle 2 button's digital signal. + * + * @return a Trigger instance representing the Left Paddle 2 button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #leftPaddle2(EventLoop) + */ + public Trigger leftPaddle2() { + return leftPaddle2(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Left Paddle 2 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Left Paddle 2 button's digital signal attached + * to the given loop. + */ + public Trigger leftPaddle2(EventLoop loop) { + return m_hid.button(SteamController.Button.LEFT_PADDLE_2.value, loop); + } + + /** + * Constructs a Trigger instance around the Left Touchpad button's digital signal. + * + * @return a Trigger instance representing the Left Touchpad button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #leftTouchpad(EventLoop) + */ + public Trigger leftTouchpad() { + return leftTouchpad(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Left Touchpad button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Left Touchpad button's digital signal attached + * to the given loop. + */ + public Trigger leftTouchpad(EventLoop loop) { + return m_hid.button(SteamController.Button.LEFT_TOUCHPAD.value, loop); + } + + /** + * Constructs a Trigger instance around the Right Touchpad button's digital signal. + * + * @return a Trigger instance representing the Right Touchpad button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #rightTouchpad(EventLoop) + */ + public Trigger rightTouchpad() { + return rightTouchpad(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Right Touchpad button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Right Touchpad button's digital signal attached + * to the given loop. + */ + public Trigger rightTouchpad(EventLoop loop) { + return m_hid.button(SteamController.Button.RIGHT_TOUCHPAD.value, loop); + } + + /** + * Constructs a Trigger instance around the Left Stick Touch button's digital signal. + * + * @return a Trigger instance representing the Left Stick Touch button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #leftStickTouch(EventLoop) + */ + public Trigger leftStickTouch() { + return leftStickTouch(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Left Stick Touch button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Left Stick Touch button's digital signal attached + * to the given loop. + */ + public Trigger leftStickTouch(EventLoop loop) { + return m_hid.button(SteamController.Button.LEFT_STICK_TOUCH.value, loop); + } + + /** + * Constructs a Trigger instance around the Right Stick Touch button's digital signal. + * + * @return a Trigger instance representing the Right Stick Touch button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #rightStickTouch(EventLoop) + */ + public Trigger rightStickTouch() { + return rightStickTouch(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Right Stick Touch button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Right Stick Touch button's digital signal attached + * to the given loop. + */ + public Trigger rightStickTouch(EventLoop loop) { + return m_hid.button(SteamController.Button.RIGHT_STICK_TOUCH.value, loop); + } + + /** + * Constructs a Trigger instance around the Left Grip Touch button's digital signal. + * + * @return a Trigger instance representing the Left Grip Touch button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #leftGripTouch(EventLoop) + */ + public Trigger leftGripTouch() { + return leftGripTouch(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Left Grip Touch button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Left Grip Touch button's digital signal attached + * to the given loop. + */ + public Trigger leftGripTouch(EventLoop loop) { + return m_hid.button(SteamController.Button.LEFT_GRIP_TOUCH.value, loop); + } + + /** + * Constructs a Trigger instance around the Right Grip Touch button's digital signal. + * + * @return a Trigger instance representing the Right Grip Touch button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #rightGripTouch(EventLoop) + */ + public Trigger rightGripTouch() { + return rightGripTouch(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Right Grip Touch button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Right Grip Touch button's digital signal attached + * to the given loop. + */ + public Trigger rightGripTouch(EventLoop loop) { + return m_hid.button(SteamController.Button.RIGHT_GRIP_TOUCH.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 axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger leftTrigger(double threshold, EventLoop loop) { + return m_hid.axisGreaterThan( + SteamController.Axis.LEFT_TRIGGER.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 axis exceeds the provided + * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler event + * loop} on the scheduler passed to the controller's constructor, or the {@link + * Scheduler#getDefault default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger leftTrigger(double threshold) { + return leftTrigger(threshold, m_hid.getScheduler().getDefaultEventLoop()); + } + + + /** + * 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 axis exceeds 0.5, attached to + * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + */ + 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 axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger rightTrigger(double threshold, EventLoop loop) { + return m_hid.axisGreaterThan( + SteamController.Axis.RIGHT_TRIGGER.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 axis exceeds the provided + * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler event + * loop} on the scheduler passed to the controller's constructor, or the {@link + * Scheduler#getDefault default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger rightTrigger(double threshold) { + return rightTrigger(threshold, m_hid.getScheduler().getDefaultEventLoop()); + } + + + /** + * 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 axis exceeds 0.5, attached to + * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger rightTrigger() { + return rightTrigger(0.5); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return m_controller.getRightX(); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return m_controller.getRightY(); + } + + /** + * Get the Left Trigger value of the controller. + * + * @return The axis value. + */ + public double getLeftTrigger() { + return m_controller.getLeftTrigger(); + } + + /** + * Get the Right Trigger value of the controller. + * + * @return The axis value. + */ + public double getRightTrigger() { + return m_controller.getRightTrigger(); + } +} diff --git a/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandSwitch2GCController.java b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandSwitch2GCController.java new file mode 100644 index 0000000000..f543914528 --- /dev/null +++ b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandSwitch2GCController.java @@ -0,0 +1,613 @@ +// 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 ./commandsv3/generate_files.py. DO NOT MODIFY + +package org.wpilib.command3.button; + +import java.util.Objects; +import org.wpilib.command3.Scheduler; +import org.wpilib.command3.Trigger; +import org.wpilib.driverstation.Switch2GCController; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link Switch2GCController} with {@link Trigger} factories for command-based. + * + * @see Switch2GCController + */ +@SuppressWarnings("MethodName") +public class CommandSwitch2GCController { + private final CommandGenericHID m_hid; + private final Switch2GCController m_controller; + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandSwitch2GCController(int port) { + this(Scheduler.getDefault(), port); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param controller The Switch2GCController object to use for this controller. + */ + public CommandSwitch2GCController(Switch2GCController controller) { + this(Scheduler.getDefault(), controller); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandSwitch2GCController(Scheduler scheduler, int port) { + m_hid = CommandGenericHID.getCommandGenericHID(scheduler, port); + m_controller = new Switch2GCController(m_hid.getHID()); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param controller The Switch2GCController object to use for this controller. + */ + public CommandSwitch2GCController(Scheduler scheduler, Switch2GCController controller) { + m_controller = + Objects.requireNonNull(controller, "Provided Switch2GCController cannot be null"); + m_hid = new CommandGenericHID(scheduler, m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public Switch2GCController getController() { + return m_controller; + } + + /** + * 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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #a(EventLoop) + */ + public Trigger a() { + return a(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(Switch2GCController.Button.A.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #x(EventLoop) + */ + public Trigger x() { + return x(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(Switch2GCController.Button.X.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #b(EventLoop) + */ + public Trigger b() { + return b(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(Switch2GCController.Button.B.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #y(EventLoop) + */ + public Trigger y() { + return y(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(Switch2GCController.Button.Y.value, loop); + } + + /** + * Constructs a Trigger instance around the Home button's digital signal. + * + * @return a Trigger instance representing the Home button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #home(EventLoop) + */ + public Trigger home() { + return home(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Home button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Home button's digital signal attached + * to the given loop. + */ + public Trigger home(EventLoop loop) { + return m_hid.button(Switch2GCController.Button.HOME.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #start(EventLoop) + */ + public Trigger start() { + return start(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(Switch2GCController.Button.START.value, loop); + } + + /** + * Constructs a Trigger instance around the ZL button's digital signal. + * + * @return a Trigger instance representing the ZL button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #ZL(EventLoop) + */ + public Trigger ZL() { + return ZL(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the ZL button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the ZL button's digital signal attached + * to the given loop. + */ + public Trigger ZL(EventLoop loop) { + return m_hid.button(Switch2GCController.Button.ZL.value, loop); + } + + /** + * Constructs a Trigger instance around the Z button's digital signal. + * + * @return a Trigger instance representing the Z button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #Z(EventLoop) + */ + public Trigger Z() { + return Z(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Z button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Z button's digital signal attached + * to the given loop. + */ + public Trigger Z(EventLoop loop) { + return m_hid.button(Switch2GCController.Button.Z.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return m_hid.button(Switch2GCController.Button.DPAD_UP.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return m_hid.button(Switch2GCController.Button.DPAD_DOWN.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return m_hid.button(Switch2GCController.Button.DPAD_LEFT.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return m_hid.button(Switch2GCController.Button.DPAD_RIGHT.value, loop); + } + + /** + * Constructs a Trigger instance around the Capture button's digital signal. + * + * @return a Trigger instance representing the Capture button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #capture(EventLoop) + */ + public Trigger capture() { + return capture(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Capture button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Capture button's digital signal attached + * to the given loop. + */ + public Trigger capture(EventLoop loop) { + return m_hid.button(Switch2GCController.Button.CAPTURE.value, loop); + } + + /** + * Constructs a Trigger instance around the C button's digital signal. + * + * @return a Trigger instance representing the C button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #C(EventLoop) + */ + public Trigger C() { + return C(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the C button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the C button's digital signal attached + * to the given loop. + */ + public Trigger C(EventLoop loop) { + return m_hid.button(Switch2GCController.Button.C.value, loop); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @return a Trigger instance representing the L button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #L(EventLoop) + */ + public Trigger L() { + return L(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L button's digital signal attached + * to the given loop. + */ + public Trigger L(EventLoop loop) { + return m_hid.button(Switch2GCController.Button.L.value, loop); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @return a Trigger instance representing the R button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #R(EventLoop) + */ + public Trigger R() { + return R(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R button's digital signal attached + * to the given loop. + */ + public Trigger R(EventLoop loop) { + return m_hid.button(Switch2GCController.Button.R.value, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the L 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 L Trigger axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger LTrigger(double threshold, EventLoop loop) { + return m_hid.axisGreaterThan( + Switch2GCController.Axis.L_TRIGGER.value, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the L 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 L Trigger axis exceeds the provided + * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler event + * loop} on the scheduler passed to the controller's constructor, or the {@link + * Scheduler#getDefault default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger LTrigger(double threshold) { + return LTrigger(threshold, m_hid.getScheduler().getDefaultEventLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the L 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 L Trigger axis exceeds 0.5, attached to + * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger LTrigger() { + return LTrigger(0.5); + } + + /** + * Constructs a Trigger instance around the axis value of the R 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 R Trigger axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger RTrigger(double threshold, EventLoop loop) { + return m_hid.axisGreaterThan( + Switch2GCController.Axis.R_TRIGGER.value, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the R 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 R Trigger axis exceeds the provided + * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler event + * loop} on the scheduler passed to the controller's constructor, or the {@link + * Scheduler#getDefault default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger RTrigger(double threshold) { + return RTrigger(threshold, m_hid.getScheduler().getDefaultEventLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the R 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 R Trigger axis exceeds 0.5, attached to + * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger RTrigger() { + return RTrigger(0.5); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the C Stick X value of the controller. + * + * @return The axis value. + */ + public double getCStickX() { + return m_controller.getCStickX(); + } + + /** + * Get the C Stick Y value of the controller. + * + * @return The axis value. + */ + public double getCStickY() { + return m_controller.getCStickY(); + } + + /** + * Get the L Trigger value of the controller. + * + * @return The axis value. + */ + public double getLTrigger() { + return m_controller.getLTrigger(); + } + + /** + * Get the R Trigger value of the controller. + * + * @return The axis value. + */ + public double getRTrigger() { + return m_controller.getRTrigger(); + } +} diff --git a/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandSwitch2ProController.java b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandSwitch2ProController.java new file mode 100644 index 0000000000..7bd9c1d4bb --- /dev/null +++ b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandSwitch2ProController.java @@ -0,0 +1,685 @@ +// 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 ./commandsv3/generate_files.py. DO NOT MODIFY + +package org.wpilib.command3.button; + +import java.util.Objects; +import org.wpilib.command3.Scheduler; +import org.wpilib.command3.Trigger; +import org.wpilib.driverstation.Switch2ProController; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link Switch2ProController} with {@link Trigger} factories for command-based. + * + * @see Switch2ProController + */ +@SuppressWarnings("MethodName") +public class CommandSwitch2ProController { + private final CommandGenericHID m_hid; + private final Switch2ProController m_controller; + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandSwitch2ProController(int port) { + this(Scheduler.getDefault(), port); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param controller The Switch2ProController object to use for this controller. + */ + public CommandSwitch2ProController(Switch2ProController controller) { + this(Scheduler.getDefault(), controller); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandSwitch2ProController(Scheduler scheduler, int port) { + m_hid = CommandGenericHID.getCommandGenericHID(scheduler, port); + m_controller = new Switch2ProController(m_hid.getHID()); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param controller The Switch2ProController object to use for this controller. + */ + public CommandSwitch2ProController(Scheduler scheduler, Switch2ProController controller) { + m_controller = + Objects.requireNonNull(controller, "Provided Switch2ProController cannot be null"); + m_hid = new CommandGenericHID(scheduler, m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public Switch2ProController getController() { + return m_controller; + } + + /** + * 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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #b(EventLoop) + */ + public Trigger b() { + return b(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(Switch2ProController.Button.B.value, loop); + } + + /** + * 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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #a(EventLoop) + */ + public Trigger a() { + return a(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(Switch2ProController.Button.A.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #y(EventLoop) + */ + public Trigger y() { + return y(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(Switch2ProController.Button.Y.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #x(EventLoop) + */ + public Trigger x() { + return x(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(Switch2ProController.Button.X.value, loop); + } + + /** + * Constructs a Trigger instance around the Minus button's digital signal. + * + * @return a Trigger instance representing the Minus button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #minus(EventLoop) + */ + public Trigger minus() { + return minus(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Minus button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Minus button's digital signal attached + * to the given loop. + */ + public Trigger minus(EventLoop loop) { + return m_hid.button(Switch2ProController.Button.MINUS.value, loop); + } + + /** + * Constructs a Trigger instance around the Home button's digital signal. + * + * @return a Trigger instance representing the Home button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #home(EventLoop) + */ + public Trigger home() { + return home(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Home button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Home button's digital signal attached + * to the given loop. + */ + public Trigger home(EventLoop loop) { + return m_hid.button(Switch2ProController.Button.HOME.value, loop); + } + + /** + * Constructs a Trigger instance around the Plus button's digital signal. + * + * @return a Trigger instance representing the Plus button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #plus(EventLoop) + */ + public Trigger plus() { + return plus(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Plus button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Plus button's digital signal attached + * to the given loop. + */ + public Trigger plus(EventLoop loop) { + return m_hid.button(Switch2ProController.Button.PLUS.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #leftStick(EventLoop) + */ + public Trigger leftStick() { + return leftStick(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(Switch2ProController.Button.LEFT_STICK.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #rightStick(EventLoop) + */ + public Trigger rightStick() { + return rightStick(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(Switch2ProController.Button.RIGHT_STICK.value, loop); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @return a Trigger instance representing the L button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #L(EventLoop) + */ + public Trigger L() { + return L(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L button's digital signal attached + * to the given loop. + */ + public Trigger L(EventLoop loop) { + return m_hid.button(Switch2ProController.Button.L.value, loop); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @return a Trigger instance representing the R button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #R(EventLoop) + */ + public Trigger R() { + return R(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R button's digital signal attached + * to the given loop. + */ + public Trigger R(EventLoop loop) { + return m_hid.button(Switch2ProController.Button.R.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return m_hid.button(Switch2ProController.Button.DPAD_UP.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return m_hid.button(Switch2ProController.Button.DPAD_DOWN.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return m_hid.button(Switch2ProController.Button.DPAD_LEFT.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return m_hid.button(Switch2ProController.Button.DPAD_RIGHT.value, loop); + } + + /** + * Constructs a Trigger instance around the Capture button's digital signal. + * + * @return a Trigger instance representing the Capture button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #capture(EventLoop) + */ + public Trigger capture() { + return capture(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Capture button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Capture button's digital signal attached + * to the given loop. + */ + public Trigger capture(EventLoop loop) { + return m_hid.button(Switch2ProController.Button.CAPTURE.value, loop); + } + + /** + * Constructs a Trigger instance around the GR button's digital signal. + * + * @return a Trigger instance representing the GR button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #GR(EventLoop) + */ + public Trigger GR() { + return GR(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the GR button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the GR button's digital signal attached + * to the given loop. + */ + public Trigger GR(EventLoop loop) { + return m_hid.button(Switch2ProController.Button.GR.value, loop); + } + + /** + * Constructs a Trigger instance around the GL button's digital signal. + * + * @return a Trigger instance representing the GL button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #GL(EventLoop) + */ + public Trigger GL() { + return GL(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the GL button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the GL button's digital signal attached + * to the given loop. + */ + public Trigger GL(EventLoop loop) { + return m_hid.button(Switch2ProController.Button.GL.value, loop); + } + + /** + * Constructs a Trigger instance around the C button's digital signal. + * + * @return a Trigger instance representing the C button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #C(EventLoop) + */ + public Trigger C() { + return C(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the C button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the C button's digital signal attached + * to the given loop. + */ + public Trigger C(EventLoop loop) { + return m_hid.button(Switch2ProController.Button.C.value, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the ZL. 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 ZL axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger ZL(double threshold, EventLoop loop) { + return m_hid.axisGreaterThan( + Switch2ProController.Axis.ZL.value, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the ZL. 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 ZL axis exceeds the provided + * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler event + * loop} on the scheduler passed to the controller's constructor, or the {@link + * Scheduler#getDefault default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger ZL(double threshold) { + return ZL(threshold, m_hid.getScheduler().getDefaultEventLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the ZL. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the ZL axis exceeds 0.5, attached to + * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger ZL() { + return ZL(0.5); + } + + /** + * Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger ZR(double threshold, EventLoop loop) { + return m_hid.axisGreaterThan( + Switch2ProController.Axis.ZR.value, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided + * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler event + * loop} on the scheduler passed to the controller's constructor, or the {@link + * Scheduler#getDefault default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger ZR(double threshold) { + return ZR(threshold, m_hid.getScheduler().getDefaultEventLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the ZR. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the ZR axis exceeds 0.5, attached to + * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger ZR() { + return ZR(0.5); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return m_controller.getRightX(); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return m_controller.getRightY(); + } + + /** + * Get the ZL value of the controller. + * + * @return The axis value. + */ + public double getZL() { + return m_controller.getZL(); + } + + /** + * Get the ZR value of the controller. + * + * @return The axis value. + */ + public double getZR() { + return m_controller.getZR(); + } +} diff --git a/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandSwitchN64Controller.java b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandSwitchN64Controller.java new file mode 100644 index 0000000000..28be9e6c49 --- /dev/null +++ b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandSwitchN64Controller.java @@ -0,0 +1,527 @@ +// 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 ./commandsv3/generate_files.py. DO NOT MODIFY + +package org.wpilib.command3.button; + +import java.util.Objects; +import org.wpilib.command3.Scheduler; +import org.wpilib.command3.Trigger; +import org.wpilib.driverstation.SwitchN64Controller; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link SwitchN64Controller} with {@link Trigger} factories for command-based. + * + * @see SwitchN64Controller + */ +@SuppressWarnings("MethodName") +public class CommandSwitchN64Controller { + private final CommandGenericHID m_hid; + private final SwitchN64Controller m_controller; + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandSwitchN64Controller(int port) { + this(Scheduler.getDefault(), port); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param controller The SwitchN64Controller object to use for this controller. + */ + public CommandSwitchN64Controller(SwitchN64Controller controller) { + this(Scheduler.getDefault(), controller); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandSwitchN64Controller(Scheduler scheduler, int port) { + m_hid = CommandGenericHID.getCommandGenericHID(scheduler, port); + m_controller = new SwitchN64Controller(m_hid.getHID()); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param controller The SwitchN64Controller object to use for this controller. + */ + public CommandSwitchN64Controller(Scheduler scheduler, SwitchN64Controller controller) { + m_controller = + Objects.requireNonNull(controller, "Provided SwitchN64Controller cannot be null"); + m_hid = new CommandGenericHID(scheduler, m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public SwitchN64Controller getController() { + return m_controller; + } + + /** + * 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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #a(EventLoop) + */ + public Trigger a() { + return a(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(SwitchN64Controller.Button.A.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #b(EventLoop) + */ + public Trigger b() { + return b(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(SwitchN64Controller.Button.B.value, loop); + } + + /** + * Constructs a Trigger instance around the C Left button's digital signal. + * + * @return a Trigger instance representing the C Left button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #CLeft(EventLoop) + */ + public Trigger CLeft() { + return CLeft(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the C Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the C Left button's digital signal attached + * to the given loop. + */ + public Trigger CLeft(EventLoop loop) { + return m_hid.button(SwitchN64Controller.Button.C_LEFT.value, loop); + } + + /** + * Constructs a Trigger instance around the C Up button's digital signal. + * + * @return a Trigger instance representing the C Up button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #CUp(EventLoop) + */ + public Trigger CUp() { + return CUp(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the C Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the C Up button's digital signal attached + * to the given loop. + */ + public Trigger CUp(EventLoop loop) { + return m_hid.button(SwitchN64Controller.Button.C_UP.value, loop); + } + + /** + * Constructs a Trigger instance around the Capture button's digital signal. + * + * @return a Trigger instance representing the Capture button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #capture(EventLoop) + */ + public Trigger capture() { + return capture(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Capture button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Capture button's digital signal attached + * to the given loop. + */ + public Trigger capture(EventLoop loop) { + return m_hid.button(SwitchN64Controller.Button.CAPTURE.value, loop); + } + + /** + * Constructs a Trigger instance around the Home button's digital signal. + * + * @return a Trigger instance representing the Home button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #home(EventLoop) + */ + public Trigger home() { + return home(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Home button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Home button's digital signal attached + * to the given loop. + */ + public Trigger home(EventLoop loop) { + return m_hid.button(SwitchN64Controller.Button.HOME.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #start(EventLoop) + */ + public Trigger start() { + return start(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(SwitchN64Controller.Button.START.value, loop); + } + + /** + * Constructs a Trigger instance around the C Down button's digital signal. + * + * @return a Trigger instance representing the C Down button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #CDown(EventLoop) + */ + public Trigger CDown() { + return CDown(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the C Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the C Down button's digital signal attached + * to the given loop. + */ + public Trigger CDown(EventLoop loop) { + return m_hid.button(SwitchN64Controller.Button.C_DOWN.value, loop); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @return a Trigger instance representing the L button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #L(EventLoop) + */ + public Trigger L() { + return L(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L button's digital signal attached + * to the given loop. + */ + public Trigger L(EventLoop loop) { + return m_hid.button(SwitchN64Controller.Button.L.value, loop); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @return a Trigger instance representing the R button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #R(EventLoop) + */ + public Trigger R() { + return R(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R button's digital signal attached + * to the given loop. + */ + public Trigger R(EventLoop loop) { + return m_hid.button(SwitchN64Controller.Button.R.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return m_hid.button(SwitchN64Controller.Button.DPAD_UP.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return m_hid.button(SwitchN64Controller.Button.DPAD_DOWN.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return m_hid.button(SwitchN64Controller.Button.DPAD_LEFT.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return m_hid.button(SwitchN64Controller.Button.DPAD_RIGHT.value, loop); + } + + /** + * Constructs a Trigger instance around the C Right button's digital signal. + * + * @return a Trigger instance representing the C Right button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #CRight(EventLoop) + */ + public Trigger CRight() { + return CRight(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the C Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the C Right button's digital signal attached + * to the given loop. + */ + public Trigger CRight(EventLoop loop) { + return m_hid.button(SwitchN64Controller.Button.C_RIGHT.value, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger ZR(double threshold, EventLoop loop) { + return m_hid.axisGreaterThan( + SwitchN64Controller.Axis.ZR.value, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided + * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler event + * loop} on the scheduler passed to the controller's constructor, or the {@link + * Scheduler#getDefault default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger ZR(double threshold) { + return ZR(threshold, m_hid.getScheduler().getDefaultEventLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the ZR. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the ZR axis exceeds 0.5, attached to + * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger ZR() { + return ZR(0.5); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the Z Axis value of the controller. + * + * @return The axis value. + */ + public double getZAxis() { + return m_controller.getZAxis(); + } + + /** + * Get the ZR value of the controller. + * + * @return The axis value. + */ + public double getZR() { + return m_controller.getZR(); + } +} diff --git a/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandSwitchProController.java b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandSwitchProController.java new file mode 100644 index 0000000000..ecd2ba0afa --- /dev/null +++ b/commandsv3/src/generated/main/java/org/wpilib/command3/button/CommandSwitchProController.java @@ -0,0 +1,613 @@ +// 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 ./commandsv3/generate_files.py. DO NOT MODIFY + +package org.wpilib.command3.button; + +import java.util.Objects; +import org.wpilib.command3.Scheduler; +import org.wpilib.command3.Trigger; +import org.wpilib.driverstation.SwitchProController; +import org.wpilib.event.EventLoop; + +/** + * A version of {@link SwitchProController} with {@link Trigger} factories for command-based. + * + * @see SwitchProController + */ +@SuppressWarnings("MethodName") +public class CommandSwitchProController { + private final CommandGenericHID m_hid; + private final SwitchProController m_controller; + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandSwitchProController(int port) { + this(Scheduler.getDefault(), port); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. + * + * @param controller The SwitchProController object to use for this controller. + */ + public CommandSwitchProController(SwitchProController controller) { + this(Scheduler.getDefault(), controller); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandSwitchProController(Scheduler scheduler, int port) { + m_hid = CommandGenericHID.getCommandGenericHID(scheduler, port); + m_controller = new SwitchProController(m_hid.getHID()); + } + + /** + * Construct an instance of a controller. Commands bound to buttons on the controller will be + * scheduled on the given scheduler using its default event loop. + * + * @param scheduler The scheduler that should execute the triggered commands. + * @param controller The SwitchProController object to use for this controller. + */ + public CommandSwitchProController(Scheduler scheduler, SwitchProController controller) { + m_controller = + Objects.requireNonNull(controller, "Provided SwitchProController cannot be null"); + m_hid = new CommandGenericHID(scheduler, m_controller.getHID()); + } + + /** + * Get the underlying CommandGenericHID object. + * + * @return the wrapped CommandGenericHID object + */ + public CommandGenericHID getHID() { + return m_hid; + } + + /** + * Get the wrapped controller object. + * + * @return the wrapped controller object + */ + public SwitchProController getController() { + return m_controller; + } + + /** + * 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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #b(EventLoop) + */ + public Trigger b() { + return b(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(SwitchProController.Button.B.value, loop); + } + + /** + * 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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #a(EventLoop) + */ + public Trigger a() { + return a(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(SwitchProController.Button.A.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #y(EventLoop) + */ + public Trigger y() { + return y(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(SwitchProController.Button.Y.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #x(EventLoop) + */ + public Trigger x() { + return x(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(SwitchProController.Button.X.value, loop); + } + + /** + * Constructs a Trigger instance around the Minus button's digital signal. + * + * @return a Trigger instance representing the Minus button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #minus(EventLoop) + */ + public Trigger minus() { + return minus(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Minus button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Minus button's digital signal attached + * to the given loop. + */ + public Trigger minus(EventLoop loop) { + return m_hid.button(SwitchProController.Button.MINUS.value, loop); + } + + /** + * Constructs a Trigger instance around the Home button's digital signal. + * + * @return a Trigger instance representing the Home button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #home(EventLoop) + */ + public Trigger home() { + return home(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Home button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Home button's digital signal attached + * to the given loop. + */ + public Trigger home(EventLoop loop) { + return m_hid.button(SwitchProController.Button.HOME.value, loop); + } + + /** + * Constructs a Trigger instance around the Plus button's digital signal. + * + * @return a Trigger instance representing the Plus button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #plus(EventLoop) + */ + public Trigger plus() { + return plus(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Plus button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Plus button's digital signal attached + * to the given loop. + */ + public Trigger plus(EventLoop loop) { + return m_hid.button(SwitchProController.Button.PLUS.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #leftStick(EventLoop) + */ + public Trigger leftStick() { + return leftStick(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(SwitchProController.Button.LEFT_STICK.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 Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #rightStick(EventLoop) + */ + public Trigger rightStick() { + return rightStick(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * 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 m_hid.button(SwitchProController.Button.RIGHT_STICK.value, loop); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @return a Trigger instance representing the L button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #L(EventLoop) + */ + public Trigger L() { + return L(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the L button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L button's digital signal attached + * to the given loop. + */ + public Trigger L(EventLoop loop) { + return m_hid.button(SwitchProController.Button.L.value, loop); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @return a Trigger instance representing the R button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #R(EventLoop) + */ + public Trigger R() { + return R(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the R button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R button's digital signal attached + * to the given loop. + */ + public Trigger R(EventLoop loop) { + return m_hid.button(SwitchProController.Button.R.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadUp(EventLoop) + */ + public Trigger dpadUp() { + return dpadUp(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Up button's digital signal attached + * to the given loop. + */ + public Trigger dpadUp(EventLoop loop) { + return m_hid.button(SwitchProController.Button.DPAD_UP.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadDown(EventLoop) + */ + public Trigger dpadDown() { + return dpadDown(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Down button's digital signal attached + * to the given loop. + */ + public Trigger dpadDown(EventLoop loop) { + return m_hid.button(SwitchProController.Button.DPAD_DOWN.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadLeft(EventLoop) + */ + public Trigger dpadLeft() { + return dpadLeft(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Left button's digital signal attached + * to the given loop. + */ + public Trigger dpadLeft(EventLoop loop) { + return m_hid.button(SwitchProController.Button.DPAD_LEFT.value, loop); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #dpadRight(EventLoop) + */ + public Trigger dpadRight() { + return dpadRight(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Dpad Right button's digital signal attached + * to the given loop. + */ + public Trigger dpadRight(EventLoop loop) { + return m_hid.button(SwitchProController.Button.DPAD_RIGHT.value, loop); + } + + /** + * Constructs a Trigger instance around the Capture button's digital signal. + * + * @return a Trigger instance representing the Capture button's digital signal attached + * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + * @see #capture(EventLoop) + */ + public Trigger capture() { + return capture(m_hid.getScheduler().getDefaultEventLoop()); + } + + /** + * Constructs a Trigger instance around the Capture button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the Capture button's digital signal attached + * to the given loop. + */ + public Trigger capture(EventLoop loop) { + return m_hid.button(SwitchProController.Button.CAPTURE.value, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the ZL. 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 ZL axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger ZL(double threshold, EventLoop loop) { + return m_hid.axisGreaterThan( + SwitchProController.Axis.ZL.value, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the ZL. 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 ZL axis exceeds the provided + * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler event + * loop} on the scheduler passed to the controller's constructor, or the {@link + * Scheduler#getDefault default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger ZL(double threshold) { + return ZL(threshold, m_hid.getScheduler().getDefaultEventLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the ZL. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the ZL axis exceeds 0.5, attached to + * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger ZL() { + return ZL(0.5); + } + + /** + * Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger ZR(double threshold, EventLoop loop) { + return m_hid.axisGreaterThan( + SwitchProController.Axis.ZR.value, threshold, loop); + } + + /** + * Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided + * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler event + * loop} on the scheduler passed to the controller's constructor, or the {@link + * Scheduler#getDefault default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger ZR(double threshold) { + return ZR(threshold, m_hid.getScheduler().getDefaultEventLoop()); + } + + + /** + * Constructs a Trigger instance around the axis value of the ZR. The returned + * trigger will be true when the axis value is greater than 0.5. + * + * @return a Trigger instance that is true when the ZR axis exceeds 0.5, attached to + * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the + * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault + * default scheduler} if a scheduler was not explicitly provided. + */ + public Trigger ZR() { + return ZR(0.5); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_controller.getLeftX(); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_controller.getLeftY(); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return m_controller.getRightX(); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return m_controller.getRightY(); + } + + /** + * Get the ZL value of the controller. + * + * @return The axis value. + */ + public double getZL() { + return m_controller.getZL(); + } + + /** + * Get the ZR value of the controller. + * + * @return The axis value. + */ + public double getZR() { + return m_controller.getZR(); + } +} diff --git a/wpilibc/robotpy_pybind_build_info.bzl b/wpilibc/robotpy_pybind_build_info.bzl index 9549542acd..44b0417830 100644 --- a/wpilibc/robotpy_pybind_build_info.bzl +++ b/wpilibc/robotpy_pybind_build_info.bzl @@ -241,6 +241,26 @@ def wpilib_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includ ("wpi::Joystick", "wpi__Joystick.hpp"), ], ), + struct( + class_name = "GameCubeController", + yml_file = "semiwrap/GameCubeController.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/GameCubeController.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::GameCubeController", "wpi__GameCubeController.hpp"), + ], + ), + struct( + class_name = "DualSenseEdgeController", + yml_file = "semiwrap/DualSenseEdgeController.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/DualSenseEdgeController.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::DualSenseEdgeController", "wpi__DualSenseEdgeController.hpp"), + ], + ), struct( class_name = "DualSenseController", yml_file = "semiwrap/DualSenseController.yml", @@ -251,6 +271,76 @@ def wpilib_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includ ("wpi::DualSenseController", "wpi__DualSenseController.hpp"), ], ), + struct( + class_name = "DualShock4Controller", + yml_file = "semiwrap/DualShock4Controller.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/DualShock4Controller.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::DualShock4Controller", "wpi__DualShock4Controller.hpp"), + ], + ), + struct( + class_name = "LogitechF310Controller", + yml_file = "semiwrap/LogitechF310Controller.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/LogitechF310Controller.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::LogitechF310Controller", "wpi__LogitechF310Controller.hpp"), + ], + ), + struct( + class_name = "SteamController", + yml_file = "semiwrap/SteamController.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/SteamController.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::SteamController", "wpi__SteamController.hpp"), + ], + ), + struct( + class_name = "Switch2GCController", + yml_file = "semiwrap/Switch2GCController.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/Switch2GCController.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Switch2GCController", "wpi__Switch2GCController.hpp"), + ], + ), + struct( + class_name = "Switch2ProController", + yml_file = "semiwrap/Switch2ProController.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/Switch2ProController.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Switch2ProController", "wpi__Switch2ProController.hpp"), + ], + ), + struct( + class_name = "SwitchN64Controller", + yml_file = "semiwrap/SwitchN64Controller.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/SwitchN64Controller.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::SwitchN64Controller", "wpi__SwitchN64Controller.hpp"), + ], + ), + struct( + class_name = "SwitchProController", + yml_file = "semiwrap/SwitchProController.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/SwitchProController.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::SwitchProController", "wpi__SwitchProController.hpp"), + ], + ), struct( class_name = "XboxController", yml_file = "semiwrap/XboxController.yml", @@ -1480,6 +1570,26 @@ def wpilib_simulation_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = ("wpi::sim::LinearSystemSim", "wpi__sim__LinearSystemSim.hpp"), ], ), + struct( + class_name = "GameCubeControllerSim", + yml_file = "semiwrap/simulation/GameCubeControllerSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/GameCubeControllerSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::GameCubeControllerSim", "wpi__sim__GameCubeControllerSim.hpp"), + ], + ), + struct( + class_name = "DualSenseEdgeControllerSim", + yml_file = "semiwrap/simulation/DualSenseEdgeControllerSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/DualSenseEdgeControllerSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::DualSenseEdgeControllerSim", "wpi__sim__DualSenseEdgeControllerSim.hpp"), + ], + ), struct( class_name = "DualSenseControllerSim", yml_file = "semiwrap/simulation/DualSenseControllerSim.yml", @@ -1490,6 +1600,76 @@ def wpilib_simulation_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = ("wpi::sim::DualSenseControllerSim", "wpi__sim__DualSenseControllerSim.hpp"), ], ), + struct( + class_name = "DualShock4ControllerSim", + yml_file = "semiwrap/simulation/DualShock4ControllerSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/DualShock4ControllerSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::DualShock4ControllerSim", "wpi__sim__DualShock4ControllerSim.hpp"), + ], + ), + struct( + class_name = "LogitechF310ControllerSim", + yml_file = "semiwrap/simulation/LogitechF310ControllerSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/LogitechF310ControllerSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::LogitechF310ControllerSim", "wpi__sim__LogitechF310ControllerSim.hpp"), + ], + ), + struct( + class_name = "SteamControllerSim", + yml_file = "semiwrap/simulation/SteamControllerSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/SteamControllerSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::SteamControllerSim", "wpi__sim__SteamControllerSim.hpp"), + ], + ), + struct( + class_name = "Switch2GCControllerSim", + yml_file = "semiwrap/simulation/Switch2GCControllerSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/Switch2GCControllerSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::Switch2GCControllerSim", "wpi__sim__Switch2GCControllerSim.hpp"), + ], + ), + struct( + class_name = "Switch2ProControllerSim", + yml_file = "semiwrap/simulation/Switch2ProControllerSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/Switch2ProControllerSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::Switch2ProControllerSim", "wpi__sim__Switch2ProControllerSim.hpp"), + ], + ), + struct( + class_name = "SwitchN64ControllerSim", + yml_file = "semiwrap/simulation/SwitchN64ControllerSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/SwitchN64ControllerSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::SwitchN64ControllerSim", "wpi__sim__SwitchN64ControllerSim.hpp"), + ], + ), + struct( + class_name = "SwitchProControllerSim", + yml_file = "semiwrap/simulation/SwitchProControllerSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/SwitchProControllerSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::SwitchProControllerSim", "wpi__sim__SwitchProControllerSim.hpp"), + ], + ), struct( class_name = "XboxControllerSim", yml_file = "semiwrap/simulation/XboxControllerSim.yml", diff --git a/wpilibc/src/generated/main/native/cpp/driverstation/DualSenseEdgeController.cpp b/wpilibc/src/generated/main/native/cpp/driverstation/DualSenseEdgeController.cpp new file mode 100644 index 0000000000..eff9945173 --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/driverstation/DualSenseEdgeController.cpp @@ -0,0 +1,479 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/DualSenseEdgeController.hpp" + +#include "wpi/driverstation/DriverStation.hpp" +#include "wpi/event/BooleanEvent.hpp" +#include "wpi/hal/UsageReporting.hpp" +#include "wpi/util/sendable/SendableBuilder.hpp" + +using namespace wpi; + +DualSenseEdgeController::DualSenseEdgeController(int port) + : DualSenseEdgeController{DriverStation::GetGenericHID(port)} {} + +DualSenseEdgeController::DualSenseEdgeController(GenericHID& hid) + : m_hid{&hid} { + HAL_ReportUsage("HID", hid.GetPort(), "DualSenseEdgeController"); +} + +GenericHID& DualSenseEdgeController::GetHID() { + return *m_hid; +} + +const GenericHID& DualSenseEdgeController::GetHID() const { + return *m_hid; +} + +int DualSenseEdgeController::GetPort() const { + return m_hid->GetPort(); +} + +bool DualSenseEdgeController::IsConnected() const { + return m_hid->IsConnected(); +} + +double DualSenseEdgeController::GetLeftX() const { + return GetAxis(Axis::LEFT_X); +} + +double DualSenseEdgeController::GetLeftY() const { + return GetAxis(Axis::LEFT_Y); +} + +double DualSenseEdgeController::GetRightX() const { + return GetAxis(Axis::RIGHT_X); +} + +double DualSenseEdgeController::GetRightY() const { + return GetAxis(Axis::RIGHT_Y); +} + +double DualSenseEdgeController::GetL2() const { + return GetAxis(Axis::L2); +} + +double DualSenseEdgeController::GetR2() const { + return GetAxis(Axis::R2); +} + +double DualSenseEdgeController::GetAxis(Axis axis) const { + return m_hid->GetRawAxis(static_cast(axis)); +} + +BooleanEvent DualSenseEdgeController::AxisLessThan(Axis axis, double threshold, + EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +BooleanEvent DualSenseEdgeController::AxisGreaterThan( + Axis axis, double threshold, EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +bool DualSenseEdgeController::GetCrossButton() const { + return GetButton(Button::CROSS); +} + +bool DualSenseEdgeController::GetCrossButtonPressed() { + return GetButtonPressed(Button::CROSS); +} + +bool DualSenseEdgeController::GetCrossButtonReleased() { + return GetButtonReleased(Button::CROSS); +} + +BooleanEvent DualSenseEdgeController::Cross(EventLoop* loop) const { + return ButtonEvent(Button::CROSS, loop); +} + +bool DualSenseEdgeController::GetCircleButton() const { + return GetButton(Button::CIRCLE); +} + +bool DualSenseEdgeController::GetCircleButtonPressed() { + return GetButtonPressed(Button::CIRCLE); +} + +bool DualSenseEdgeController::GetCircleButtonReleased() { + return GetButtonReleased(Button::CIRCLE); +} + +BooleanEvent DualSenseEdgeController::Circle(EventLoop* loop) const { + return ButtonEvent(Button::CIRCLE, loop); +} + +bool DualSenseEdgeController::GetSquareButton() const { + return GetButton(Button::SQUARE); +} + +bool DualSenseEdgeController::GetSquareButtonPressed() { + return GetButtonPressed(Button::SQUARE); +} + +bool DualSenseEdgeController::GetSquareButtonReleased() { + return GetButtonReleased(Button::SQUARE); +} + +BooleanEvent DualSenseEdgeController::Square(EventLoop* loop) const { + return ButtonEvent(Button::SQUARE, loop); +} + +bool DualSenseEdgeController::GetTriangleButton() const { + return GetButton(Button::TRIANGLE); +} + +bool DualSenseEdgeController::GetTriangleButtonPressed() { + return GetButtonPressed(Button::TRIANGLE); +} + +bool DualSenseEdgeController::GetTriangleButtonReleased() { + return GetButtonReleased(Button::TRIANGLE); +} + +BooleanEvent DualSenseEdgeController::Triangle(EventLoop* loop) const { + return ButtonEvent(Button::TRIANGLE, loop); +} + +bool DualSenseEdgeController::GetCreateButton() const { + return GetButton(Button::CREATE); +} + +bool DualSenseEdgeController::GetCreateButtonPressed() { + return GetButtonPressed(Button::CREATE); +} + +bool DualSenseEdgeController::GetCreateButtonReleased() { + return GetButtonReleased(Button::CREATE); +} + +BooleanEvent DualSenseEdgeController::Create(EventLoop* loop) const { + return ButtonEvent(Button::CREATE, loop); +} + +bool DualSenseEdgeController::GetPSButton() const { + return GetButton(Button::PS); +} + +bool DualSenseEdgeController::GetPSButtonPressed() { + return GetButtonPressed(Button::PS); +} + +bool DualSenseEdgeController::GetPSButtonReleased() { + return GetButtonReleased(Button::PS); +} + +BooleanEvent DualSenseEdgeController::PS(EventLoop* loop) const { + return ButtonEvent(Button::PS, loop); +} + +bool DualSenseEdgeController::GetOptionsButton() const { + return GetButton(Button::OPTIONS); +} + +bool DualSenseEdgeController::GetOptionsButtonPressed() { + return GetButtonPressed(Button::OPTIONS); +} + +bool DualSenseEdgeController::GetOptionsButtonReleased() { + return GetButtonReleased(Button::OPTIONS); +} + +BooleanEvent DualSenseEdgeController::Options(EventLoop* loop) const { + return ButtonEvent(Button::OPTIONS, loop); +} + +bool DualSenseEdgeController::GetL3Button() const { + return GetButton(Button::L3); +} + +bool DualSenseEdgeController::GetL3ButtonPressed() { + return GetButtonPressed(Button::L3); +} + +bool DualSenseEdgeController::GetL3ButtonReleased() { + return GetButtonReleased(Button::L3); +} + +BooleanEvent DualSenseEdgeController::L3(EventLoop* loop) const { + return ButtonEvent(Button::L3, loop); +} + +bool DualSenseEdgeController::GetR3Button() const { + return GetButton(Button::R3); +} + +bool DualSenseEdgeController::GetR3ButtonPressed() { + return GetButtonPressed(Button::R3); +} + +bool DualSenseEdgeController::GetR3ButtonReleased() { + return GetButtonReleased(Button::R3); +} + +BooleanEvent DualSenseEdgeController::R3(EventLoop* loop) const { + return ButtonEvent(Button::R3, loop); +} + +bool DualSenseEdgeController::GetL1Button() const { + return GetButton(Button::L1); +} + +bool DualSenseEdgeController::GetL1ButtonPressed() { + return GetButtonPressed(Button::L1); +} + +bool DualSenseEdgeController::GetL1ButtonReleased() { + return GetButtonReleased(Button::L1); +} + +BooleanEvent DualSenseEdgeController::L1(EventLoop* loop) const { + return ButtonEvent(Button::L1, loop); +} + +bool DualSenseEdgeController::GetR1Button() const { + return GetButton(Button::R1); +} + +bool DualSenseEdgeController::GetR1ButtonPressed() { + return GetButtonPressed(Button::R1); +} + +bool DualSenseEdgeController::GetR1ButtonReleased() { + return GetButtonReleased(Button::R1); +} + +BooleanEvent DualSenseEdgeController::R1(EventLoop* loop) const { + return ButtonEvent(Button::R1, loop); +} + +bool DualSenseEdgeController::GetDpadUpButton() const { + return GetButton(Button::DPAD_UP); +} + +bool DualSenseEdgeController::GetDpadUpButtonPressed() { + return GetButtonPressed(Button::DPAD_UP); +} + +bool DualSenseEdgeController::GetDpadUpButtonReleased() { + return GetButtonReleased(Button::DPAD_UP); +} + +BooleanEvent DualSenseEdgeController::DpadUp(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_UP, loop); +} + +bool DualSenseEdgeController::GetDpadDownButton() const { + return GetButton(Button::DPAD_DOWN); +} + +bool DualSenseEdgeController::GetDpadDownButtonPressed() { + return GetButtonPressed(Button::DPAD_DOWN); +} + +bool DualSenseEdgeController::GetDpadDownButtonReleased() { + return GetButtonReleased(Button::DPAD_DOWN); +} + +BooleanEvent DualSenseEdgeController::DpadDown(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_DOWN, loop); +} + +bool DualSenseEdgeController::GetDpadLeftButton() const { + return GetButton(Button::DPAD_LEFT); +} + +bool DualSenseEdgeController::GetDpadLeftButtonPressed() { + return GetButtonPressed(Button::DPAD_LEFT); +} + +bool DualSenseEdgeController::GetDpadLeftButtonReleased() { + return GetButtonReleased(Button::DPAD_LEFT); +} + +BooleanEvent DualSenseEdgeController::DpadLeft(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_LEFT, loop); +} + +bool DualSenseEdgeController::GetDpadRightButton() const { + return GetButton(Button::DPAD_RIGHT); +} + +bool DualSenseEdgeController::GetDpadRightButtonPressed() { + return GetButtonPressed(Button::DPAD_RIGHT); +} + +bool DualSenseEdgeController::GetDpadRightButtonReleased() { + return GetButtonReleased(Button::DPAD_RIGHT); +} + +BooleanEvent DualSenseEdgeController::DpadRight(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_RIGHT, loop); +} + +bool DualSenseEdgeController::GetMicrophoneButton() const { + return GetButton(Button::MICROPHONE); +} + +bool DualSenseEdgeController::GetMicrophoneButtonPressed() { + return GetButtonPressed(Button::MICROPHONE); +} + +bool DualSenseEdgeController::GetMicrophoneButtonReleased() { + return GetButtonReleased(Button::MICROPHONE); +} + +BooleanEvent DualSenseEdgeController::Microphone(EventLoop* loop) const { + return ButtonEvent(Button::MICROPHONE, loop); +} + +bool DualSenseEdgeController::GetRightPaddle1Button() const { + return GetButton(Button::RIGHT_PADDLE_1); +} + +bool DualSenseEdgeController::GetRightPaddle1ButtonPressed() { + return GetButtonPressed(Button::RIGHT_PADDLE_1); +} + +bool DualSenseEdgeController::GetRightPaddle1ButtonReleased() { + return GetButtonReleased(Button::RIGHT_PADDLE_1); +} + +BooleanEvent DualSenseEdgeController::RightPaddle1(EventLoop* loop) const { + return ButtonEvent(Button::RIGHT_PADDLE_1, loop); +} + +bool DualSenseEdgeController::GetLeftPaddle1Button() const { + return GetButton(Button::LEFT_PADDLE_1); +} + +bool DualSenseEdgeController::GetLeftPaddle1ButtonPressed() { + return GetButtonPressed(Button::LEFT_PADDLE_1); +} + +bool DualSenseEdgeController::GetLeftPaddle1ButtonReleased() { + return GetButtonReleased(Button::LEFT_PADDLE_1); +} + +BooleanEvent DualSenseEdgeController::LeftPaddle1(EventLoop* loop) const { + return ButtonEvent(Button::LEFT_PADDLE_1, loop); +} + +bool DualSenseEdgeController::GetTouchpadButton() const { + return GetButton(Button::TOUCHPAD); +} + +bool DualSenseEdgeController::GetTouchpadButtonPressed() { + return GetButtonPressed(Button::TOUCHPAD); +} + +bool DualSenseEdgeController::GetTouchpadButtonReleased() { + return GetButtonReleased(Button::TOUCHPAD); +} + +BooleanEvent DualSenseEdgeController::Touchpad(EventLoop* loop) const { + return ButtonEvent(Button::TOUCHPAD, loop); +} + +bool DualSenseEdgeController::GetLeftFunctionButton() const { + return GetButton(Button::LEFT_FUNCTION); +} + +bool DualSenseEdgeController::GetLeftFunctionButtonPressed() { + return GetButtonPressed(Button::LEFT_FUNCTION); +} + +bool DualSenseEdgeController::GetLeftFunctionButtonReleased() { + return GetButtonReleased(Button::LEFT_FUNCTION); +} + +BooleanEvent DualSenseEdgeController::LeftFunction(EventLoop* loop) const { + return ButtonEvent(Button::LEFT_FUNCTION, loop); +} + +bool DualSenseEdgeController::GetRightFunctionButton() const { + return GetButton(Button::RIGHT_FUNCTION); +} + +bool DualSenseEdgeController::GetRightFunctionButtonPressed() { + return GetButtonPressed(Button::RIGHT_FUNCTION); +} + +bool DualSenseEdgeController::GetRightFunctionButtonReleased() { + return GetButtonReleased(Button::RIGHT_FUNCTION); +} + +BooleanEvent DualSenseEdgeController::RightFunction(EventLoop* loop) const { + return ButtonEvent(Button::RIGHT_FUNCTION, loop); +} + +bool DualSenseEdgeController::GetButton(Button button) const { + return m_hid->GetRawButton(static_cast(button)); +} + +bool DualSenseEdgeController::GetButtonPressed(Button button) { + return m_hid->GetRawButtonPressed(static_cast(button)); +} + +bool DualSenseEdgeController::GetButtonReleased(Button button) { + return m_hid->GetRawButtonReleased(static_cast(button)); +} + +BooleanEvent DualSenseEdgeController::ButtonEvent(Button button, + EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + +void DualSenseEdgeController::SetLeds(int r, int g, int b) { + m_hid->SetLeds(r, g, b); +} + +void DualSenseEdgeController::SetRumble(GenericHID::RumbleType type, + double value) { + m_hid->SetRumble(type, value); +} + + +bool DualSenseEdgeController::GetTouchpadFingerAvailable(int finger) const { + return m_hid->GetTouchpadFingerAvailable(0, finger); +} + +TouchpadFinger DualSenseEdgeController::GetTouchpadFinger(int finger) const { + return m_hid->GetTouchpadFinger(0, finger); +} + + +void DualSenseEdgeController::InitSendable(wpi::util::SendableBuilder& builder) { + builder.SetSmartDashboardType("HID"); + builder.PublishConstString("ControllerType", "DualSenseEdge"); + builder.AddDoubleProperty("LeftX", [this] { return GetLeftX(); }, nullptr); + builder.AddDoubleProperty("LeftY", [this] { return GetLeftY(); }, nullptr); + builder.AddDoubleProperty("RightX", [this] { return GetRightX(); }, nullptr); + builder.AddDoubleProperty("RightY", [this] { return GetRightY(); }, nullptr); + builder.AddDoubleProperty("L2", [this] { return GetL2(); }, nullptr); + builder.AddDoubleProperty("R2", [this] { return GetR2(); }, nullptr); + builder.AddBooleanProperty("Cross", [this] { return GetCrossButton(); }, nullptr); + builder.AddBooleanProperty("Circle", [this] { return GetCircleButton(); }, nullptr); + builder.AddBooleanProperty("Square", [this] { return GetSquareButton(); }, nullptr); + builder.AddBooleanProperty("Triangle", [this] { return GetTriangleButton(); }, nullptr); + builder.AddBooleanProperty("Create", [this] { return GetCreateButton(); }, nullptr); + builder.AddBooleanProperty("PS", [this] { return GetPSButton(); }, nullptr); + builder.AddBooleanProperty("Options", [this] { return GetOptionsButton(); }, nullptr); + builder.AddBooleanProperty("L3", [this] { return GetL3Button(); }, nullptr); + builder.AddBooleanProperty("R3", [this] { return GetR3Button(); }, nullptr); + builder.AddBooleanProperty("L1", [this] { return GetL1Button(); }, nullptr); + builder.AddBooleanProperty("R1", [this] { return GetR1Button(); }, nullptr); + builder.AddBooleanProperty("DpadUp", [this] { return GetDpadUpButton(); }, nullptr); + builder.AddBooleanProperty("DpadDown", [this] { return GetDpadDownButton(); }, nullptr); + builder.AddBooleanProperty("DpadLeft", [this] { return GetDpadLeftButton(); }, nullptr); + builder.AddBooleanProperty("DpadRight", [this] { return GetDpadRightButton(); }, nullptr); + builder.AddBooleanProperty("Microphone", [this] { return GetMicrophoneButton(); }, nullptr); + builder.AddBooleanProperty("RightPaddle1", [this] { return GetRightPaddle1Button(); }, nullptr); + builder.AddBooleanProperty("LeftPaddle1", [this] { return GetLeftPaddle1Button(); }, nullptr); + builder.AddBooleanProperty("Touchpad", [this] { return GetTouchpadButton(); }, nullptr); + builder.AddBooleanProperty("LeftFunction", [this] { return GetLeftFunctionButton(); }, nullptr); + builder.AddBooleanProperty("RightFunction", [this] { return GetRightFunctionButton(); }, nullptr); +} diff --git a/wpilibc/src/generated/main/native/cpp/driverstation/DualShock4Controller.cpp b/wpilibc/src/generated/main/native/cpp/driverstation/DualShock4Controller.cpp new file mode 100644 index 0000000000..919612452d --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/driverstation/DualShock4Controller.cpp @@ -0,0 +1,394 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/DualShock4Controller.hpp" + +#include "wpi/driverstation/DriverStation.hpp" +#include "wpi/event/BooleanEvent.hpp" +#include "wpi/hal/UsageReporting.hpp" +#include "wpi/util/sendable/SendableBuilder.hpp" + +using namespace wpi; + +DualShock4Controller::DualShock4Controller(int port) + : DualShock4Controller{DriverStation::GetGenericHID(port)} {} + +DualShock4Controller::DualShock4Controller(GenericHID& hid) + : m_hid{&hid} { + HAL_ReportUsage("HID", hid.GetPort(), "DualShock4Controller"); +} + +GenericHID& DualShock4Controller::GetHID() { + return *m_hid; +} + +const GenericHID& DualShock4Controller::GetHID() const { + return *m_hid; +} + +int DualShock4Controller::GetPort() const { + return m_hid->GetPort(); +} + +bool DualShock4Controller::IsConnected() const { + return m_hid->IsConnected(); +} + +double DualShock4Controller::GetLeftX() const { + return GetAxis(Axis::LEFT_X); +} + +double DualShock4Controller::GetLeftY() const { + return GetAxis(Axis::LEFT_Y); +} + +double DualShock4Controller::GetRightX() const { + return GetAxis(Axis::RIGHT_X); +} + +double DualShock4Controller::GetRightY() const { + return GetAxis(Axis::RIGHT_Y); +} + +double DualShock4Controller::GetL2() const { + return GetAxis(Axis::L2); +} + +double DualShock4Controller::GetR2() const { + return GetAxis(Axis::R2); +} + +double DualShock4Controller::GetAxis(Axis axis) const { + return m_hid->GetRawAxis(static_cast(axis)); +} + +BooleanEvent DualShock4Controller::AxisLessThan(Axis axis, double threshold, + EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +BooleanEvent DualShock4Controller::AxisGreaterThan( + Axis axis, double threshold, EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +bool DualShock4Controller::GetCrossButton() const { + return GetButton(Button::CROSS); +} + +bool DualShock4Controller::GetCrossButtonPressed() { + return GetButtonPressed(Button::CROSS); +} + +bool DualShock4Controller::GetCrossButtonReleased() { + return GetButtonReleased(Button::CROSS); +} + +BooleanEvent DualShock4Controller::Cross(EventLoop* loop) const { + return ButtonEvent(Button::CROSS, loop); +} + +bool DualShock4Controller::GetCircleButton() const { + return GetButton(Button::CIRCLE); +} + +bool DualShock4Controller::GetCircleButtonPressed() { + return GetButtonPressed(Button::CIRCLE); +} + +bool DualShock4Controller::GetCircleButtonReleased() { + return GetButtonReleased(Button::CIRCLE); +} + +BooleanEvent DualShock4Controller::Circle(EventLoop* loop) const { + return ButtonEvent(Button::CIRCLE, loop); +} + +bool DualShock4Controller::GetSquareButton() const { + return GetButton(Button::SQUARE); +} + +bool DualShock4Controller::GetSquareButtonPressed() { + return GetButtonPressed(Button::SQUARE); +} + +bool DualShock4Controller::GetSquareButtonReleased() { + return GetButtonReleased(Button::SQUARE); +} + +BooleanEvent DualShock4Controller::Square(EventLoop* loop) const { + return ButtonEvent(Button::SQUARE, loop); +} + +bool DualShock4Controller::GetTriangleButton() const { + return GetButton(Button::TRIANGLE); +} + +bool DualShock4Controller::GetTriangleButtonPressed() { + return GetButtonPressed(Button::TRIANGLE); +} + +bool DualShock4Controller::GetTriangleButtonReleased() { + return GetButtonReleased(Button::TRIANGLE); +} + +BooleanEvent DualShock4Controller::Triangle(EventLoop* loop) const { + return ButtonEvent(Button::TRIANGLE, loop); +} + +bool DualShock4Controller::GetShareButton() const { + return GetButton(Button::SHARE); +} + +bool DualShock4Controller::GetShareButtonPressed() { + return GetButtonPressed(Button::SHARE); +} + +bool DualShock4Controller::GetShareButtonReleased() { + return GetButtonReleased(Button::SHARE); +} + +BooleanEvent DualShock4Controller::Share(EventLoop* loop) const { + return ButtonEvent(Button::SHARE, loop); +} + +bool DualShock4Controller::GetPSButton() const { + return GetButton(Button::PS); +} + +bool DualShock4Controller::GetPSButtonPressed() { + return GetButtonPressed(Button::PS); +} + +bool DualShock4Controller::GetPSButtonReleased() { + return GetButtonReleased(Button::PS); +} + +BooleanEvent DualShock4Controller::PS(EventLoop* loop) const { + return ButtonEvent(Button::PS, loop); +} + +bool DualShock4Controller::GetOptionsButton() const { + return GetButton(Button::OPTIONS); +} + +bool DualShock4Controller::GetOptionsButtonPressed() { + return GetButtonPressed(Button::OPTIONS); +} + +bool DualShock4Controller::GetOptionsButtonReleased() { + return GetButtonReleased(Button::OPTIONS); +} + +BooleanEvent DualShock4Controller::Options(EventLoop* loop) const { + return ButtonEvent(Button::OPTIONS, loop); +} + +bool DualShock4Controller::GetL3Button() const { + return GetButton(Button::L3); +} + +bool DualShock4Controller::GetL3ButtonPressed() { + return GetButtonPressed(Button::L3); +} + +bool DualShock4Controller::GetL3ButtonReleased() { + return GetButtonReleased(Button::L3); +} + +BooleanEvent DualShock4Controller::L3(EventLoop* loop) const { + return ButtonEvent(Button::L3, loop); +} + +bool DualShock4Controller::GetR3Button() const { + return GetButton(Button::R3); +} + +bool DualShock4Controller::GetR3ButtonPressed() { + return GetButtonPressed(Button::R3); +} + +bool DualShock4Controller::GetR3ButtonReleased() { + return GetButtonReleased(Button::R3); +} + +BooleanEvent DualShock4Controller::R3(EventLoop* loop) const { + return ButtonEvent(Button::R3, loop); +} + +bool DualShock4Controller::GetL1Button() const { + return GetButton(Button::L1); +} + +bool DualShock4Controller::GetL1ButtonPressed() { + return GetButtonPressed(Button::L1); +} + +bool DualShock4Controller::GetL1ButtonReleased() { + return GetButtonReleased(Button::L1); +} + +BooleanEvent DualShock4Controller::L1(EventLoop* loop) const { + return ButtonEvent(Button::L1, loop); +} + +bool DualShock4Controller::GetR1Button() const { + return GetButton(Button::R1); +} + +bool DualShock4Controller::GetR1ButtonPressed() { + return GetButtonPressed(Button::R1); +} + +bool DualShock4Controller::GetR1ButtonReleased() { + return GetButtonReleased(Button::R1); +} + +BooleanEvent DualShock4Controller::R1(EventLoop* loop) const { + return ButtonEvent(Button::R1, loop); +} + +bool DualShock4Controller::GetDpadUpButton() const { + return GetButton(Button::DPAD_UP); +} + +bool DualShock4Controller::GetDpadUpButtonPressed() { + return GetButtonPressed(Button::DPAD_UP); +} + +bool DualShock4Controller::GetDpadUpButtonReleased() { + return GetButtonReleased(Button::DPAD_UP); +} + +BooleanEvent DualShock4Controller::DpadUp(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_UP, loop); +} + +bool DualShock4Controller::GetDpadDownButton() const { + return GetButton(Button::DPAD_DOWN); +} + +bool DualShock4Controller::GetDpadDownButtonPressed() { + return GetButtonPressed(Button::DPAD_DOWN); +} + +bool DualShock4Controller::GetDpadDownButtonReleased() { + return GetButtonReleased(Button::DPAD_DOWN); +} + +BooleanEvent DualShock4Controller::DpadDown(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_DOWN, loop); +} + +bool DualShock4Controller::GetDpadLeftButton() const { + return GetButton(Button::DPAD_LEFT); +} + +bool DualShock4Controller::GetDpadLeftButtonPressed() { + return GetButtonPressed(Button::DPAD_LEFT); +} + +bool DualShock4Controller::GetDpadLeftButtonReleased() { + return GetButtonReleased(Button::DPAD_LEFT); +} + +BooleanEvent DualShock4Controller::DpadLeft(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_LEFT, loop); +} + +bool DualShock4Controller::GetDpadRightButton() const { + return GetButton(Button::DPAD_RIGHT); +} + +bool DualShock4Controller::GetDpadRightButtonPressed() { + return GetButtonPressed(Button::DPAD_RIGHT); +} + +bool DualShock4Controller::GetDpadRightButtonReleased() { + return GetButtonReleased(Button::DPAD_RIGHT); +} + +BooleanEvent DualShock4Controller::DpadRight(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_RIGHT, loop); +} + +bool DualShock4Controller::GetTouchpadButton() const { + return GetButton(Button::TOUCHPAD); +} + +bool DualShock4Controller::GetTouchpadButtonPressed() { + return GetButtonPressed(Button::TOUCHPAD); +} + +bool DualShock4Controller::GetTouchpadButtonReleased() { + return GetButtonReleased(Button::TOUCHPAD); +} + +BooleanEvent DualShock4Controller::Touchpad(EventLoop* loop) const { + return ButtonEvent(Button::TOUCHPAD, loop); +} + +bool DualShock4Controller::GetButton(Button button) const { + return m_hid->GetRawButton(static_cast(button)); +} + +bool DualShock4Controller::GetButtonPressed(Button button) { + return m_hid->GetRawButtonPressed(static_cast(button)); +} + +bool DualShock4Controller::GetButtonReleased(Button button) { + return m_hid->GetRawButtonReleased(static_cast(button)); +} + +BooleanEvent DualShock4Controller::ButtonEvent(Button button, + EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + +void DualShock4Controller::SetLeds(int r, int g, int b) { + m_hid->SetLeds(r, g, b); +} + +void DualShock4Controller::SetRumble(GenericHID::RumbleType type, + double value) { + m_hid->SetRumble(type, value); +} + + +bool DualShock4Controller::GetTouchpadFingerAvailable(int finger) const { + return m_hid->GetTouchpadFingerAvailable(0, finger); +} + +TouchpadFinger DualShock4Controller::GetTouchpadFinger(int finger) const { + return m_hid->GetTouchpadFinger(0, finger); +} + + +void DualShock4Controller::InitSendable(wpi::util::SendableBuilder& builder) { + builder.SetSmartDashboardType("HID"); + builder.PublishConstString("ControllerType", "DualShock4"); + builder.AddDoubleProperty("LeftX", [this] { return GetLeftX(); }, nullptr); + builder.AddDoubleProperty("LeftY", [this] { return GetLeftY(); }, nullptr); + builder.AddDoubleProperty("RightX", [this] { return GetRightX(); }, nullptr); + builder.AddDoubleProperty("RightY", [this] { return GetRightY(); }, nullptr); + builder.AddDoubleProperty("L2", [this] { return GetL2(); }, nullptr); + builder.AddDoubleProperty("R2", [this] { return GetR2(); }, nullptr); + builder.AddBooleanProperty("Cross", [this] { return GetCrossButton(); }, nullptr); + builder.AddBooleanProperty("Circle", [this] { return GetCircleButton(); }, nullptr); + builder.AddBooleanProperty("Square", [this] { return GetSquareButton(); }, nullptr); + builder.AddBooleanProperty("Triangle", [this] { return GetTriangleButton(); }, nullptr); + builder.AddBooleanProperty("Share", [this] { return GetShareButton(); }, nullptr); + builder.AddBooleanProperty("PS", [this] { return GetPSButton(); }, nullptr); + builder.AddBooleanProperty("Options", [this] { return GetOptionsButton(); }, nullptr); + builder.AddBooleanProperty("L3", [this] { return GetL3Button(); }, nullptr); + builder.AddBooleanProperty("R3", [this] { return GetR3Button(); }, nullptr); + builder.AddBooleanProperty("L1", [this] { return GetL1Button(); }, nullptr); + builder.AddBooleanProperty("R1", [this] { return GetR1Button(); }, nullptr); + builder.AddBooleanProperty("DpadUp", [this] { return GetDpadUpButton(); }, nullptr); + builder.AddBooleanProperty("DpadDown", [this] { return GetDpadDownButton(); }, nullptr); + builder.AddBooleanProperty("DpadLeft", [this] { return GetDpadLeftButton(); }, nullptr); + builder.AddBooleanProperty("DpadRight", [this] { return GetDpadRightButton(); }, nullptr); + builder.AddBooleanProperty("Touchpad", [this] { return GetTouchpadButton(); }, nullptr); +} diff --git a/wpilibc/src/generated/main/native/cpp/driverstation/GameCubeController.cpp b/wpilibc/src/generated/main/native/cpp/driverstation/GameCubeController.cpp new file mode 100644 index 0000000000..a0ff505dc5 --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/driverstation/GameCubeController.cpp @@ -0,0 +1,318 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/GameCubeController.hpp" + +#include "wpi/driverstation/DriverStation.hpp" +#include "wpi/event/BooleanEvent.hpp" +#include "wpi/hal/UsageReporting.hpp" +#include "wpi/util/sendable/SendableBuilder.hpp" + +using namespace wpi; + +GameCubeController::GameCubeController(int port) + : GameCubeController{DriverStation::GetGenericHID(port)} {} + +GameCubeController::GameCubeController(GenericHID& hid) + : m_hid{&hid} { + HAL_ReportUsage("HID", hid.GetPort(), "GameCubeController"); +} + +GenericHID& GameCubeController::GetHID() { + return *m_hid; +} + +const GenericHID& GameCubeController::GetHID() const { + return *m_hid; +} + +int GameCubeController::GetPort() const { + return m_hid->GetPort(); +} + +bool GameCubeController::IsConnected() const { + return m_hid->IsConnected(); +} + +double GameCubeController::GetLeftX() const { + return GetAxis(Axis::LEFT_X); +} + +double GameCubeController::GetLeftY() const { + return GetAxis(Axis::LEFT_Y); +} + +double GameCubeController::GetCStickX() const { + return GetAxis(Axis::C_STICK_X); +} + +double GameCubeController::GetCStickY() const { + return GetAxis(Axis::C_STICK_Y); +} + +double GameCubeController::GetLTrigger() const { + return GetAxis(Axis::L_TRIGGER); +} + +double GameCubeController::GetRTrigger() const { + return GetAxis(Axis::R_TRIGGER); +} + +double GameCubeController::GetAxis(Axis axis) const { + return m_hid->GetRawAxis(static_cast(axis)); +} + +BooleanEvent GameCubeController::AxisLessThan(Axis axis, double threshold, + EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +BooleanEvent GameCubeController::AxisGreaterThan( + Axis axis, double threshold, EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +bool GameCubeController::GetAButton() const { + return GetButton(Button::A); +} + +bool GameCubeController::GetAButtonPressed() { + return GetButtonPressed(Button::A); +} + +bool GameCubeController::GetAButtonReleased() { + return GetButtonReleased(Button::A); +} + +BooleanEvent GameCubeController::A(EventLoop* loop) const { + return ButtonEvent(Button::A, loop); +} + +bool GameCubeController::GetXButton() const { + return GetButton(Button::X); +} + +bool GameCubeController::GetXButtonPressed() { + return GetButtonPressed(Button::X); +} + +bool GameCubeController::GetXButtonReleased() { + return GetButtonReleased(Button::X); +} + +BooleanEvent GameCubeController::X(EventLoop* loop) const { + return ButtonEvent(Button::X, loop); +} + +bool GameCubeController::GetBButton() const { + return GetButton(Button::B); +} + +bool GameCubeController::GetBButtonPressed() { + return GetButtonPressed(Button::B); +} + +bool GameCubeController::GetBButtonReleased() { + return GetButtonReleased(Button::B); +} + +BooleanEvent GameCubeController::B(EventLoop* loop) const { + return ButtonEvent(Button::B, loop); +} + +bool GameCubeController::GetYButton() const { + return GetButton(Button::Y); +} + +bool GameCubeController::GetYButtonPressed() { + return GetButtonPressed(Button::Y); +} + +bool GameCubeController::GetYButtonReleased() { + return GetButtonReleased(Button::Y); +} + +BooleanEvent GameCubeController::Y(EventLoop* loop) const { + return ButtonEvent(Button::Y, loop); +} + +bool GameCubeController::GetStartButton() const { + return GetButton(Button::START); +} + +bool GameCubeController::GetStartButtonPressed() { + return GetButtonPressed(Button::START); +} + +bool GameCubeController::GetStartButtonReleased() { + return GetButtonReleased(Button::START); +} + +BooleanEvent GameCubeController::Start(EventLoop* loop) const { + return ButtonEvent(Button::START, loop); +} + +bool GameCubeController::GetZButton() const { + return GetButton(Button::Z); +} + +bool GameCubeController::GetZButtonPressed() { + return GetButtonPressed(Button::Z); +} + +bool GameCubeController::GetZButtonReleased() { + return GetButtonReleased(Button::Z); +} + +BooleanEvent GameCubeController::Z(EventLoop* loop) const { + return ButtonEvent(Button::Z, loop); +} + +bool GameCubeController::GetDpadUpButton() const { + return GetButton(Button::DPAD_UP); +} + +bool GameCubeController::GetDpadUpButtonPressed() { + return GetButtonPressed(Button::DPAD_UP); +} + +bool GameCubeController::GetDpadUpButtonReleased() { + return GetButtonReleased(Button::DPAD_UP); +} + +BooleanEvent GameCubeController::DpadUp(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_UP, loop); +} + +bool GameCubeController::GetDpadDownButton() const { + return GetButton(Button::DPAD_DOWN); +} + +bool GameCubeController::GetDpadDownButtonPressed() { + return GetButtonPressed(Button::DPAD_DOWN); +} + +bool GameCubeController::GetDpadDownButtonReleased() { + return GetButtonReleased(Button::DPAD_DOWN); +} + +BooleanEvent GameCubeController::DpadDown(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_DOWN, loop); +} + +bool GameCubeController::GetDpadLeftButton() const { + return GetButton(Button::DPAD_LEFT); +} + +bool GameCubeController::GetDpadLeftButtonPressed() { + return GetButtonPressed(Button::DPAD_LEFT); +} + +bool GameCubeController::GetDpadLeftButtonReleased() { + return GetButtonReleased(Button::DPAD_LEFT); +} + +BooleanEvent GameCubeController::DpadLeft(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_LEFT, loop); +} + +bool GameCubeController::GetDpadRightButton() const { + return GetButton(Button::DPAD_RIGHT); +} + +bool GameCubeController::GetDpadRightButtonPressed() { + return GetButtonPressed(Button::DPAD_RIGHT); +} + +bool GameCubeController::GetDpadRightButtonReleased() { + return GetButtonReleased(Button::DPAD_RIGHT); +} + +BooleanEvent GameCubeController::DpadRight(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_RIGHT, loop); +} + +bool GameCubeController::GetLButton() const { + return GetButton(Button::L); +} + +bool GameCubeController::GetLButtonPressed() { + return GetButtonPressed(Button::L); +} + +bool GameCubeController::GetLButtonReleased() { + return GetButtonReleased(Button::L); +} + +BooleanEvent GameCubeController::L(EventLoop* loop) const { + return ButtonEvent(Button::L, loop); +} + +bool GameCubeController::GetRButton() const { + return GetButton(Button::R); +} + +bool GameCubeController::GetRButtonPressed() { + return GetButtonPressed(Button::R); +} + +bool GameCubeController::GetRButtonReleased() { + return GetButtonReleased(Button::R); +} + +BooleanEvent GameCubeController::R(EventLoop* loop) const { + return ButtonEvent(Button::R, loop); +} + +bool GameCubeController::GetButton(Button button) const { + return m_hid->GetRawButton(static_cast(button)); +} + +bool GameCubeController::GetButtonPressed(Button button) { + return m_hid->GetRawButtonPressed(static_cast(button)); +} + +bool GameCubeController::GetButtonReleased(Button button) { + return m_hid->GetRawButtonReleased(static_cast(button)); +} + +BooleanEvent GameCubeController::ButtonEvent(Button button, + EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + +void GameCubeController::SetLeds(int r, int g, int b) { + m_hid->SetLeds(r, g, b); +} + +void GameCubeController::SetRumble(GenericHID::RumbleType type, + double value) { + m_hid->SetRumble(type, value); +} + + + +void GameCubeController::InitSendable(wpi::util::SendableBuilder& builder) { + builder.SetSmartDashboardType("HID"); + builder.PublishConstString("ControllerType", "GameCube"); + builder.AddDoubleProperty("LeftX", [this] { return GetLeftX(); }, nullptr); + builder.AddDoubleProperty("LeftY", [this] { return GetLeftY(); }, nullptr); + builder.AddDoubleProperty("CStickX", [this] { return GetCStickX(); }, nullptr); + builder.AddDoubleProperty("CStickY", [this] { return GetCStickY(); }, nullptr); + builder.AddDoubleProperty("LTrigger", [this] { return GetLTrigger(); }, nullptr); + builder.AddDoubleProperty("RTrigger", [this] { return GetRTrigger(); }, nullptr); + builder.AddBooleanProperty("A", [this] { return GetAButton(); }, nullptr); + builder.AddBooleanProperty("X", [this] { return GetXButton(); }, nullptr); + builder.AddBooleanProperty("B", [this] { return GetBButton(); }, nullptr); + builder.AddBooleanProperty("Y", [this] { return GetYButton(); }, nullptr); + builder.AddBooleanProperty("Start", [this] { return GetStartButton(); }, nullptr); + builder.AddBooleanProperty("Z", [this] { return GetZButton(); }, nullptr); + builder.AddBooleanProperty("DpadUp", [this] { return GetDpadUpButton(); }, nullptr); + builder.AddBooleanProperty("DpadDown", [this] { return GetDpadDownButton(); }, nullptr); + builder.AddBooleanProperty("DpadLeft", [this] { return GetDpadLeftButton(); }, nullptr); + builder.AddBooleanProperty("DpadRight", [this] { return GetDpadRightButton(); }, nullptr); + builder.AddBooleanProperty("L", [this] { return GetLButton(); }, nullptr); + builder.AddBooleanProperty("R", [this] { return GetRButton(); }, nullptr); +} diff --git a/wpilibc/src/generated/main/native/cpp/driverstation/LogitechF310Controller.cpp b/wpilibc/src/generated/main/native/cpp/driverstation/LogitechF310Controller.cpp new file mode 100644 index 0000000000..ace5388ae9 --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/driverstation/LogitechF310Controller.cpp @@ -0,0 +1,369 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/LogitechF310Controller.hpp" + +#include "wpi/driverstation/DriverStation.hpp" +#include "wpi/event/BooleanEvent.hpp" +#include "wpi/hal/UsageReporting.hpp" +#include "wpi/util/sendable/SendableBuilder.hpp" + +using namespace wpi; + +LogitechF310Controller::LogitechF310Controller(int port) + : LogitechF310Controller{DriverStation::GetGenericHID(port)} {} + +LogitechF310Controller::LogitechF310Controller(GenericHID& hid) + : m_hid{&hid} { + HAL_ReportUsage("HID", hid.GetPort(), "LogitechF310Controller"); +} + +GenericHID& LogitechF310Controller::GetHID() { + return *m_hid; +} + +const GenericHID& LogitechF310Controller::GetHID() const { + return *m_hid; +} + +int LogitechF310Controller::GetPort() const { + return m_hid->GetPort(); +} + +bool LogitechF310Controller::IsConnected() const { + return m_hid->IsConnected(); +} + +double LogitechF310Controller::GetLeftX() const { + return GetAxis(Axis::LEFT_X); +} + +double LogitechF310Controller::GetLeftY() const { + return GetAxis(Axis::LEFT_Y); +} + +double LogitechF310Controller::GetRightX() const { + return GetAxis(Axis::RIGHT_X); +} + +double LogitechF310Controller::GetRightY() const { + return GetAxis(Axis::RIGHT_Y); +} + +double LogitechF310Controller::GetLeftTrigger() const { + return GetAxis(Axis::LEFT_TRIGGER); +} + +double LogitechF310Controller::GetRightTrigger() const { + return GetAxis(Axis::RIGHT_TRIGGER); +} + +double LogitechF310Controller::GetAxis(Axis axis) const { + return m_hid->GetRawAxis(static_cast(axis)); +} + +BooleanEvent LogitechF310Controller::AxisLessThan(Axis axis, double threshold, + EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +BooleanEvent LogitechF310Controller::AxisGreaterThan( + Axis axis, double threshold, EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +bool LogitechF310Controller::GetAButton() const { + return GetButton(Button::A); +} + +bool LogitechF310Controller::GetAButtonPressed() { + return GetButtonPressed(Button::A); +} + +bool LogitechF310Controller::GetAButtonReleased() { + return GetButtonReleased(Button::A); +} + +BooleanEvent LogitechF310Controller::A(EventLoop* loop) const { + return ButtonEvent(Button::A, loop); +} + +bool LogitechF310Controller::GetBButton() const { + return GetButton(Button::B); +} + +bool LogitechF310Controller::GetBButtonPressed() { + return GetButtonPressed(Button::B); +} + +bool LogitechF310Controller::GetBButtonReleased() { + return GetButtonReleased(Button::B); +} + +BooleanEvent LogitechF310Controller::B(EventLoop* loop) const { + return ButtonEvent(Button::B, loop); +} + +bool LogitechF310Controller::GetXButton() const { + return GetButton(Button::X); +} + +bool LogitechF310Controller::GetXButtonPressed() { + return GetButtonPressed(Button::X); +} + +bool LogitechF310Controller::GetXButtonReleased() { + return GetButtonReleased(Button::X); +} + +BooleanEvent LogitechF310Controller::X(EventLoop* loop) const { + return ButtonEvent(Button::X, loop); +} + +bool LogitechF310Controller::GetYButton() const { + return GetButton(Button::Y); +} + +bool LogitechF310Controller::GetYButtonPressed() { + return GetButtonPressed(Button::Y); +} + +bool LogitechF310Controller::GetYButtonReleased() { + return GetButtonReleased(Button::Y); +} + +BooleanEvent LogitechF310Controller::Y(EventLoop* loop) const { + return ButtonEvent(Button::Y, loop); +} + +bool LogitechF310Controller::GetBackButton() const { + return GetButton(Button::BACK); +} + +bool LogitechF310Controller::GetBackButtonPressed() { + return GetButtonPressed(Button::BACK); +} + +bool LogitechF310Controller::GetBackButtonReleased() { + return GetButtonReleased(Button::BACK); +} + +BooleanEvent LogitechF310Controller::Back(EventLoop* loop) const { + return ButtonEvent(Button::BACK, loop); +} + +bool LogitechF310Controller::GetLogitechButton() const { + return GetButton(Button::LOGITECH); +} + +bool LogitechF310Controller::GetLogitechButtonPressed() { + return GetButtonPressed(Button::LOGITECH); +} + +bool LogitechF310Controller::GetLogitechButtonReleased() { + return GetButtonReleased(Button::LOGITECH); +} + +BooleanEvent LogitechF310Controller::Logitech(EventLoop* loop) const { + return ButtonEvent(Button::LOGITECH, loop); +} + +bool LogitechF310Controller::GetStartButton() const { + return GetButton(Button::START); +} + +bool LogitechF310Controller::GetStartButtonPressed() { + return GetButtonPressed(Button::START); +} + +bool LogitechF310Controller::GetStartButtonReleased() { + return GetButtonReleased(Button::START); +} + +BooleanEvent LogitechF310Controller::Start(EventLoop* loop) const { + return ButtonEvent(Button::START, loop); +} + +bool LogitechF310Controller::GetLeftStickButton() const { + return GetButton(Button::LEFT_STICK); +} + +bool LogitechF310Controller::GetLeftStickButtonPressed() { + return GetButtonPressed(Button::LEFT_STICK); +} + +bool LogitechF310Controller::GetLeftStickButtonReleased() { + return GetButtonReleased(Button::LEFT_STICK); +} + +BooleanEvent LogitechF310Controller::LeftStick(EventLoop* loop) const { + return ButtonEvent(Button::LEFT_STICK, loop); +} + +bool LogitechF310Controller::GetRightStickButton() const { + return GetButton(Button::RIGHT_STICK); +} + +bool LogitechF310Controller::GetRightStickButtonPressed() { + return GetButtonPressed(Button::RIGHT_STICK); +} + +bool LogitechF310Controller::GetRightStickButtonReleased() { + return GetButtonReleased(Button::RIGHT_STICK); +} + +BooleanEvent LogitechF310Controller::RightStick(EventLoop* loop) const { + return ButtonEvent(Button::RIGHT_STICK, loop); +} + +bool LogitechF310Controller::GetLeftBumperButton() const { + return GetButton(Button::LEFT_BUMPER); +} + +bool LogitechF310Controller::GetLeftBumperButtonPressed() { + return GetButtonPressed(Button::LEFT_BUMPER); +} + +bool LogitechF310Controller::GetLeftBumperButtonReleased() { + return GetButtonReleased(Button::LEFT_BUMPER); +} + +BooleanEvent LogitechF310Controller::LeftBumper(EventLoop* loop) const { + return ButtonEvent(Button::LEFT_BUMPER, loop); +} + +bool LogitechF310Controller::GetRightBumperButton() const { + return GetButton(Button::RIGHT_BUMPER); +} + +bool LogitechF310Controller::GetRightBumperButtonPressed() { + return GetButtonPressed(Button::RIGHT_BUMPER); +} + +bool LogitechF310Controller::GetRightBumperButtonReleased() { + return GetButtonReleased(Button::RIGHT_BUMPER); +} + +BooleanEvent LogitechF310Controller::RightBumper(EventLoop* loop) const { + return ButtonEvent(Button::RIGHT_BUMPER, loop); +} + +bool LogitechF310Controller::GetDpadUpButton() const { + return GetButton(Button::DPAD_UP); +} + +bool LogitechF310Controller::GetDpadUpButtonPressed() { + return GetButtonPressed(Button::DPAD_UP); +} + +bool LogitechF310Controller::GetDpadUpButtonReleased() { + return GetButtonReleased(Button::DPAD_UP); +} + +BooleanEvent LogitechF310Controller::DpadUp(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_UP, loop); +} + +bool LogitechF310Controller::GetDpadDownButton() const { + return GetButton(Button::DPAD_DOWN); +} + +bool LogitechF310Controller::GetDpadDownButtonPressed() { + return GetButtonPressed(Button::DPAD_DOWN); +} + +bool LogitechF310Controller::GetDpadDownButtonReleased() { + return GetButtonReleased(Button::DPAD_DOWN); +} + +BooleanEvent LogitechF310Controller::DpadDown(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_DOWN, loop); +} + +bool LogitechF310Controller::GetDpadLeftButton() const { + return GetButton(Button::DPAD_LEFT); +} + +bool LogitechF310Controller::GetDpadLeftButtonPressed() { + return GetButtonPressed(Button::DPAD_LEFT); +} + +bool LogitechF310Controller::GetDpadLeftButtonReleased() { + return GetButtonReleased(Button::DPAD_LEFT); +} + +BooleanEvent LogitechF310Controller::DpadLeft(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_LEFT, loop); +} + +bool LogitechF310Controller::GetDpadRightButton() const { + return GetButton(Button::DPAD_RIGHT); +} + +bool LogitechF310Controller::GetDpadRightButtonPressed() { + return GetButtonPressed(Button::DPAD_RIGHT); +} + +bool LogitechF310Controller::GetDpadRightButtonReleased() { + return GetButtonReleased(Button::DPAD_RIGHT); +} + +BooleanEvent LogitechF310Controller::DpadRight(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_RIGHT, loop); +} + +bool LogitechF310Controller::GetButton(Button button) const { + return m_hid->GetRawButton(static_cast(button)); +} + +bool LogitechF310Controller::GetButtonPressed(Button button) { + return m_hid->GetRawButtonPressed(static_cast(button)); +} + +bool LogitechF310Controller::GetButtonReleased(Button button) { + return m_hid->GetRawButtonReleased(static_cast(button)); +} + +BooleanEvent LogitechF310Controller::ButtonEvent(Button button, + EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + +void LogitechF310Controller::SetLeds(int r, int g, int b) { + m_hid->SetLeds(r, g, b); +} + +void LogitechF310Controller::SetRumble(GenericHID::RumbleType type, + double value) { + m_hid->SetRumble(type, value); +} + + + +void LogitechF310Controller::InitSendable(wpi::util::SendableBuilder& builder) { + builder.SetSmartDashboardType("HID"); + builder.PublishConstString("ControllerType", "LogitechF310"); + builder.AddDoubleProperty("LeftX", [this] { return GetLeftX(); }, nullptr); + builder.AddDoubleProperty("LeftY", [this] { return GetLeftY(); }, nullptr); + builder.AddDoubleProperty("RightX", [this] { return GetRightX(); }, nullptr); + builder.AddDoubleProperty("RightY", [this] { return GetRightY(); }, nullptr); + builder.AddDoubleProperty("LeftTrigger", [this] { return GetLeftTrigger(); }, nullptr); + builder.AddDoubleProperty("RightTrigger", [this] { return GetRightTrigger(); }, nullptr); + builder.AddBooleanProperty("A", [this] { return GetAButton(); }, nullptr); + builder.AddBooleanProperty("B", [this] { return GetBButton(); }, nullptr); + builder.AddBooleanProperty("X", [this] { return GetXButton(); }, nullptr); + builder.AddBooleanProperty("Y", [this] { return GetYButton(); }, nullptr); + builder.AddBooleanProperty("Back", [this] { return GetBackButton(); }, nullptr); + builder.AddBooleanProperty("Logitech", [this] { return GetLogitechButton(); }, nullptr); + builder.AddBooleanProperty("Start", [this] { return GetStartButton(); }, nullptr); + builder.AddBooleanProperty("LeftStick", [this] { return GetLeftStickButton(); }, nullptr); + builder.AddBooleanProperty("RightStick", [this] { return GetRightStickButton(); }, nullptr); + builder.AddBooleanProperty("LeftBumper", [this] { return GetLeftBumperButton(); }, nullptr); + builder.AddBooleanProperty("RightBumper", [this] { return GetRightBumperButton(); }, nullptr); + builder.AddBooleanProperty("DpadUp", [this] { return GetDpadUpButton(); }, nullptr); + builder.AddBooleanProperty("DpadDown", [this] { return GetDpadDownButton(); }, nullptr); + builder.AddBooleanProperty("DpadLeft", [this] { return GetDpadLeftButton(); }, nullptr); + builder.AddBooleanProperty("DpadRight", [this] { return GetDpadRightButton(); }, nullptr); +} diff --git a/wpilibc/src/generated/main/native/cpp/driverstation/SteamController.cpp b/wpilibc/src/generated/main/native/cpp/driverstation/SteamController.cpp new file mode 100644 index 0000000000..27f98ae9b8 --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/driverstation/SteamController.cpp @@ -0,0 +1,566 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/SteamController.hpp" + +#include "wpi/driverstation/DriverStation.hpp" +#include "wpi/event/BooleanEvent.hpp" +#include "wpi/hal/UsageReporting.hpp" +#include "wpi/util/sendable/SendableBuilder.hpp" + +using namespace wpi; + +SteamController::SteamController(int port) + : SteamController{DriverStation::GetGenericHID(port)} {} + +SteamController::SteamController(GenericHID& hid) + : m_hid{&hid} { + HAL_ReportUsage("HID", hid.GetPort(), "SteamController"); +} + +GenericHID& SteamController::GetHID() { + return *m_hid; +} + +const GenericHID& SteamController::GetHID() const { + return *m_hid; +} + +int SteamController::GetPort() const { + return m_hid->GetPort(); +} + +bool SteamController::IsConnected() const { + return m_hid->IsConnected(); +} + +double SteamController::GetLeftX() const { + return GetAxis(Axis::LEFT_X); +} + +double SteamController::GetLeftY() const { + return GetAxis(Axis::LEFT_Y); +} + +double SteamController::GetRightX() const { + return GetAxis(Axis::RIGHT_X); +} + +double SteamController::GetRightY() const { + return GetAxis(Axis::RIGHT_Y); +} + +double SteamController::GetLeftTrigger() const { + return GetAxis(Axis::LEFT_TRIGGER); +} + +double SteamController::GetRightTrigger() const { + return GetAxis(Axis::RIGHT_TRIGGER); +} + +double SteamController::GetAxis(Axis axis) const { + return m_hid->GetRawAxis(static_cast(axis)); +} + +BooleanEvent SteamController::AxisLessThan(Axis axis, double threshold, + EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +BooleanEvent SteamController::AxisGreaterThan( + Axis axis, double threshold, EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +bool SteamController::GetAButton() const { + return GetButton(Button::A); +} + +bool SteamController::GetAButtonPressed() { + return GetButtonPressed(Button::A); +} + +bool SteamController::GetAButtonReleased() { + return GetButtonReleased(Button::A); +} + +BooleanEvent SteamController::A(EventLoop* loop) const { + return ButtonEvent(Button::A, loop); +} + +bool SteamController::GetBButton() const { + return GetButton(Button::B); +} + +bool SteamController::GetBButtonPressed() { + return GetButtonPressed(Button::B); +} + +bool SteamController::GetBButtonReleased() { + return GetButtonReleased(Button::B); +} + +BooleanEvent SteamController::B(EventLoop* loop) const { + return ButtonEvent(Button::B, loop); +} + +bool SteamController::GetXButton() const { + return GetButton(Button::X); +} + +bool SteamController::GetXButtonPressed() { + return GetButtonPressed(Button::X); +} + +bool SteamController::GetXButtonReleased() { + return GetButtonReleased(Button::X); +} + +BooleanEvent SteamController::X(EventLoop* loop) const { + return ButtonEvent(Button::X, loop); +} + +bool SteamController::GetYButton() const { + return GetButton(Button::Y); +} + +bool SteamController::GetYButtonPressed() { + return GetButtonPressed(Button::Y); +} + +bool SteamController::GetYButtonReleased() { + return GetButtonReleased(Button::Y); +} + +BooleanEvent SteamController::Y(EventLoop* loop) const { + return ButtonEvent(Button::Y, loop); +} + +bool SteamController::GetMenuButton() const { + return GetButton(Button::MENU); +} + +bool SteamController::GetMenuButtonPressed() { + return GetButtonPressed(Button::MENU); +} + +bool SteamController::GetMenuButtonReleased() { + return GetButtonReleased(Button::MENU); +} + +BooleanEvent SteamController::Menu(EventLoop* loop) const { + return ButtonEvent(Button::MENU, loop); +} + +bool SteamController::GetSteamButton() const { + return GetButton(Button::STEAM); +} + +bool SteamController::GetSteamButtonPressed() { + return GetButtonPressed(Button::STEAM); +} + +bool SteamController::GetSteamButtonReleased() { + return GetButtonReleased(Button::STEAM); +} + +BooleanEvent SteamController::Steam(EventLoop* loop) const { + return ButtonEvent(Button::STEAM, loop); +} + +bool SteamController::GetViewButton() const { + return GetButton(Button::VIEW); +} + +bool SteamController::GetViewButtonPressed() { + return GetButtonPressed(Button::VIEW); +} + +bool SteamController::GetViewButtonReleased() { + return GetButtonReleased(Button::VIEW); +} + +BooleanEvent SteamController::View(EventLoop* loop) const { + return ButtonEvent(Button::VIEW, loop); +} + +bool SteamController::GetLeftStickButton() const { + return GetButton(Button::LEFT_STICK); +} + +bool SteamController::GetLeftStickButtonPressed() { + return GetButtonPressed(Button::LEFT_STICK); +} + +bool SteamController::GetLeftStickButtonReleased() { + return GetButtonReleased(Button::LEFT_STICK); +} + +BooleanEvent SteamController::LeftStick(EventLoop* loop) const { + return ButtonEvent(Button::LEFT_STICK, loop); +} + +bool SteamController::GetRightStickButton() const { + return GetButton(Button::RIGHT_STICK); +} + +bool SteamController::GetRightStickButtonPressed() { + return GetButtonPressed(Button::RIGHT_STICK); +} + +bool SteamController::GetRightStickButtonReleased() { + return GetButtonReleased(Button::RIGHT_STICK); +} + +BooleanEvent SteamController::RightStick(EventLoop* loop) const { + return ButtonEvent(Button::RIGHT_STICK, loop); +} + +bool SteamController::GetLeftBumperButton() const { + return GetButton(Button::LEFT_BUMPER); +} + +bool SteamController::GetLeftBumperButtonPressed() { + return GetButtonPressed(Button::LEFT_BUMPER); +} + +bool SteamController::GetLeftBumperButtonReleased() { + return GetButtonReleased(Button::LEFT_BUMPER); +} + +BooleanEvent SteamController::LeftBumper(EventLoop* loop) const { + return ButtonEvent(Button::LEFT_BUMPER, loop); +} + +bool SteamController::GetRightBumperButton() const { + return GetButton(Button::RIGHT_BUMPER); +} + +bool SteamController::GetRightBumperButtonPressed() { + return GetButtonPressed(Button::RIGHT_BUMPER); +} + +bool SteamController::GetRightBumperButtonReleased() { + return GetButtonReleased(Button::RIGHT_BUMPER); +} + +BooleanEvent SteamController::RightBumper(EventLoop* loop) const { + return ButtonEvent(Button::RIGHT_BUMPER, loop); +} + +bool SteamController::GetDpadUpButton() const { + return GetButton(Button::DPAD_UP); +} + +bool SteamController::GetDpadUpButtonPressed() { + return GetButtonPressed(Button::DPAD_UP); +} + +bool SteamController::GetDpadUpButtonReleased() { + return GetButtonReleased(Button::DPAD_UP); +} + +BooleanEvent SteamController::DpadUp(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_UP, loop); +} + +bool SteamController::GetDpadDownButton() const { + return GetButton(Button::DPAD_DOWN); +} + +bool SteamController::GetDpadDownButtonPressed() { + return GetButtonPressed(Button::DPAD_DOWN); +} + +bool SteamController::GetDpadDownButtonReleased() { + return GetButtonReleased(Button::DPAD_DOWN); +} + +BooleanEvent SteamController::DpadDown(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_DOWN, loop); +} + +bool SteamController::GetDpadLeftButton() const { + return GetButton(Button::DPAD_LEFT); +} + +bool SteamController::GetDpadLeftButtonPressed() { + return GetButtonPressed(Button::DPAD_LEFT); +} + +bool SteamController::GetDpadLeftButtonReleased() { + return GetButtonReleased(Button::DPAD_LEFT); +} + +BooleanEvent SteamController::DpadLeft(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_LEFT, loop); +} + +bool SteamController::GetDpadRightButton() const { + return GetButton(Button::DPAD_RIGHT); +} + +bool SteamController::GetDpadRightButtonPressed() { + return GetButtonPressed(Button::DPAD_RIGHT); +} + +bool SteamController::GetDpadRightButtonReleased() { + return GetButtonReleased(Button::DPAD_RIGHT); +} + +BooleanEvent SteamController::DpadRight(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_RIGHT, loop); +} + +bool SteamController::GetQAMButton() const { + return GetButton(Button::QAM); +} + +bool SteamController::GetQAMButtonPressed() { + return GetButtonPressed(Button::QAM); +} + +bool SteamController::GetQAMButtonReleased() { + return GetButtonReleased(Button::QAM); +} + +BooleanEvent SteamController::QAM(EventLoop* loop) const { + return ButtonEvent(Button::QAM, loop); +} + +bool SteamController::GetRightPaddle1Button() const { + return GetButton(Button::RIGHT_PADDLE_1); +} + +bool SteamController::GetRightPaddle1ButtonPressed() { + return GetButtonPressed(Button::RIGHT_PADDLE_1); +} + +bool SteamController::GetRightPaddle1ButtonReleased() { + return GetButtonReleased(Button::RIGHT_PADDLE_1); +} + +BooleanEvent SteamController::RightPaddle1(EventLoop* loop) const { + return ButtonEvent(Button::RIGHT_PADDLE_1, loop); +} + +bool SteamController::GetLeftPaddle1Button() const { + return GetButton(Button::LEFT_PADDLE_1); +} + +bool SteamController::GetLeftPaddle1ButtonPressed() { + return GetButtonPressed(Button::LEFT_PADDLE_1); +} + +bool SteamController::GetLeftPaddle1ButtonReleased() { + return GetButtonReleased(Button::LEFT_PADDLE_1); +} + +BooleanEvent SteamController::LeftPaddle1(EventLoop* loop) const { + return ButtonEvent(Button::LEFT_PADDLE_1, loop); +} + +bool SteamController::GetRightPaddle2Button() const { + return GetButton(Button::RIGHT_PADDLE_2); +} + +bool SteamController::GetRightPaddle2ButtonPressed() { + return GetButtonPressed(Button::RIGHT_PADDLE_2); +} + +bool SteamController::GetRightPaddle2ButtonReleased() { + return GetButtonReleased(Button::RIGHT_PADDLE_2); +} + +BooleanEvent SteamController::RightPaddle2(EventLoop* loop) const { + return ButtonEvent(Button::RIGHT_PADDLE_2, loop); +} + +bool SteamController::GetLeftPaddle2Button() const { + return GetButton(Button::LEFT_PADDLE_2); +} + +bool SteamController::GetLeftPaddle2ButtonPressed() { + return GetButtonPressed(Button::LEFT_PADDLE_2); +} + +bool SteamController::GetLeftPaddle2ButtonReleased() { + return GetButtonReleased(Button::LEFT_PADDLE_2); +} + +BooleanEvent SteamController::LeftPaddle2(EventLoop* loop) const { + return ButtonEvent(Button::LEFT_PADDLE_2, loop); +} + +bool SteamController::GetLeftTouchpadButton() const { + return GetButton(Button::LEFT_TOUCHPAD); +} + +bool SteamController::GetLeftTouchpadButtonPressed() { + return GetButtonPressed(Button::LEFT_TOUCHPAD); +} + +bool SteamController::GetLeftTouchpadButtonReleased() { + return GetButtonReleased(Button::LEFT_TOUCHPAD); +} + +BooleanEvent SteamController::LeftTouchpad(EventLoop* loop) const { + return ButtonEvent(Button::LEFT_TOUCHPAD, loop); +} + +bool SteamController::GetRightTouchpadButton() const { + return GetButton(Button::RIGHT_TOUCHPAD); +} + +bool SteamController::GetRightTouchpadButtonPressed() { + return GetButtonPressed(Button::RIGHT_TOUCHPAD); +} + +bool SteamController::GetRightTouchpadButtonReleased() { + return GetButtonReleased(Button::RIGHT_TOUCHPAD); +} + +BooleanEvent SteamController::RightTouchpad(EventLoop* loop) const { + return ButtonEvent(Button::RIGHT_TOUCHPAD, loop); +} + +bool SteamController::GetLeftStickTouchButton() const { + return GetButton(Button::LEFT_STICK_TOUCH); +} + +bool SteamController::GetLeftStickTouchButtonPressed() { + return GetButtonPressed(Button::LEFT_STICK_TOUCH); +} + +bool SteamController::GetLeftStickTouchButtonReleased() { + return GetButtonReleased(Button::LEFT_STICK_TOUCH); +} + +BooleanEvent SteamController::LeftStickTouch(EventLoop* loop) const { + return ButtonEvent(Button::LEFT_STICK_TOUCH, loop); +} + +bool SteamController::GetRightStickTouchButton() const { + return GetButton(Button::RIGHT_STICK_TOUCH); +} + +bool SteamController::GetRightStickTouchButtonPressed() { + return GetButtonPressed(Button::RIGHT_STICK_TOUCH); +} + +bool SteamController::GetRightStickTouchButtonReleased() { + return GetButtonReleased(Button::RIGHT_STICK_TOUCH); +} + +BooleanEvent SteamController::RightStickTouch(EventLoop* loop) const { + return ButtonEvent(Button::RIGHT_STICK_TOUCH, loop); +} + +bool SteamController::GetLeftGripTouchButton() const { + return GetButton(Button::LEFT_GRIP_TOUCH); +} + +bool SteamController::GetLeftGripTouchButtonPressed() { + return GetButtonPressed(Button::LEFT_GRIP_TOUCH); +} + +bool SteamController::GetLeftGripTouchButtonReleased() { + return GetButtonReleased(Button::LEFT_GRIP_TOUCH); +} + +BooleanEvent SteamController::LeftGripTouch(EventLoop* loop) const { + return ButtonEvent(Button::LEFT_GRIP_TOUCH, loop); +} + +bool SteamController::GetRightGripTouchButton() const { + return GetButton(Button::RIGHT_GRIP_TOUCH); +} + +bool SteamController::GetRightGripTouchButtonPressed() { + return GetButtonPressed(Button::RIGHT_GRIP_TOUCH); +} + +bool SteamController::GetRightGripTouchButtonReleased() { + return GetButtonReleased(Button::RIGHT_GRIP_TOUCH); +} + +BooleanEvent SteamController::RightGripTouch(EventLoop* loop) const { + return ButtonEvent(Button::RIGHT_GRIP_TOUCH, loop); +} + +bool SteamController::GetButton(Button button) const { + return m_hid->GetRawButton(static_cast(button)); +} + +bool SteamController::GetButtonPressed(Button button) { + return m_hid->GetRawButtonPressed(static_cast(button)); +} + +bool SteamController::GetButtonReleased(Button button) { + return m_hid->GetRawButtonReleased(static_cast(button)); +} + +BooleanEvent SteamController::ButtonEvent(Button button, + EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + +void SteamController::SetLeds(int r, int g, int b) { + m_hid->SetLeds(r, g, b); +} + +void SteamController::SetRumble(GenericHID::RumbleType type, + double value) { + m_hid->SetRumble(type, value); +} + + +bool SteamController::GetTouchpadFingerAvailable(int touchpad, + int finger) const { + return m_hid->GetTouchpadFingerAvailable(touchpad, finger); +} + +TouchpadFinger SteamController::GetTouchpadFinger(int touchpad, + int finger) const { + return m_hid->GetTouchpadFinger(touchpad, finger); +} + + +void SteamController::InitSendable(wpi::util::SendableBuilder& builder) { + builder.SetSmartDashboardType("HID"); + builder.PublishConstString("ControllerType", "Steam"); + builder.AddDoubleProperty("LeftX", [this] { return GetLeftX(); }, nullptr); + builder.AddDoubleProperty("LeftY", [this] { return GetLeftY(); }, nullptr); + builder.AddDoubleProperty("RightX", [this] { return GetRightX(); }, nullptr); + builder.AddDoubleProperty("RightY", [this] { return GetRightY(); }, nullptr); + builder.AddDoubleProperty("LeftTrigger", [this] { return GetLeftTrigger(); }, nullptr); + builder.AddDoubleProperty("RightTrigger", [this] { return GetRightTrigger(); }, nullptr); + builder.AddBooleanProperty("A", [this] { return GetAButton(); }, nullptr); + builder.AddBooleanProperty("B", [this] { return GetBButton(); }, nullptr); + builder.AddBooleanProperty("X", [this] { return GetXButton(); }, nullptr); + builder.AddBooleanProperty("Y", [this] { return GetYButton(); }, nullptr); + builder.AddBooleanProperty("Menu", [this] { return GetMenuButton(); }, nullptr); + builder.AddBooleanProperty("Steam", [this] { return GetSteamButton(); }, nullptr); + builder.AddBooleanProperty("View", [this] { return GetViewButton(); }, nullptr); + builder.AddBooleanProperty("LeftStick", [this] { return GetLeftStickButton(); }, nullptr); + builder.AddBooleanProperty("RightStick", [this] { return GetRightStickButton(); }, nullptr); + builder.AddBooleanProperty("LeftBumper", [this] { return GetLeftBumperButton(); }, nullptr); + builder.AddBooleanProperty("RightBumper", [this] { return GetRightBumperButton(); }, nullptr); + builder.AddBooleanProperty("DpadUp", [this] { return GetDpadUpButton(); }, nullptr); + builder.AddBooleanProperty("DpadDown", [this] { return GetDpadDownButton(); }, nullptr); + builder.AddBooleanProperty("DpadLeft", [this] { return GetDpadLeftButton(); }, nullptr); + builder.AddBooleanProperty("DpadRight", [this] { return GetDpadRightButton(); }, nullptr); + builder.AddBooleanProperty("QAM", [this] { return GetQAMButton(); }, nullptr); + builder.AddBooleanProperty("RightPaddle1", [this] { return GetRightPaddle1Button(); }, nullptr); + builder.AddBooleanProperty("LeftPaddle1", [this] { return GetLeftPaddle1Button(); }, nullptr); + builder.AddBooleanProperty("RightPaddle2", [this] { return GetRightPaddle2Button(); }, nullptr); + builder.AddBooleanProperty("LeftPaddle2", [this] { return GetLeftPaddle2Button(); }, nullptr); + builder.AddBooleanProperty("LeftTouchpad", [this] { return GetLeftTouchpadButton(); }, nullptr); + builder.AddBooleanProperty("RightTouchpad", [this] { return GetRightTouchpadButton(); }, nullptr); + builder.AddBooleanProperty("LeftStickTouch", [this] { return GetLeftStickTouchButton(); }, nullptr); + builder.AddBooleanProperty("RightStickTouch", [this] { return GetRightStickTouchButton(); }, nullptr); + builder.AddBooleanProperty("LeftGripTouch", [this] { return GetLeftGripTouchButton(); }, nullptr); + builder.AddBooleanProperty("RightGripTouch", [this] { return GetRightGripTouchButton(); }, nullptr); +} diff --git a/wpilibc/src/generated/main/native/cpp/driverstation/Switch2GCController.cpp b/wpilibc/src/generated/main/native/cpp/driverstation/Switch2GCController.cpp new file mode 100644 index 0000000000..37241bee03 --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/driverstation/Switch2GCController.cpp @@ -0,0 +1,386 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/Switch2GCController.hpp" + +#include "wpi/driverstation/DriverStation.hpp" +#include "wpi/event/BooleanEvent.hpp" +#include "wpi/hal/UsageReporting.hpp" +#include "wpi/util/sendable/SendableBuilder.hpp" + +using namespace wpi; + +Switch2GCController::Switch2GCController(int port) + : Switch2GCController{DriverStation::GetGenericHID(port)} {} + +Switch2GCController::Switch2GCController(GenericHID& hid) + : m_hid{&hid} { + HAL_ReportUsage("HID", hid.GetPort(), "Switch2GCController"); +} + +GenericHID& Switch2GCController::GetHID() { + return *m_hid; +} + +const GenericHID& Switch2GCController::GetHID() const { + return *m_hid; +} + +int Switch2GCController::GetPort() const { + return m_hid->GetPort(); +} + +bool Switch2GCController::IsConnected() const { + return m_hid->IsConnected(); +} + +double Switch2GCController::GetLeftX() const { + return GetAxis(Axis::LEFT_X); +} + +double Switch2GCController::GetLeftY() const { + return GetAxis(Axis::LEFT_Y); +} + +double Switch2GCController::GetCStickX() const { + return GetAxis(Axis::C_STICK_X); +} + +double Switch2GCController::GetCStickY() const { + return GetAxis(Axis::C_STICK_Y); +} + +double Switch2GCController::GetLTrigger() const { + return GetAxis(Axis::L_TRIGGER); +} + +double Switch2GCController::GetRTrigger() const { + return GetAxis(Axis::R_TRIGGER); +} + +double Switch2GCController::GetAxis(Axis axis) const { + return m_hid->GetRawAxis(static_cast(axis)); +} + +BooleanEvent Switch2GCController::AxisLessThan(Axis axis, double threshold, + EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +BooleanEvent Switch2GCController::AxisGreaterThan( + Axis axis, double threshold, EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +bool Switch2GCController::GetAButton() const { + return GetButton(Button::A); +} + +bool Switch2GCController::GetAButtonPressed() { + return GetButtonPressed(Button::A); +} + +bool Switch2GCController::GetAButtonReleased() { + return GetButtonReleased(Button::A); +} + +BooleanEvent Switch2GCController::A(EventLoop* loop) const { + return ButtonEvent(Button::A, loop); +} + +bool Switch2GCController::GetXButton() const { + return GetButton(Button::X); +} + +bool Switch2GCController::GetXButtonPressed() { + return GetButtonPressed(Button::X); +} + +bool Switch2GCController::GetXButtonReleased() { + return GetButtonReleased(Button::X); +} + +BooleanEvent Switch2GCController::X(EventLoop* loop) const { + return ButtonEvent(Button::X, loop); +} + +bool Switch2GCController::GetBButton() const { + return GetButton(Button::B); +} + +bool Switch2GCController::GetBButtonPressed() { + return GetButtonPressed(Button::B); +} + +bool Switch2GCController::GetBButtonReleased() { + return GetButtonReleased(Button::B); +} + +BooleanEvent Switch2GCController::B(EventLoop* loop) const { + return ButtonEvent(Button::B, loop); +} + +bool Switch2GCController::GetYButton() const { + return GetButton(Button::Y); +} + +bool Switch2GCController::GetYButtonPressed() { + return GetButtonPressed(Button::Y); +} + +bool Switch2GCController::GetYButtonReleased() { + return GetButtonReleased(Button::Y); +} + +BooleanEvent Switch2GCController::Y(EventLoop* loop) const { + return ButtonEvent(Button::Y, loop); +} + +bool Switch2GCController::GetHomeButton() const { + return GetButton(Button::HOME); +} + +bool Switch2GCController::GetHomeButtonPressed() { + return GetButtonPressed(Button::HOME); +} + +bool Switch2GCController::GetHomeButtonReleased() { + return GetButtonReleased(Button::HOME); +} + +BooleanEvent Switch2GCController::Home(EventLoop* loop) const { + return ButtonEvent(Button::HOME, loop); +} + +bool Switch2GCController::GetStartButton() const { + return GetButton(Button::START); +} + +bool Switch2GCController::GetStartButtonPressed() { + return GetButtonPressed(Button::START); +} + +bool Switch2GCController::GetStartButtonReleased() { + return GetButtonReleased(Button::START); +} + +BooleanEvent Switch2GCController::Start(EventLoop* loop) const { + return ButtonEvent(Button::START, loop); +} + +bool Switch2GCController::GetZLButton() const { + return GetButton(Button::ZL); +} + +bool Switch2GCController::GetZLButtonPressed() { + return GetButtonPressed(Button::ZL); +} + +bool Switch2GCController::GetZLButtonReleased() { + return GetButtonReleased(Button::ZL); +} + +BooleanEvent Switch2GCController::ZL(EventLoop* loop) const { + return ButtonEvent(Button::ZL, loop); +} + +bool Switch2GCController::GetZButton() const { + return GetButton(Button::Z); +} + +bool Switch2GCController::GetZButtonPressed() { + return GetButtonPressed(Button::Z); +} + +bool Switch2GCController::GetZButtonReleased() { + return GetButtonReleased(Button::Z); +} + +BooleanEvent Switch2GCController::Z(EventLoop* loop) const { + return ButtonEvent(Button::Z, loop); +} + +bool Switch2GCController::GetDpadUpButton() const { + return GetButton(Button::DPAD_UP); +} + +bool Switch2GCController::GetDpadUpButtonPressed() { + return GetButtonPressed(Button::DPAD_UP); +} + +bool Switch2GCController::GetDpadUpButtonReleased() { + return GetButtonReleased(Button::DPAD_UP); +} + +BooleanEvent Switch2GCController::DpadUp(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_UP, loop); +} + +bool Switch2GCController::GetDpadDownButton() const { + return GetButton(Button::DPAD_DOWN); +} + +bool Switch2GCController::GetDpadDownButtonPressed() { + return GetButtonPressed(Button::DPAD_DOWN); +} + +bool Switch2GCController::GetDpadDownButtonReleased() { + return GetButtonReleased(Button::DPAD_DOWN); +} + +BooleanEvent Switch2GCController::DpadDown(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_DOWN, loop); +} + +bool Switch2GCController::GetDpadLeftButton() const { + return GetButton(Button::DPAD_LEFT); +} + +bool Switch2GCController::GetDpadLeftButtonPressed() { + return GetButtonPressed(Button::DPAD_LEFT); +} + +bool Switch2GCController::GetDpadLeftButtonReleased() { + return GetButtonReleased(Button::DPAD_LEFT); +} + +BooleanEvent Switch2GCController::DpadLeft(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_LEFT, loop); +} + +bool Switch2GCController::GetDpadRightButton() const { + return GetButton(Button::DPAD_RIGHT); +} + +bool Switch2GCController::GetDpadRightButtonPressed() { + return GetButtonPressed(Button::DPAD_RIGHT); +} + +bool Switch2GCController::GetDpadRightButtonReleased() { + return GetButtonReleased(Button::DPAD_RIGHT); +} + +BooleanEvent Switch2GCController::DpadRight(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_RIGHT, loop); +} + +bool Switch2GCController::GetCaptureButton() const { + return GetButton(Button::CAPTURE); +} + +bool Switch2GCController::GetCaptureButtonPressed() { + return GetButtonPressed(Button::CAPTURE); +} + +bool Switch2GCController::GetCaptureButtonReleased() { + return GetButtonReleased(Button::CAPTURE); +} + +BooleanEvent Switch2GCController::Capture(EventLoop* loop) const { + return ButtonEvent(Button::CAPTURE, loop); +} + +bool Switch2GCController::GetCButton() const { + return GetButton(Button::C); +} + +bool Switch2GCController::GetCButtonPressed() { + return GetButtonPressed(Button::C); +} + +bool Switch2GCController::GetCButtonReleased() { + return GetButtonReleased(Button::C); +} + +BooleanEvent Switch2GCController::C(EventLoop* loop) const { + return ButtonEvent(Button::C, loop); +} + +bool Switch2GCController::GetLButton() const { + return GetButton(Button::L); +} + +bool Switch2GCController::GetLButtonPressed() { + return GetButtonPressed(Button::L); +} + +bool Switch2GCController::GetLButtonReleased() { + return GetButtonReleased(Button::L); +} + +BooleanEvent Switch2GCController::L(EventLoop* loop) const { + return ButtonEvent(Button::L, loop); +} + +bool Switch2GCController::GetRButton() const { + return GetButton(Button::R); +} + +bool Switch2GCController::GetRButtonPressed() { + return GetButtonPressed(Button::R); +} + +bool Switch2GCController::GetRButtonReleased() { + return GetButtonReleased(Button::R); +} + +BooleanEvent Switch2GCController::R(EventLoop* loop) const { + return ButtonEvent(Button::R, loop); +} + +bool Switch2GCController::GetButton(Button button) const { + return m_hid->GetRawButton(static_cast(button)); +} + +bool Switch2GCController::GetButtonPressed(Button button) { + return m_hid->GetRawButtonPressed(static_cast(button)); +} + +bool Switch2GCController::GetButtonReleased(Button button) { + return m_hid->GetRawButtonReleased(static_cast(button)); +} + +BooleanEvent Switch2GCController::ButtonEvent(Button button, + EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + +void Switch2GCController::SetLeds(int r, int g, int b) { + m_hid->SetLeds(r, g, b); +} + +void Switch2GCController::SetRumble(GenericHID::RumbleType type, + double value) { + m_hid->SetRumble(type, value); +} + + + +void Switch2GCController::InitSendable(wpi::util::SendableBuilder& builder) { + builder.SetSmartDashboardType("HID"); + builder.PublishConstString("ControllerType", "Switch2GC"); + builder.AddDoubleProperty("LeftX", [this] { return GetLeftX(); }, nullptr); + builder.AddDoubleProperty("LeftY", [this] { return GetLeftY(); }, nullptr); + builder.AddDoubleProperty("CStickX", [this] { return GetCStickX(); }, nullptr); + builder.AddDoubleProperty("CStickY", [this] { return GetCStickY(); }, nullptr); + builder.AddDoubleProperty("LTrigger", [this] { return GetLTrigger(); }, nullptr); + builder.AddDoubleProperty("RTrigger", [this] { return GetRTrigger(); }, nullptr); + builder.AddBooleanProperty("A", [this] { return GetAButton(); }, nullptr); + builder.AddBooleanProperty("X", [this] { return GetXButton(); }, nullptr); + builder.AddBooleanProperty("B", [this] { return GetBButton(); }, nullptr); + builder.AddBooleanProperty("Y", [this] { return GetYButton(); }, nullptr); + builder.AddBooleanProperty("Home", [this] { return GetHomeButton(); }, nullptr); + builder.AddBooleanProperty("Start", [this] { return GetStartButton(); }, nullptr); + builder.AddBooleanProperty("ZL", [this] { return GetZLButton(); }, nullptr); + builder.AddBooleanProperty("Z", [this] { return GetZButton(); }, nullptr); + builder.AddBooleanProperty("DpadUp", [this] { return GetDpadUpButton(); }, nullptr); + builder.AddBooleanProperty("DpadDown", [this] { return GetDpadDownButton(); }, nullptr); + builder.AddBooleanProperty("DpadLeft", [this] { return GetDpadLeftButton(); }, nullptr); + builder.AddBooleanProperty("DpadRight", [this] { return GetDpadRightButton(); }, nullptr); + builder.AddBooleanProperty("Capture", [this] { return GetCaptureButton(); }, nullptr); + builder.AddBooleanProperty("C", [this] { return GetCButton(); }, nullptr); + builder.AddBooleanProperty("L", [this] { return GetLButton(); }, nullptr); + builder.AddBooleanProperty("R", [this] { return GetRButton(); }, nullptr); +} diff --git a/wpilibc/src/generated/main/native/cpp/driverstation/Switch2ProController.cpp b/wpilibc/src/generated/main/native/cpp/driverstation/Switch2ProController.cpp new file mode 100644 index 0000000000..7eb5282074 --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/driverstation/Switch2ProController.cpp @@ -0,0 +1,437 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/Switch2ProController.hpp" + +#include "wpi/driverstation/DriverStation.hpp" +#include "wpi/event/BooleanEvent.hpp" +#include "wpi/hal/UsageReporting.hpp" +#include "wpi/util/sendable/SendableBuilder.hpp" + +using namespace wpi; + +Switch2ProController::Switch2ProController(int port) + : Switch2ProController{DriverStation::GetGenericHID(port)} {} + +Switch2ProController::Switch2ProController(GenericHID& hid) + : m_hid{&hid} { + HAL_ReportUsage("HID", hid.GetPort(), "Switch2ProController"); +} + +GenericHID& Switch2ProController::GetHID() { + return *m_hid; +} + +const GenericHID& Switch2ProController::GetHID() const { + return *m_hid; +} + +int Switch2ProController::GetPort() const { + return m_hid->GetPort(); +} + +bool Switch2ProController::IsConnected() const { + return m_hid->IsConnected(); +} + +double Switch2ProController::GetLeftX() const { + return GetAxis(Axis::LEFT_X); +} + +double Switch2ProController::GetLeftY() const { + return GetAxis(Axis::LEFT_Y); +} + +double Switch2ProController::GetRightX() const { + return GetAxis(Axis::RIGHT_X); +} + +double Switch2ProController::GetRightY() const { + return GetAxis(Axis::RIGHT_Y); +} + +double Switch2ProController::GetZL() const { + return GetAxis(Axis::ZL); +} + +double Switch2ProController::GetZR() const { + return GetAxis(Axis::ZR); +} + +double Switch2ProController::GetAxis(Axis axis) const { + return m_hid->GetRawAxis(static_cast(axis)); +} + +BooleanEvent Switch2ProController::AxisLessThan(Axis axis, double threshold, + EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +BooleanEvent Switch2ProController::AxisGreaterThan( + Axis axis, double threshold, EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +bool Switch2ProController::GetBButton() const { + return GetButton(Button::B); +} + +bool Switch2ProController::GetBButtonPressed() { + return GetButtonPressed(Button::B); +} + +bool Switch2ProController::GetBButtonReleased() { + return GetButtonReleased(Button::B); +} + +BooleanEvent Switch2ProController::B(EventLoop* loop) const { + return ButtonEvent(Button::B, loop); +} + +bool Switch2ProController::GetAButton() const { + return GetButton(Button::A); +} + +bool Switch2ProController::GetAButtonPressed() { + return GetButtonPressed(Button::A); +} + +bool Switch2ProController::GetAButtonReleased() { + return GetButtonReleased(Button::A); +} + +BooleanEvent Switch2ProController::A(EventLoop* loop) const { + return ButtonEvent(Button::A, loop); +} + +bool Switch2ProController::GetYButton() const { + return GetButton(Button::Y); +} + +bool Switch2ProController::GetYButtonPressed() { + return GetButtonPressed(Button::Y); +} + +bool Switch2ProController::GetYButtonReleased() { + return GetButtonReleased(Button::Y); +} + +BooleanEvent Switch2ProController::Y(EventLoop* loop) const { + return ButtonEvent(Button::Y, loop); +} + +bool Switch2ProController::GetXButton() const { + return GetButton(Button::X); +} + +bool Switch2ProController::GetXButtonPressed() { + return GetButtonPressed(Button::X); +} + +bool Switch2ProController::GetXButtonReleased() { + return GetButtonReleased(Button::X); +} + +BooleanEvent Switch2ProController::X(EventLoop* loop) const { + return ButtonEvent(Button::X, loop); +} + +bool Switch2ProController::GetMinusButton() const { + return GetButton(Button::MINUS); +} + +bool Switch2ProController::GetMinusButtonPressed() { + return GetButtonPressed(Button::MINUS); +} + +bool Switch2ProController::GetMinusButtonReleased() { + return GetButtonReleased(Button::MINUS); +} + +BooleanEvent Switch2ProController::Minus(EventLoop* loop) const { + return ButtonEvent(Button::MINUS, loop); +} + +bool Switch2ProController::GetHomeButton() const { + return GetButton(Button::HOME); +} + +bool Switch2ProController::GetHomeButtonPressed() { + return GetButtonPressed(Button::HOME); +} + +bool Switch2ProController::GetHomeButtonReleased() { + return GetButtonReleased(Button::HOME); +} + +BooleanEvent Switch2ProController::Home(EventLoop* loop) const { + return ButtonEvent(Button::HOME, loop); +} + +bool Switch2ProController::GetPlusButton() const { + return GetButton(Button::PLUS); +} + +bool Switch2ProController::GetPlusButtonPressed() { + return GetButtonPressed(Button::PLUS); +} + +bool Switch2ProController::GetPlusButtonReleased() { + return GetButtonReleased(Button::PLUS); +} + +BooleanEvent Switch2ProController::Plus(EventLoop* loop) const { + return ButtonEvent(Button::PLUS, loop); +} + +bool Switch2ProController::GetLeftStickButton() const { + return GetButton(Button::LEFT_STICK); +} + +bool Switch2ProController::GetLeftStickButtonPressed() { + return GetButtonPressed(Button::LEFT_STICK); +} + +bool Switch2ProController::GetLeftStickButtonReleased() { + return GetButtonReleased(Button::LEFT_STICK); +} + +BooleanEvent Switch2ProController::LeftStick(EventLoop* loop) const { + return ButtonEvent(Button::LEFT_STICK, loop); +} + +bool Switch2ProController::GetRightStickButton() const { + return GetButton(Button::RIGHT_STICK); +} + +bool Switch2ProController::GetRightStickButtonPressed() { + return GetButtonPressed(Button::RIGHT_STICK); +} + +bool Switch2ProController::GetRightStickButtonReleased() { + return GetButtonReleased(Button::RIGHT_STICK); +} + +BooleanEvent Switch2ProController::RightStick(EventLoop* loop) const { + return ButtonEvent(Button::RIGHT_STICK, loop); +} + +bool Switch2ProController::GetLButton() const { + return GetButton(Button::L); +} + +bool Switch2ProController::GetLButtonPressed() { + return GetButtonPressed(Button::L); +} + +bool Switch2ProController::GetLButtonReleased() { + return GetButtonReleased(Button::L); +} + +BooleanEvent Switch2ProController::L(EventLoop* loop) const { + return ButtonEvent(Button::L, loop); +} + +bool Switch2ProController::GetRButton() const { + return GetButton(Button::R); +} + +bool Switch2ProController::GetRButtonPressed() { + return GetButtonPressed(Button::R); +} + +bool Switch2ProController::GetRButtonReleased() { + return GetButtonReleased(Button::R); +} + +BooleanEvent Switch2ProController::R(EventLoop* loop) const { + return ButtonEvent(Button::R, loop); +} + +bool Switch2ProController::GetDpadUpButton() const { + return GetButton(Button::DPAD_UP); +} + +bool Switch2ProController::GetDpadUpButtonPressed() { + return GetButtonPressed(Button::DPAD_UP); +} + +bool Switch2ProController::GetDpadUpButtonReleased() { + return GetButtonReleased(Button::DPAD_UP); +} + +BooleanEvent Switch2ProController::DpadUp(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_UP, loop); +} + +bool Switch2ProController::GetDpadDownButton() const { + return GetButton(Button::DPAD_DOWN); +} + +bool Switch2ProController::GetDpadDownButtonPressed() { + return GetButtonPressed(Button::DPAD_DOWN); +} + +bool Switch2ProController::GetDpadDownButtonReleased() { + return GetButtonReleased(Button::DPAD_DOWN); +} + +BooleanEvent Switch2ProController::DpadDown(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_DOWN, loop); +} + +bool Switch2ProController::GetDpadLeftButton() const { + return GetButton(Button::DPAD_LEFT); +} + +bool Switch2ProController::GetDpadLeftButtonPressed() { + return GetButtonPressed(Button::DPAD_LEFT); +} + +bool Switch2ProController::GetDpadLeftButtonReleased() { + return GetButtonReleased(Button::DPAD_LEFT); +} + +BooleanEvent Switch2ProController::DpadLeft(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_LEFT, loop); +} + +bool Switch2ProController::GetDpadRightButton() const { + return GetButton(Button::DPAD_RIGHT); +} + +bool Switch2ProController::GetDpadRightButtonPressed() { + return GetButtonPressed(Button::DPAD_RIGHT); +} + +bool Switch2ProController::GetDpadRightButtonReleased() { + return GetButtonReleased(Button::DPAD_RIGHT); +} + +BooleanEvent Switch2ProController::DpadRight(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_RIGHT, loop); +} + +bool Switch2ProController::GetCaptureButton() const { + return GetButton(Button::CAPTURE); +} + +bool Switch2ProController::GetCaptureButtonPressed() { + return GetButtonPressed(Button::CAPTURE); +} + +bool Switch2ProController::GetCaptureButtonReleased() { + return GetButtonReleased(Button::CAPTURE); +} + +BooleanEvent Switch2ProController::Capture(EventLoop* loop) const { + return ButtonEvent(Button::CAPTURE, loop); +} + +bool Switch2ProController::GetGRButton() const { + return GetButton(Button::GR); +} + +bool Switch2ProController::GetGRButtonPressed() { + return GetButtonPressed(Button::GR); +} + +bool Switch2ProController::GetGRButtonReleased() { + return GetButtonReleased(Button::GR); +} + +BooleanEvent Switch2ProController::GR(EventLoop* loop) const { + return ButtonEvent(Button::GR, loop); +} + +bool Switch2ProController::GetGLButton() const { + return GetButton(Button::GL); +} + +bool Switch2ProController::GetGLButtonPressed() { + return GetButtonPressed(Button::GL); +} + +bool Switch2ProController::GetGLButtonReleased() { + return GetButtonReleased(Button::GL); +} + +BooleanEvent Switch2ProController::GL(EventLoop* loop) const { + return ButtonEvent(Button::GL, loop); +} + +bool Switch2ProController::GetCButton() const { + return GetButton(Button::C); +} + +bool Switch2ProController::GetCButtonPressed() { + return GetButtonPressed(Button::C); +} + +bool Switch2ProController::GetCButtonReleased() { + return GetButtonReleased(Button::C); +} + +BooleanEvent Switch2ProController::C(EventLoop* loop) const { + return ButtonEvent(Button::C, loop); +} + +bool Switch2ProController::GetButton(Button button) const { + return m_hid->GetRawButton(static_cast(button)); +} + +bool Switch2ProController::GetButtonPressed(Button button) { + return m_hid->GetRawButtonPressed(static_cast(button)); +} + +bool Switch2ProController::GetButtonReleased(Button button) { + return m_hid->GetRawButtonReleased(static_cast(button)); +} + +BooleanEvent Switch2ProController::ButtonEvent(Button button, + EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + +void Switch2ProController::SetLeds(int r, int g, int b) { + m_hid->SetLeds(r, g, b); +} + +void Switch2ProController::SetRumble(GenericHID::RumbleType type, + double value) { + m_hid->SetRumble(type, value); +} + + + +void Switch2ProController::InitSendable(wpi::util::SendableBuilder& builder) { + builder.SetSmartDashboardType("HID"); + builder.PublishConstString("ControllerType", "Switch2Pro"); + builder.AddDoubleProperty("LeftX", [this] { return GetLeftX(); }, nullptr); + builder.AddDoubleProperty("LeftY", [this] { return GetLeftY(); }, nullptr); + builder.AddDoubleProperty("RightX", [this] { return GetRightX(); }, nullptr); + builder.AddDoubleProperty("RightY", [this] { return GetRightY(); }, nullptr); + builder.AddDoubleProperty("ZL", [this] { return GetZL(); }, nullptr); + builder.AddDoubleProperty("ZR", [this] { return GetZR(); }, nullptr); + builder.AddBooleanProperty("B", [this] { return GetBButton(); }, nullptr); + builder.AddBooleanProperty("A", [this] { return GetAButton(); }, nullptr); + builder.AddBooleanProperty("Y", [this] { return GetYButton(); }, nullptr); + builder.AddBooleanProperty("X", [this] { return GetXButton(); }, nullptr); + builder.AddBooleanProperty("Minus", [this] { return GetMinusButton(); }, nullptr); + builder.AddBooleanProperty("Home", [this] { return GetHomeButton(); }, nullptr); + builder.AddBooleanProperty("Plus", [this] { return GetPlusButton(); }, nullptr); + builder.AddBooleanProperty("LeftStick", [this] { return GetLeftStickButton(); }, nullptr); + builder.AddBooleanProperty("RightStick", [this] { return GetRightStickButton(); }, nullptr); + builder.AddBooleanProperty("L", [this] { return GetLButton(); }, nullptr); + builder.AddBooleanProperty("R", [this] { return GetRButton(); }, nullptr); + builder.AddBooleanProperty("DpadUp", [this] { return GetDpadUpButton(); }, nullptr); + builder.AddBooleanProperty("DpadDown", [this] { return GetDpadDownButton(); }, nullptr); + builder.AddBooleanProperty("DpadLeft", [this] { return GetDpadLeftButton(); }, nullptr); + builder.AddBooleanProperty("DpadRight", [this] { return GetDpadRightButton(); }, nullptr); + builder.AddBooleanProperty("Capture", [this] { return GetCaptureButton(); }, nullptr); + builder.AddBooleanProperty("GR", [this] { return GetGRButton(); }, nullptr); + builder.AddBooleanProperty("GL", [this] { return GetGLButton(); }, nullptr); + builder.AddBooleanProperty("C", [this] { return GetCButton(); }, nullptr); +} diff --git a/wpilibc/src/generated/main/native/cpp/driverstation/SwitchN64Controller.cpp b/wpilibc/src/generated/main/native/cpp/driverstation/SwitchN64Controller.cpp new file mode 100644 index 0000000000..5baec64326 --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/driverstation/SwitchN64Controller.cpp @@ -0,0 +1,359 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/SwitchN64Controller.hpp" + +#include "wpi/driverstation/DriverStation.hpp" +#include "wpi/event/BooleanEvent.hpp" +#include "wpi/hal/UsageReporting.hpp" +#include "wpi/util/sendable/SendableBuilder.hpp" + +using namespace wpi; + +SwitchN64Controller::SwitchN64Controller(int port) + : SwitchN64Controller{DriverStation::GetGenericHID(port)} {} + +SwitchN64Controller::SwitchN64Controller(GenericHID& hid) + : m_hid{&hid} { + HAL_ReportUsage("HID", hid.GetPort(), "SwitchN64Controller"); +} + +GenericHID& SwitchN64Controller::GetHID() { + return *m_hid; +} + +const GenericHID& SwitchN64Controller::GetHID() const { + return *m_hid; +} + +int SwitchN64Controller::GetPort() const { + return m_hid->GetPort(); +} + +bool SwitchN64Controller::IsConnected() const { + return m_hid->IsConnected(); +} + +double SwitchN64Controller::GetLeftX() const { + return GetAxis(Axis::LEFT_X); +} + +double SwitchN64Controller::GetLeftY() const { + return GetAxis(Axis::LEFT_Y); +} + +double SwitchN64Controller::GetZAxis() const { + return GetAxis(Axis::Z_AXIS); +} + +double SwitchN64Controller::GetZR() const { + return GetAxis(Axis::ZR); +} + +double SwitchN64Controller::GetAxis(Axis axis) const { + return m_hid->GetRawAxis(static_cast(axis)); +} + +BooleanEvent SwitchN64Controller::AxisLessThan(Axis axis, double threshold, + EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +BooleanEvent SwitchN64Controller::AxisGreaterThan( + Axis axis, double threshold, EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +bool SwitchN64Controller::GetAButton() const { + return GetButton(Button::A); +} + +bool SwitchN64Controller::GetAButtonPressed() { + return GetButtonPressed(Button::A); +} + +bool SwitchN64Controller::GetAButtonReleased() { + return GetButtonReleased(Button::A); +} + +BooleanEvent SwitchN64Controller::A(EventLoop* loop) const { + return ButtonEvent(Button::A, loop); +} + +bool SwitchN64Controller::GetBButton() const { + return GetButton(Button::B); +} + +bool SwitchN64Controller::GetBButtonPressed() { + return GetButtonPressed(Button::B); +} + +bool SwitchN64Controller::GetBButtonReleased() { + return GetButtonReleased(Button::B); +} + +BooleanEvent SwitchN64Controller::B(EventLoop* loop) const { + return ButtonEvent(Button::B, loop); +} + +bool SwitchN64Controller::GetCLeftButton() const { + return GetButton(Button::C_LEFT); +} + +bool SwitchN64Controller::GetCLeftButtonPressed() { + return GetButtonPressed(Button::C_LEFT); +} + +bool SwitchN64Controller::GetCLeftButtonReleased() { + return GetButtonReleased(Button::C_LEFT); +} + +BooleanEvent SwitchN64Controller::CLeft(EventLoop* loop) const { + return ButtonEvent(Button::C_LEFT, loop); +} + +bool SwitchN64Controller::GetCUpButton() const { + return GetButton(Button::C_UP); +} + +bool SwitchN64Controller::GetCUpButtonPressed() { + return GetButtonPressed(Button::C_UP); +} + +bool SwitchN64Controller::GetCUpButtonReleased() { + return GetButtonReleased(Button::C_UP); +} + +BooleanEvent SwitchN64Controller::CUp(EventLoop* loop) const { + return ButtonEvent(Button::C_UP, loop); +} + +bool SwitchN64Controller::GetCaptureButton() const { + return GetButton(Button::CAPTURE); +} + +bool SwitchN64Controller::GetCaptureButtonPressed() { + return GetButtonPressed(Button::CAPTURE); +} + +bool SwitchN64Controller::GetCaptureButtonReleased() { + return GetButtonReleased(Button::CAPTURE); +} + +BooleanEvent SwitchN64Controller::Capture(EventLoop* loop) const { + return ButtonEvent(Button::CAPTURE, loop); +} + +bool SwitchN64Controller::GetHomeButton() const { + return GetButton(Button::HOME); +} + +bool SwitchN64Controller::GetHomeButtonPressed() { + return GetButtonPressed(Button::HOME); +} + +bool SwitchN64Controller::GetHomeButtonReleased() { + return GetButtonReleased(Button::HOME); +} + +BooleanEvent SwitchN64Controller::Home(EventLoop* loop) const { + return ButtonEvent(Button::HOME, loop); +} + +bool SwitchN64Controller::GetStartButton() const { + return GetButton(Button::START); +} + +bool SwitchN64Controller::GetStartButtonPressed() { + return GetButtonPressed(Button::START); +} + +bool SwitchN64Controller::GetStartButtonReleased() { + return GetButtonReleased(Button::START); +} + +BooleanEvent SwitchN64Controller::Start(EventLoop* loop) const { + return ButtonEvent(Button::START, loop); +} + +bool SwitchN64Controller::GetCDownButton() const { + return GetButton(Button::C_DOWN); +} + +bool SwitchN64Controller::GetCDownButtonPressed() { + return GetButtonPressed(Button::C_DOWN); +} + +bool SwitchN64Controller::GetCDownButtonReleased() { + return GetButtonReleased(Button::C_DOWN); +} + +BooleanEvent SwitchN64Controller::CDown(EventLoop* loop) const { + return ButtonEvent(Button::C_DOWN, loop); +} + +bool SwitchN64Controller::GetLButton() const { + return GetButton(Button::L); +} + +bool SwitchN64Controller::GetLButtonPressed() { + return GetButtonPressed(Button::L); +} + +bool SwitchN64Controller::GetLButtonReleased() { + return GetButtonReleased(Button::L); +} + +BooleanEvent SwitchN64Controller::L(EventLoop* loop) const { + return ButtonEvent(Button::L, loop); +} + +bool SwitchN64Controller::GetRButton() const { + return GetButton(Button::R); +} + +bool SwitchN64Controller::GetRButtonPressed() { + return GetButtonPressed(Button::R); +} + +bool SwitchN64Controller::GetRButtonReleased() { + return GetButtonReleased(Button::R); +} + +BooleanEvent SwitchN64Controller::R(EventLoop* loop) const { + return ButtonEvent(Button::R, loop); +} + +bool SwitchN64Controller::GetDpadUpButton() const { + return GetButton(Button::DPAD_UP); +} + +bool SwitchN64Controller::GetDpadUpButtonPressed() { + return GetButtonPressed(Button::DPAD_UP); +} + +bool SwitchN64Controller::GetDpadUpButtonReleased() { + return GetButtonReleased(Button::DPAD_UP); +} + +BooleanEvent SwitchN64Controller::DpadUp(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_UP, loop); +} + +bool SwitchN64Controller::GetDpadDownButton() const { + return GetButton(Button::DPAD_DOWN); +} + +bool SwitchN64Controller::GetDpadDownButtonPressed() { + return GetButtonPressed(Button::DPAD_DOWN); +} + +bool SwitchN64Controller::GetDpadDownButtonReleased() { + return GetButtonReleased(Button::DPAD_DOWN); +} + +BooleanEvent SwitchN64Controller::DpadDown(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_DOWN, loop); +} + +bool SwitchN64Controller::GetDpadLeftButton() const { + return GetButton(Button::DPAD_LEFT); +} + +bool SwitchN64Controller::GetDpadLeftButtonPressed() { + return GetButtonPressed(Button::DPAD_LEFT); +} + +bool SwitchN64Controller::GetDpadLeftButtonReleased() { + return GetButtonReleased(Button::DPAD_LEFT); +} + +BooleanEvent SwitchN64Controller::DpadLeft(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_LEFT, loop); +} + +bool SwitchN64Controller::GetDpadRightButton() const { + return GetButton(Button::DPAD_RIGHT); +} + +bool SwitchN64Controller::GetDpadRightButtonPressed() { + return GetButtonPressed(Button::DPAD_RIGHT); +} + +bool SwitchN64Controller::GetDpadRightButtonReleased() { + return GetButtonReleased(Button::DPAD_RIGHT); +} + +BooleanEvent SwitchN64Controller::DpadRight(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_RIGHT, loop); +} + +bool SwitchN64Controller::GetCRightButton() const { + return GetButton(Button::C_RIGHT); +} + +bool SwitchN64Controller::GetCRightButtonPressed() { + return GetButtonPressed(Button::C_RIGHT); +} + +bool SwitchN64Controller::GetCRightButtonReleased() { + return GetButtonReleased(Button::C_RIGHT); +} + +BooleanEvent SwitchN64Controller::CRight(EventLoop* loop) const { + return ButtonEvent(Button::C_RIGHT, loop); +} + +bool SwitchN64Controller::GetButton(Button button) const { + return m_hid->GetRawButton(static_cast(button)); +} + +bool SwitchN64Controller::GetButtonPressed(Button button) { + return m_hid->GetRawButtonPressed(static_cast(button)); +} + +bool SwitchN64Controller::GetButtonReleased(Button button) { + return m_hid->GetRawButtonReleased(static_cast(button)); +} + +BooleanEvent SwitchN64Controller::ButtonEvent(Button button, + EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + +void SwitchN64Controller::SetLeds(int r, int g, int b) { + m_hid->SetLeds(r, g, b); +} + +void SwitchN64Controller::SetRumble(GenericHID::RumbleType type, + double value) { + m_hid->SetRumble(type, value); +} + + + +void SwitchN64Controller::InitSendable(wpi::util::SendableBuilder& builder) { + builder.SetSmartDashboardType("HID"); + builder.PublishConstString("ControllerType", "SwitchN64"); + builder.AddDoubleProperty("LeftX", [this] { return GetLeftX(); }, nullptr); + builder.AddDoubleProperty("LeftY", [this] { return GetLeftY(); }, nullptr); + builder.AddDoubleProperty("ZAxis", [this] { return GetZAxis(); }, nullptr); + builder.AddDoubleProperty("ZR", [this] { return GetZR(); }, nullptr); + builder.AddBooleanProperty("A", [this] { return GetAButton(); }, nullptr); + builder.AddBooleanProperty("B", [this] { return GetBButton(); }, nullptr); + builder.AddBooleanProperty("CLeft", [this] { return GetCLeftButton(); }, nullptr); + builder.AddBooleanProperty("CUp", [this] { return GetCUpButton(); }, nullptr); + builder.AddBooleanProperty("Capture", [this] { return GetCaptureButton(); }, nullptr); + builder.AddBooleanProperty("Home", [this] { return GetHomeButton(); }, nullptr); + builder.AddBooleanProperty("Start", [this] { return GetStartButton(); }, nullptr); + builder.AddBooleanProperty("CDown", [this] { return GetCDownButton(); }, nullptr); + builder.AddBooleanProperty("L", [this] { return GetLButton(); }, nullptr); + builder.AddBooleanProperty("R", [this] { return GetRButton(); }, nullptr); + builder.AddBooleanProperty("DpadUp", [this] { return GetDpadUpButton(); }, nullptr); + builder.AddBooleanProperty("DpadDown", [this] { return GetDpadDownButton(); }, nullptr); + builder.AddBooleanProperty("DpadLeft", [this] { return GetDpadLeftButton(); }, nullptr); + builder.AddBooleanProperty("DpadRight", [this] { return GetDpadRightButton(); }, nullptr); + builder.AddBooleanProperty("CRight", [this] { return GetCRightButton(); }, nullptr); +} diff --git a/wpilibc/src/generated/main/native/cpp/driverstation/SwitchProController.cpp b/wpilibc/src/generated/main/native/cpp/driverstation/SwitchProController.cpp new file mode 100644 index 0000000000..c0f3743eb5 --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/driverstation/SwitchProController.cpp @@ -0,0 +1,386 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/SwitchProController.hpp" + +#include "wpi/driverstation/DriverStation.hpp" +#include "wpi/event/BooleanEvent.hpp" +#include "wpi/hal/UsageReporting.hpp" +#include "wpi/util/sendable/SendableBuilder.hpp" + +using namespace wpi; + +SwitchProController::SwitchProController(int port) + : SwitchProController{DriverStation::GetGenericHID(port)} {} + +SwitchProController::SwitchProController(GenericHID& hid) + : m_hid{&hid} { + HAL_ReportUsage("HID", hid.GetPort(), "SwitchProController"); +} + +GenericHID& SwitchProController::GetHID() { + return *m_hid; +} + +const GenericHID& SwitchProController::GetHID() const { + return *m_hid; +} + +int SwitchProController::GetPort() const { + return m_hid->GetPort(); +} + +bool SwitchProController::IsConnected() const { + return m_hid->IsConnected(); +} + +double SwitchProController::GetLeftX() const { + return GetAxis(Axis::LEFT_X); +} + +double SwitchProController::GetLeftY() const { + return GetAxis(Axis::LEFT_Y); +} + +double SwitchProController::GetRightX() const { + return GetAxis(Axis::RIGHT_X); +} + +double SwitchProController::GetRightY() const { + return GetAxis(Axis::RIGHT_Y); +} + +double SwitchProController::GetZL() const { + return GetAxis(Axis::ZL); +} + +double SwitchProController::GetZR() const { + return GetAxis(Axis::ZR); +} + +double SwitchProController::GetAxis(Axis axis) const { + return m_hid->GetRawAxis(static_cast(axis)); +} + +BooleanEvent SwitchProController::AxisLessThan(Axis axis, double threshold, + EventLoop* loop) const { + return m_hid->AxisLessThan(static_cast(axis), threshold, loop); +} + +BooleanEvent SwitchProController::AxisGreaterThan( + Axis axis, double threshold, EventLoop* loop) const { + return m_hid->AxisGreaterThan(static_cast(axis), threshold, loop); +} + +bool SwitchProController::GetBButton() const { + return GetButton(Button::B); +} + +bool SwitchProController::GetBButtonPressed() { + return GetButtonPressed(Button::B); +} + +bool SwitchProController::GetBButtonReleased() { + return GetButtonReleased(Button::B); +} + +BooleanEvent SwitchProController::B(EventLoop* loop) const { + return ButtonEvent(Button::B, loop); +} + +bool SwitchProController::GetAButton() const { + return GetButton(Button::A); +} + +bool SwitchProController::GetAButtonPressed() { + return GetButtonPressed(Button::A); +} + +bool SwitchProController::GetAButtonReleased() { + return GetButtonReleased(Button::A); +} + +BooleanEvent SwitchProController::A(EventLoop* loop) const { + return ButtonEvent(Button::A, loop); +} + +bool SwitchProController::GetYButton() const { + return GetButton(Button::Y); +} + +bool SwitchProController::GetYButtonPressed() { + return GetButtonPressed(Button::Y); +} + +bool SwitchProController::GetYButtonReleased() { + return GetButtonReleased(Button::Y); +} + +BooleanEvent SwitchProController::Y(EventLoop* loop) const { + return ButtonEvent(Button::Y, loop); +} + +bool SwitchProController::GetXButton() const { + return GetButton(Button::X); +} + +bool SwitchProController::GetXButtonPressed() { + return GetButtonPressed(Button::X); +} + +bool SwitchProController::GetXButtonReleased() { + return GetButtonReleased(Button::X); +} + +BooleanEvent SwitchProController::X(EventLoop* loop) const { + return ButtonEvent(Button::X, loop); +} + +bool SwitchProController::GetMinusButton() const { + return GetButton(Button::MINUS); +} + +bool SwitchProController::GetMinusButtonPressed() { + return GetButtonPressed(Button::MINUS); +} + +bool SwitchProController::GetMinusButtonReleased() { + return GetButtonReleased(Button::MINUS); +} + +BooleanEvent SwitchProController::Minus(EventLoop* loop) const { + return ButtonEvent(Button::MINUS, loop); +} + +bool SwitchProController::GetHomeButton() const { + return GetButton(Button::HOME); +} + +bool SwitchProController::GetHomeButtonPressed() { + return GetButtonPressed(Button::HOME); +} + +bool SwitchProController::GetHomeButtonReleased() { + return GetButtonReleased(Button::HOME); +} + +BooleanEvent SwitchProController::Home(EventLoop* loop) const { + return ButtonEvent(Button::HOME, loop); +} + +bool SwitchProController::GetPlusButton() const { + return GetButton(Button::PLUS); +} + +bool SwitchProController::GetPlusButtonPressed() { + return GetButtonPressed(Button::PLUS); +} + +bool SwitchProController::GetPlusButtonReleased() { + return GetButtonReleased(Button::PLUS); +} + +BooleanEvent SwitchProController::Plus(EventLoop* loop) const { + return ButtonEvent(Button::PLUS, loop); +} + +bool SwitchProController::GetLeftStickButton() const { + return GetButton(Button::LEFT_STICK); +} + +bool SwitchProController::GetLeftStickButtonPressed() { + return GetButtonPressed(Button::LEFT_STICK); +} + +bool SwitchProController::GetLeftStickButtonReleased() { + return GetButtonReleased(Button::LEFT_STICK); +} + +BooleanEvent SwitchProController::LeftStick(EventLoop* loop) const { + return ButtonEvent(Button::LEFT_STICK, loop); +} + +bool SwitchProController::GetRightStickButton() const { + return GetButton(Button::RIGHT_STICK); +} + +bool SwitchProController::GetRightStickButtonPressed() { + return GetButtonPressed(Button::RIGHT_STICK); +} + +bool SwitchProController::GetRightStickButtonReleased() { + return GetButtonReleased(Button::RIGHT_STICK); +} + +BooleanEvent SwitchProController::RightStick(EventLoop* loop) const { + return ButtonEvent(Button::RIGHT_STICK, loop); +} + +bool SwitchProController::GetLButton() const { + return GetButton(Button::L); +} + +bool SwitchProController::GetLButtonPressed() { + return GetButtonPressed(Button::L); +} + +bool SwitchProController::GetLButtonReleased() { + return GetButtonReleased(Button::L); +} + +BooleanEvent SwitchProController::L(EventLoop* loop) const { + return ButtonEvent(Button::L, loop); +} + +bool SwitchProController::GetRButton() const { + return GetButton(Button::R); +} + +bool SwitchProController::GetRButtonPressed() { + return GetButtonPressed(Button::R); +} + +bool SwitchProController::GetRButtonReleased() { + return GetButtonReleased(Button::R); +} + +BooleanEvent SwitchProController::R(EventLoop* loop) const { + return ButtonEvent(Button::R, loop); +} + +bool SwitchProController::GetDpadUpButton() const { + return GetButton(Button::DPAD_UP); +} + +bool SwitchProController::GetDpadUpButtonPressed() { + return GetButtonPressed(Button::DPAD_UP); +} + +bool SwitchProController::GetDpadUpButtonReleased() { + return GetButtonReleased(Button::DPAD_UP); +} + +BooleanEvent SwitchProController::DpadUp(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_UP, loop); +} + +bool SwitchProController::GetDpadDownButton() const { + return GetButton(Button::DPAD_DOWN); +} + +bool SwitchProController::GetDpadDownButtonPressed() { + return GetButtonPressed(Button::DPAD_DOWN); +} + +bool SwitchProController::GetDpadDownButtonReleased() { + return GetButtonReleased(Button::DPAD_DOWN); +} + +BooleanEvent SwitchProController::DpadDown(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_DOWN, loop); +} + +bool SwitchProController::GetDpadLeftButton() const { + return GetButton(Button::DPAD_LEFT); +} + +bool SwitchProController::GetDpadLeftButtonPressed() { + return GetButtonPressed(Button::DPAD_LEFT); +} + +bool SwitchProController::GetDpadLeftButtonReleased() { + return GetButtonReleased(Button::DPAD_LEFT); +} + +BooleanEvent SwitchProController::DpadLeft(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_LEFT, loop); +} + +bool SwitchProController::GetDpadRightButton() const { + return GetButton(Button::DPAD_RIGHT); +} + +bool SwitchProController::GetDpadRightButtonPressed() { + return GetButtonPressed(Button::DPAD_RIGHT); +} + +bool SwitchProController::GetDpadRightButtonReleased() { + return GetButtonReleased(Button::DPAD_RIGHT); +} + +BooleanEvent SwitchProController::DpadRight(EventLoop* loop) const { + return ButtonEvent(Button::DPAD_RIGHT, loop); +} + +bool SwitchProController::GetCaptureButton() const { + return GetButton(Button::CAPTURE); +} + +bool SwitchProController::GetCaptureButtonPressed() { + return GetButtonPressed(Button::CAPTURE); +} + +bool SwitchProController::GetCaptureButtonReleased() { + return GetButtonReleased(Button::CAPTURE); +} + +BooleanEvent SwitchProController::Capture(EventLoop* loop) const { + return ButtonEvent(Button::CAPTURE, loop); +} + +bool SwitchProController::GetButton(Button button) const { + return m_hid->GetRawButton(static_cast(button)); +} + +bool SwitchProController::GetButtonPressed(Button button) { + return m_hid->GetRawButtonPressed(static_cast(button)); +} + +bool SwitchProController::GetButtonReleased(Button button) { + return m_hid->GetRawButtonReleased(static_cast(button)); +} + +BooleanEvent SwitchProController::ButtonEvent(Button button, + EventLoop* loop) const { + return m_hid->Button(static_cast(button), loop); +} + +void SwitchProController::SetLeds(int r, int g, int b) { + m_hid->SetLeds(r, g, b); +} + +void SwitchProController::SetRumble(GenericHID::RumbleType type, + double value) { + m_hid->SetRumble(type, value); +} + + + +void SwitchProController::InitSendable(wpi::util::SendableBuilder& builder) { + builder.SetSmartDashboardType("HID"); + builder.PublishConstString("ControllerType", "SwitchPro"); + builder.AddDoubleProperty("LeftX", [this] { return GetLeftX(); }, nullptr); + builder.AddDoubleProperty("LeftY", [this] { return GetLeftY(); }, nullptr); + builder.AddDoubleProperty("RightX", [this] { return GetRightX(); }, nullptr); + builder.AddDoubleProperty("RightY", [this] { return GetRightY(); }, nullptr); + builder.AddDoubleProperty("ZL", [this] { return GetZL(); }, nullptr); + builder.AddDoubleProperty("ZR", [this] { return GetZR(); }, nullptr); + builder.AddBooleanProperty("B", [this] { return GetBButton(); }, nullptr); + builder.AddBooleanProperty("A", [this] { return GetAButton(); }, nullptr); + builder.AddBooleanProperty("Y", [this] { return GetYButton(); }, nullptr); + builder.AddBooleanProperty("X", [this] { return GetXButton(); }, nullptr); + builder.AddBooleanProperty("Minus", [this] { return GetMinusButton(); }, nullptr); + builder.AddBooleanProperty("Home", [this] { return GetHomeButton(); }, nullptr); + builder.AddBooleanProperty("Plus", [this] { return GetPlusButton(); }, nullptr); + builder.AddBooleanProperty("LeftStick", [this] { return GetLeftStickButton(); }, nullptr); + builder.AddBooleanProperty("RightStick", [this] { return GetRightStickButton(); }, nullptr); + builder.AddBooleanProperty("L", [this] { return GetLButton(); }, nullptr); + builder.AddBooleanProperty("R", [this] { return GetRButton(); }, nullptr); + builder.AddBooleanProperty("DpadUp", [this] { return GetDpadUpButton(); }, nullptr); + builder.AddBooleanProperty("DpadDown", [this] { return GetDpadDownButton(); }, nullptr); + builder.AddBooleanProperty("DpadLeft", [this] { return GetDpadLeftButton(); }, nullptr); + builder.AddBooleanProperty("DpadRight", [this] { return GetDpadRightButton(); }, nullptr); + builder.AddBooleanProperty("Capture", [this] { return GetCaptureButton(); }, nullptr); +} diff --git a/wpilibc/src/generated/main/native/cpp/simulation/DualSenseEdgeControllerSim.cpp b/wpilibc/src/generated/main/native/cpp/simulation/DualSenseEdgeControllerSim.cpp new file mode 100644 index 0000000000..67e99da9ca --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/simulation/DualSenseEdgeControllerSim.cpp @@ -0,0 +1,136 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/simulation/DualSenseEdgeControllerSim.hpp" + +#include "wpi/driverstation/DualSenseEdgeController.hpp" + +using namespace wpi; +using namespace wpi::sim; + +DualSenseEdgeControllerSim::DualSenseEdgeControllerSim(const DualSenseEdgeController& joystick) + : GenericHIDSim{joystick.GetHID()} { + SetAxesAvailable(0x3F); + SetButtonsAvailable(0x73FFFFULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::PS5); + SetSupportedOutputs(DualSenseEdgeController::SUPPORTED_OUTPUTS); +} + +DualSenseEdgeControllerSim::DualSenseEdgeControllerSim(int port) : GenericHIDSim{port} { + SetAxesAvailable(0x3F); + SetButtonsAvailable(0x73FFFFULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::PS5); + SetSupportedOutputs(DualSenseEdgeController::SUPPORTED_OUTPUTS); +} + +void DualSenseEdgeControllerSim::SetLeftX(double value) { + SetRawAxis(static_cast(DualSenseEdgeController::Axis::LEFT_X), value); +} + +void DualSenseEdgeControllerSim::SetLeftY(double value) { + SetRawAxis(static_cast(DualSenseEdgeController::Axis::LEFT_Y), value); +} + +void DualSenseEdgeControllerSim::SetRightX(double value) { + SetRawAxis(static_cast(DualSenseEdgeController::Axis::RIGHT_X), value); +} + +void DualSenseEdgeControllerSim::SetRightY(double value) { + SetRawAxis(static_cast(DualSenseEdgeController::Axis::RIGHT_Y), value); +} + +void DualSenseEdgeControllerSim::SetL2(double value) { + SetRawAxis(static_cast(DualSenseEdgeController::Axis::L2), value); +} + +void DualSenseEdgeControllerSim::SetR2(double value) { + SetRawAxis(static_cast(DualSenseEdgeController::Axis::R2), value); +} + +void DualSenseEdgeControllerSim::SetCrossButton(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::CROSS), value); +} + +void DualSenseEdgeControllerSim::SetCircleButton(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::CIRCLE), value); +} + +void DualSenseEdgeControllerSim::SetSquareButton(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::SQUARE), value); +} + +void DualSenseEdgeControllerSim::SetTriangleButton(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::TRIANGLE), value); +} + +void DualSenseEdgeControllerSim::SetCreateButton(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::CREATE), value); +} + +void DualSenseEdgeControllerSim::SetPSButton(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::PS), value); +} + +void DualSenseEdgeControllerSim::SetOptionsButton(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::OPTIONS), value); +} + +void DualSenseEdgeControllerSim::SetL3Button(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::L3), value); +} + +void DualSenseEdgeControllerSim::SetR3Button(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::R3), value); +} + +void DualSenseEdgeControllerSim::SetL1Button(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::L1), value); +} + +void DualSenseEdgeControllerSim::SetR1Button(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::R1), value); +} + +void DualSenseEdgeControllerSim::SetDpadUpButton(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::DPAD_UP), value); +} + +void DualSenseEdgeControllerSim::SetDpadDownButton(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::DPAD_DOWN), value); +} + +void DualSenseEdgeControllerSim::SetDpadLeftButton(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::DPAD_LEFT), value); +} + +void DualSenseEdgeControllerSim::SetDpadRightButton(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::DPAD_RIGHT), value); +} + +void DualSenseEdgeControllerSim::SetMicrophoneButton(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::MICROPHONE), value); +} + +void DualSenseEdgeControllerSim::SetRightPaddle1Button(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::RIGHT_PADDLE_1), value); +} + +void DualSenseEdgeControllerSim::SetLeftPaddle1Button(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::LEFT_PADDLE_1), value); +} + +void DualSenseEdgeControllerSim::SetTouchpadButton(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::TOUCHPAD), value); +} + +void DualSenseEdgeControllerSim::SetLeftFunctionButton(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::LEFT_FUNCTION), value); +} + +void DualSenseEdgeControllerSim::SetRightFunctionButton(bool value) { + SetRawButton(static_cast(DualSenseEdgeController::Button::RIGHT_FUNCTION), value); +} diff --git a/wpilibc/src/generated/main/native/cpp/simulation/DualShock4ControllerSim.cpp b/wpilibc/src/generated/main/native/cpp/simulation/DualShock4ControllerSim.cpp new file mode 100644 index 0000000000..e473b16469 --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/simulation/DualShock4ControllerSim.cpp @@ -0,0 +1,116 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/simulation/DualShock4ControllerSim.hpp" + +#include "wpi/driverstation/DualShock4Controller.hpp" + +using namespace wpi; +using namespace wpi::sim; + +DualShock4ControllerSim::DualShock4ControllerSim(const DualShock4Controller& joystick) + : GenericHIDSim{joystick.GetHID()} { + SetAxesAvailable(0x3F); + SetButtonsAvailable(0x107FFFULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::PS4); + SetSupportedOutputs(DualShock4Controller::SUPPORTED_OUTPUTS); +} + +DualShock4ControllerSim::DualShock4ControllerSim(int port) : GenericHIDSim{port} { + SetAxesAvailable(0x3F); + SetButtonsAvailable(0x107FFFULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::PS4); + SetSupportedOutputs(DualShock4Controller::SUPPORTED_OUTPUTS); +} + +void DualShock4ControllerSim::SetLeftX(double value) { + SetRawAxis(static_cast(DualShock4Controller::Axis::LEFT_X), value); +} + +void DualShock4ControllerSim::SetLeftY(double value) { + SetRawAxis(static_cast(DualShock4Controller::Axis::LEFT_Y), value); +} + +void DualShock4ControllerSim::SetRightX(double value) { + SetRawAxis(static_cast(DualShock4Controller::Axis::RIGHT_X), value); +} + +void DualShock4ControllerSim::SetRightY(double value) { + SetRawAxis(static_cast(DualShock4Controller::Axis::RIGHT_Y), value); +} + +void DualShock4ControllerSim::SetL2(double value) { + SetRawAxis(static_cast(DualShock4Controller::Axis::L2), value); +} + +void DualShock4ControllerSim::SetR2(double value) { + SetRawAxis(static_cast(DualShock4Controller::Axis::R2), value); +} + +void DualShock4ControllerSim::SetCrossButton(bool value) { + SetRawButton(static_cast(DualShock4Controller::Button::CROSS), value); +} + +void DualShock4ControllerSim::SetCircleButton(bool value) { + SetRawButton(static_cast(DualShock4Controller::Button::CIRCLE), value); +} + +void DualShock4ControllerSim::SetSquareButton(bool value) { + SetRawButton(static_cast(DualShock4Controller::Button::SQUARE), value); +} + +void DualShock4ControllerSim::SetTriangleButton(bool value) { + SetRawButton(static_cast(DualShock4Controller::Button::TRIANGLE), value); +} + +void DualShock4ControllerSim::SetShareButton(bool value) { + SetRawButton(static_cast(DualShock4Controller::Button::SHARE), value); +} + +void DualShock4ControllerSim::SetPSButton(bool value) { + SetRawButton(static_cast(DualShock4Controller::Button::PS), value); +} + +void DualShock4ControllerSim::SetOptionsButton(bool value) { + SetRawButton(static_cast(DualShock4Controller::Button::OPTIONS), value); +} + +void DualShock4ControllerSim::SetL3Button(bool value) { + SetRawButton(static_cast(DualShock4Controller::Button::L3), value); +} + +void DualShock4ControllerSim::SetR3Button(bool value) { + SetRawButton(static_cast(DualShock4Controller::Button::R3), value); +} + +void DualShock4ControllerSim::SetL1Button(bool value) { + SetRawButton(static_cast(DualShock4Controller::Button::L1), value); +} + +void DualShock4ControllerSim::SetR1Button(bool value) { + SetRawButton(static_cast(DualShock4Controller::Button::R1), value); +} + +void DualShock4ControllerSim::SetDpadUpButton(bool value) { + SetRawButton(static_cast(DualShock4Controller::Button::DPAD_UP), value); +} + +void DualShock4ControllerSim::SetDpadDownButton(bool value) { + SetRawButton(static_cast(DualShock4Controller::Button::DPAD_DOWN), value); +} + +void DualShock4ControllerSim::SetDpadLeftButton(bool value) { + SetRawButton(static_cast(DualShock4Controller::Button::DPAD_LEFT), value); +} + +void DualShock4ControllerSim::SetDpadRightButton(bool value) { + SetRawButton(static_cast(DualShock4Controller::Button::DPAD_RIGHT), value); +} + +void DualShock4ControllerSim::SetTouchpadButton(bool value) { + SetRawButton(static_cast(DualShock4Controller::Button::TOUCHPAD), value); +} diff --git a/wpilibc/src/generated/main/native/cpp/simulation/GameCubeControllerSim.cpp b/wpilibc/src/generated/main/native/cpp/simulation/GameCubeControllerSim.cpp new file mode 100644 index 0000000000..8f91ec2e22 --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/simulation/GameCubeControllerSim.cpp @@ -0,0 +1,100 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/simulation/GameCubeControllerSim.hpp" + +#include "wpi/driverstation/GameCubeController.hpp" + +using namespace wpi; +using namespace wpi::sim; + +GameCubeControllerSim::GameCubeControllerSim(const GameCubeController& joystick) + : GenericHIDSim{joystick.GetHID()} { + SetAxesAvailable(0x3F); + SetButtonsAvailable(0xC07C4FULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::STANDARD); + SetSupportedOutputs(GameCubeController::SUPPORTED_OUTPUTS); +} + +GameCubeControllerSim::GameCubeControllerSim(int port) : GenericHIDSim{port} { + SetAxesAvailable(0x3F); + SetButtonsAvailable(0xC07C4FULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::STANDARD); + SetSupportedOutputs(GameCubeController::SUPPORTED_OUTPUTS); +} + +void GameCubeControllerSim::SetLeftX(double value) { + SetRawAxis(static_cast(GameCubeController::Axis::LEFT_X), value); +} + +void GameCubeControllerSim::SetLeftY(double value) { + SetRawAxis(static_cast(GameCubeController::Axis::LEFT_Y), value); +} + +void GameCubeControllerSim::SetCStickX(double value) { + SetRawAxis(static_cast(GameCubeController::Axis::C_STICK_X), value); +} + +void GameCubeControllerSim::SetCStickY(double value) { + SetRawAxis(static_cast(GameCubeController::Axis::C_STICK_Y), value); +} + +void GameCubeControllerSim::SetLTrigger(double value) { + SetRawAxis(static_cast(GameCubeController::Axis::L_TRIGGER), value); +} + +void GameCubeControllerSim::SetRTrigger(double value) { + SetRawAxis(static_cast(GameCubeController::Axis::R_TRIGGER), value); +} + +void GameCubeControllerSim::SetAButton(bool value) { + SetRawButton(static_cast(GameCubeController::Button::A), value); +} + +void GameCubeControllerSim::SetXButton(bool value) { + SetRawButton(static_cast(GameCubeController::Button::X), value); +} + +void GameCubeControllerSim::SetBButton(bool value) { + SetRawButton(static_cast(GameCubeController::Button::B), value); +} + +void GameCubeControllerSim::SetYButton(bool value) { + SetRawButton(static_cast(GameCubeController::Button::Y), value); +} + +void GameCubeControllerSim::SetStartButton(bool value) { + SetRawButton(static_cast(GameCubeController::Button::START), value); +} + +void GameCubeControllerSim::SetZButton(bool value) { + SetRawButton(static_cast(GameCubeController::Button::Z), value); +} + +void GameCubeControllerSim::SetDpadUpButton(bool value) { + SetRawButton(static_cast(GameCubeController::Button::DPAD_UP), value); +} + +void GameCubeControllerSim::SetDpadDownButton(bool value) { + SetRawButton(static_cast(GameCubeController::Button::DPAD_DOWN), value); +} + +void GameCubeControllerSim::SetDpadLeftButton(bool value) { + SetRawButton(static_cast(GameCubeController::Button::DPAD_LEFT), value); +} + +void GameCubeControllerSim::SetDpadRightButton(bool value) { + SetRawButton(static_cast(GameCubeController::Button::DPAD_RIGHT), value); +} + +void GameCubeControllerSim::SetLButton(bool value) { + SetRawButton(static_cast(GameCubeController::Button::L), value); +} + +void GameCubeControllerSim::SetRButton(bool value) { + SetRawButton(static_cast(GameCubeController::Button::R), value); +} diff --git a/wpilibc/src/generated/main/native/cpp/simulation/LogitechF310ControllerSim.cpp b/wpilibc/src/generated/main/native/cpp/simulation/LogitechF310ControllerSim.cpp new file mode 100644 index 0000000000..17e1fccb8b --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/simulation/LogitechF310ControllerSim.cpp @@ -0,0 +1,112 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/simulation/LogitechF310ControllerSim.hpp" + +#include "wpi/driverstation/LogitechF310Controller.hpp" + +using namespace wpi; +using namespace wpi::sim; + +LogitechF310ControllerSim::LogitechF310ControllerSim(const LogitechF310Controller& joystick) + : GenericHIDSim{joystick.GetHID()} { + SetAxesAvailable(0x3F); + SetButtonsAvailable(0x7FFFULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::XBOX_360); + SetSupportedOutputs(LogitechF310Controller::SUPPORTED_OUTPUTS); +} + +LogitechF310ControllerSim::LogitechF310ControllerSim(int port) : GenericHIDSim{port} { + SetAxesAvailable(0x3F); + SetButtonsAvailable(0x7FFFULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::XBOX_360); + SetSupportedOutputs(LogitechF310Controller::SUPPORTED_OUTPUTS); +} + +void LogitechF310ControllerSim::SetLeftX(double value) { + SetRawAxis(static_cast(LogitechF310Controller::Axis::LEFT_X), value); +} + +void LogitechF310ControllerSim::SetLeftY(double value) { + SetRawAxis(static_cast(LogitechF310Controller::Axis::LEFT_Y), value); +} + +void LogitechF310ControllerSim::SetRightX(double value) { + SetRawAxis(static_cast(LogitechF310Controller::Axis::RIGHT_X), value); +} + +void LogitechF310ControllerSim::SetRightY(double value) { + SetRawAxis(static_cast(LogitechF310Controller::Axis::RIGHT_Y), value); +} + +void LogitechF310ControllerSim::SetLeftTrigger(double value) { + SetRawAxis(static_cast(LogitechF310Controller::Axis::LEFT_TRIGGER), value); +} + +void LogitechF310ControllerSim::SetRightTrigger(double value) { + SetRawAxis(static_cast(LogitechF310Controller::Axis::RIGHT_TRIGGER), value); +} + +void LogitechF310ControllerSim::SetAButton(bool value) { + SetRawButton(static_cast(LogitechF310Controller::Button::A), value); +} + +void LogitechF310ControllerSim::SetBButton(bool value) { + SetRawButton(static_cast(LogitechF310Controller::Button::B), value); +} + +void LogitechF310ControllerSim::SetXButton(bool value) { + SetRawButton(static_cast(LogitechF310Controller::Button::X), value); +} + +void LogitechF310ControllerSim::SetYButton(bool value) { + SetRawButton(static_cast(LogitechF310Controller::Button::Y), value); +} + +void LogitechF310ControllerSim::SetBackButton(bool value) { + SetRawButton(static_cast(LogitechF310Controller::Button::BACK), value); +} + +void LogitechF310ControllerSim::SetLogitechButton(bool value) { + SetRawButton(static_cast(LogitechF310Controller::Button::LOGITECH), value); +} + +void LogitechF310ControllerSim::SetStartButton(bool value) { + SetRawButton(static_cast(LogitechF310Controller::Button::START), value); +} + +void LogitechF310ControllerSim::SetLeftStickButton(bool value) { + SetRawButton(static_cast(LogitechF310Controller::Button::LEFT_STICK), value); +} + +void LogitechF310ControllerSim::SetRightStickButton(bool value) { + SetRawButton(static_cast(LogitechF310Controller::Button::RIGHT_STICK), value); +} + +void LogitechF310ControllerSim::SetLeftBumperButton(bool value) { + SetRawButton(static_cast(LogitechF310Controller::Button::LEFT_BUMPER), value); +} + +void LogitechF310ControllerSim::SetRightBumperButton(bool value) { + SetRawButton(static_cast(LogitechF310Controller::Button::RIGHT_BUMPER), value); +} + +void LogitechF310ControllerSim::SetDpadUpButton(bool value) { + SetRawButton(static_cast(LogitechF310Controller::Button::DPAD_UP), value); +} + +void LogitechF310ControllerSim::SetDpadDownButton(bool value) { + SetRawButton(static_cast(LogitechF310Controller::Button::DPAD_DOWN), value); +} + +void LogitechF310ControllerSim::SetDpadLeftButton(bool value) { + SetRawButton(static_cast(LogitechF310Controller::Button::DPAD_LEFT), value); +} + +void LogitechF310ControllerSim::SetDpadRightButton(bool value) { + SetRawButton(static_cast(LogitechF310Controller::Button::DPAD_RIGHT), value); +} diff --git a/wpilibc/src/generated/main/native/cpp/simulation/SteamControllerSim.cpp b/wpilibc/src/generated/main/native/cpp/simulation/SteamControllerSim.cpp new file mode 100644 index 0000000000..a1d7cb859e --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/simulation/SteamControllerSim.cpp @@ -0,0 +1,156 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/simulation/SteamControllerSim.hpp" + +#include "wpi/driverstation/SteamController.hpp" + +using namespace wpi; +using namespace wpi::sim; + +SteamControllerSim::SteamControllerSim(const SteamController& joystick) + : GenericHIDSim{joystick.GetHID()} { + SetAxesAvailable(0x3F); + SetButtonsAvailable(0x3FFFFFFULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::STANDARD); + SetSupportedOutputs(SteamController::SUPPORTED_OUTPUTS); +} + +SteamControllerSim::SteamControllerSim(int port) : GenericHIDSim{port} { + SetAxesAvailable(0x3F); + SetButtonsAvailable(0x3FFFFFFULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::STANDARD); + SetSupportedOutputs(SteamController::SUPPORTED_OUTPUTS); +} + +void SteamControllerSim::SetLeftX(double value) { + SetRawAxis(static_cast(SteamController::Axis::LEFT_X), value); +} + +void SteamControllerSim::SetLeftY(double value) { + SetRawAxis(static_cast(SteamController::Axis::LEFT_Y), value); +} + +void SteamControllerSim::SetRightX(double value) { + SetRawAxis(static_cast(SteamController::Axis::RIGHT_X), value); +} + +void SteamControllerSim::SetRightY(double value) { + SetRawAxis(static_cast(SteamController::Axis::RIGHT_Y), value); +} + +void SteamControllerSim::SetLeftTrigger(double value) { + SetRawAxis(static_cast(SteamController::Axis::LEFT_TRIGGER), value); +} + +void SteamControllerSim::SetRightTrigger(double value) { + SetRawAxis(static_cast(SteamController::Axis::RIGHT_TRIGGER), value); +} + +void SteamControllerSim::SetAButton(bool value) { + SetRawButton(static_cast(SteamController::Button::A), value); +} + +void SteamControllerSim::SetBButton(bool value) { + SetRawButton(static_cast(SteamController::Button::B), value); +} + +void SteamControllerSim::SetXButton(bool value) { + SetRawButton(static_cast(SteamController::Button::X), value); +} + +void SteamControllerSim::SetYButton(bool value) { + SetRawButton(static_cast(SteamController::Button::Y), value); +} + +void SteamControllerSim::SetMenuButton(bool value) { + SetRawButton(static_cast(SteamController::Button::MENU), value); +} + +void SteamControllerSim::SetSteamButton(bool value) { + SetRawButton(static_cast(SteamController::Button::STEAM), value); +} + +void SteamControllerSim::SetViewButton(bool value) { + SetRawButton(static_cast(SteamController::Button::VIEW), value); +} + +void SteamControllerSim::SetLeftStickButton(bool value) { + SetRawButton(static_cast(SteamController::Button::LEFT_STICK), value); +} + +void SteamControllerSim::SetRightStickButton(bool value) { + SetRawButton(static_cast(SteamController::Button::RIGHT_STICK), value); +} + +void SteamControllerSim::SetLeftBumperButton(bool value) { + SetRawButton(static_cast(SteamController::Button::LEFT_BUMPER), value); +} + +void SteamControllerSim::SetRightBumperButton(bool value) { + SetRawButton(static_cast(SteamController::Button::RIGHT_BUMPER), value); +} + +void SteamControllerSim::SetDpadUpButton(bool value) { + SetRawButton(static_cast(SteamController::Button::DPAD_UP), value); +} + +void SteamControllerSim::SetDpadDownButton(bool value) { + SetRawButton(static_cast(SteamController::Button::DPAD_DOWN), value); +} + +void SteamControllerSim::SetDpadLeftButton(bool value) { + SetRawButton(static_cast(SteamController::Button::DPAD_LEFT), value); +} + +void SteamControllerSim::SetDpadRightButton(bool value) { + SetRawButton(static_cast(SteamController::Button::DPAD_RIGHT), value); +} + +void SteamControllerSim::SetQAMButton(bool value) { + SetRawButton(static_cast(SteamController::Button::QAM), value); +} + +void SteamControllerSim::SetRightPaddle1Button(bool value) { + SetRawButton(static_cast(SteamController::Button::RIGHT_PADDLE_1), value); +} + +void SteamControllerSim::SetLeftPaddle1Button(bool value) { + SetRawButton(static_cast(SteamController::Button::LEFT_PADDLE_1), value); +} + +void SteamControllerSim::SetRightPaddle2Button(bool value) { + SetRawButton(static_cast(SteamController::Button::RIGHT_PADDLE_2), value); +} + +void SteamControllerSim::SetLeftPaddle2Button(bool value) { + SetRawButton(static_cast(SteamController::Button::LEFT_PADDLE_2), value); +} + +void SteamControllerSim::SetLeftTouchpadButton(bool value) { + SetRawButton(static_cast(SteamController::Button::LEFT_TOUCHPAD), value); +} + +void SteamControllerSim::SetRightTouchpadButton(bool value) { + SetRawButton(static_cast(SteamController::Button::RIGHT_TOUCHPAD), value); +} + +void SteamControllerSim::SetLeftStickTouchButton(bool value) { + SetRawButton(static_cast(SteamController::Button::LEFT_STICK_TOUCH), value); +} + +void SteamControllerSim::SetRightStickTouchButton(bool value) { + SetRawButton(static_cast(SteamController::Button::RIGHT_STICK_TOUCH), value); +} + +void SteamControllerSim::SetLeftGripTouchButton(bool value) { + SetRawButton(static_cast(SteamController::Button::LEFT_GRIP_TOUCH), value); +} + +void SteamControllerSim::SetRightGripTouchButton(bool value) { + SetRawButton(static_cast(SteamController::Button::RIGHT_GRIP_TOUCH), value); +} diff --git a/wpilibc/src/generated/main/native/cpp/simulation/Switch2GCControllerSim.cpp b/wpilibc/src/generated/main/native/cpp/simulation/Switch2GCControllerSim.cpp new file mode 100644 index 0000000000..df6975cf68 --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/simulation/Switch2GCControllerSim.cpp @@ -0,0 +1,116 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/simulation/Switch2GCControllerSim.hpp" + +#include "wpi/driverstation/Switch2GCController.hpp" + +using namespace wpi; +using namespace wpi::sim; + +Switch2GCControllerSim::Switch2GCControllerSim(const Switch2GCController& joystick) + : GenericHIDSim{joystick.GetHID()} { + SetAxesAvailable(0x3F); + SetButtonsAvailable(0xE0FE6FULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::SWITCH_PRO); + SetSupportedOutputs(Switch2GCController::SUPPORTED_OUTPUTS); +} + +Switch2GCControllerSim::Switch2GCControllerSim(int port) : GenericHIDSim{port} { + SetAxesAvailable(0x3F); + SetButtonsAvailable(0xE0FE6FULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::SWITCH_PRO); + SetSupportedOutputs(Switch2GCController::SUPPORTED_OUTPUTS); +} + +void Switch2GCControllerSim::SetLeftX(double value) { + SetRawAxis(static_cast(Switch2GCController::Axis::LEFT_X), value); +} + +void Switch2GCControllerSim::SetLeftY(double value) { + SetRawAxis(static_cast(Switch2GCController::Axis::LEFT_Y), value); +} + +void Switch2GCControllerSim::SetCStickX(double value) { + SetRawAxis(static_cast(Switch2GCController::Axis::C_STICK_X), value); +} + +void Switch2GCControllerSim::SetCStickY(double value) { + SetRawAxis(static_cast(Switch2GCController::Axis::C_STICK_Y), value); +} + +void Switch2GCControllerSim::SetLTrigger(double value) { + SetRawAxis(static_cast(Switch2GCController::Axis::L_TRIGGER), value); +} + +void Switch2GCControllerSim::SetRTrigger(double value) { + SetRawAxis(static_cast(Switch2GCController::Axis::R_TRIGGER), value); +} + +void Switch2GCControllerSim::SetAButton(bool value) { + SetRawButton(static_cast(Switch2GCController::Button::A), value); +} + +void Switch2GCControllerSim::SetXButton(bool value) { + SetRawButton(static_cast(Switch2GCController::Button::X), value); +} + +void Switch2GCControllerSim::SetBButton(bool value) { + SetRawButton(static_cast(Switch2GCController::Button::B), value); +} + +void Switch2GCControllerSim::SetYButton(bool value) { + SetRawButton(static_cast(Switch2GCController::Button::Y), value); +} + +void Switch2GCControllerSim::SetHomeButton(bool value) { + SetRawButton(static_cast(Switch2GCController::Button::HOME), value); +} + +void Switch2GCControllerSim::SetStartButton(bool value) { + SetRawButton(static_cast(Switch2GCController::Button::START), value); +} + +void Switch2GCControllerSim::SetZLButton(bool value) { + SetRawButton(static_cast(Switch2GCController::Button::ZL), value); +} + +void Switch2GCControllerSim::SetZButton(bool value) { + SetRawButton(static_cast(Switch2GCController::Button::Z), value); +} + +void Switch2GCControllerSim::SetDpadUpButton(bool value) { + SetRawButton(static_cast(Switch2GCController::Button::DPAD_UP), value); +} + +void Switch2GCControllerSim::SetDpadDownButton(bool value) { + SetRawButton(static_cast(Switch2GCController::Button::DPAD_DOWN), value); +} + +void Switch2GCControllerSim::SetDpadLeftButton(bool value) { + SetRawButton(static_cast(Switch2GCController::Button::DPAD_LEFT), value); +} + +void Switch2GCControllerSim::SetDpadRightButton(bool value) { + SetRawButton(static_cast(Switch2GCController::Button::DPAD_RIGHT), value); +} + +void Switch2GCControllerSim::SetCaptureButton(bool value) { + SetRawButton(static_cast(Switch2GCController::Button::CAPTURE), value); +} + +void Switch2GCControllerSim::SetCButton(bool value) { + SetRawButton(static_cast(Switch2GCController::Button::C), value); +} + +void Switch2GCControllerSim::SetLButton(bool value) { + SetRawButton(static_cast(Switch2GCController::Button::L), value); +} + +void Switch2GCControllerSim::SetRButton(bool value) { + SetRawButton(static_cast(Switch2GCController::Button::R), value); +} diff --git a/wpilibc/src/generated/main/native/cpp/simulation/Switch2ProControllerSim.cpp b/wpilibc/src/generated/main/native/cpp/simulation/Switch2ProControllerSim.cpp new file mode 100644 index 0000000000..4d5a0182f1 --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/simulation/Switch2ProControllerSim.cpp @@ -0,0 +1,128 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/simulation/Switch2ProControllerSim.hpp" + +#include "wpi/driverstation/Switch2ProController.hpp" + +using namespace wpi; +using namespace wpi::sim; + +Switch2ProControllerSim::Switch2ProControllerSim(const Switch2ProController& joystick) + : GenericHIDSim{joystick.GetHID()} { + SetAxesAvailable(0x3F); + SetButtonsAvailable(0x23FFFFULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::SWITCH_PRO); + SetSupportedOutputs(Switch2ProController::SUPPORTED_OUTPUTS); +} + +Switch2ProControllerSim::Switch2ProControllerSim(int port) : GenericHIDSim{port} { + SetAxesAvailable(0x3F); + SetButtonsAvailable(0x23FFFFULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::SWITCH_PRO); + SetSupportedOutputs(Switch2ProController::SUPPORTED_OUTPUTS); +} + +void Switch2ProControllerSim::SetLeftX(double value) { + SetRawAxis(static_cast(Switch2ProController::Axis::LEFT_X), value); +} + +void Switch2ProControllerSim::SetLeftY(double value) { + SetRawAxis(static_cast(Switch2ProController::Axis::LEFT_Y), value); +} + +void Switch2ProControllerSim::SetRightX(double value) { + SetRawAxis(static_cast(Switch2ProController::Axis::RIGHT_X), value); +} + +void Switch2ProControllerSim::SetRightY(double value) { + SetRawAxis(static_cast(Switch2ProController::Axis::RIGHT_Y), value); +} + +void Switch2ProControllerSim::SetZL(double value) { + SetRawAxis(static_cast(Switch2ProController::Axis::ZL), value); +} + +void Switch2ProControllerSim::SetZR(double value) { + SetRawAxis(static_cast(Switch2ProController::Axis::ZR), value); +} + +void Switch2ProControllerSim::SetBButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::B), value); +} + +void Switch2ProControllerSim::SetAButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::A), value); +} + +void Switch2ProControllerSim::SetYButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::Y), value); +} + +void Switch2ProControllerSim::SetXButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::X), value); +} + +void Switch2ProControllerSim::SetMinusButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::MINUS), value); +} + +void Switch2ProControllerSim::SetHomeButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::HOME), value); +} + +void Switch2ProControllerSim::SetPlusButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::PLUS), value); +} + +void Switch2ProControllerSim::SetLeftStickButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::LEFT_STICK), value); +} + +void Switch2ProControllerSim::SetRightStickButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::RIGHT_STICK), value); +} + +void Switch2ProControllerSim::SetLButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::L), value); +} + +void Switch2ProControllerSim::SetRButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::R), value); +} + +void Switch2ProControllerSim::SetDpadUpButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::DPAD_UP), value); +} + +void Switch2ProControllerSim::SetDpadDownButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::DPAD_DOWN), value); +} + +void Switch2ProControllerSim::SetDpadLeftButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::DPAD_LEFT), value); +} + +void Switch2ProControllerSim::SetDpadRightButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::DPAD_RIGHT), value); +} + +void Switch2ProControllerSim::SetCaptureButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::CAPTURE), value); +} + +void Switch2ProControllerSim::SetGRButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::GR), value); +} + +void Switch2ProControllerSim::SetGLButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::GL), value); +} + +void Switch2ProControllerSim::SetCButton(bool value) { + SetRawButton(static_cast(Switch2ProController::Button::C), value); +} diff --git a/wpilibc/src/generated/main/native/cpp/simulation/SwitchN64ControllerSim.cpp b/wpilibc/src/generated/main/native/cpp/simulation/SwitchN64ControllerSim.cpp new file mode 100644 index 0000000000..cf0615d278 --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/simulation/SwitchN64ControllerSim.cpp @@ -0,0 +1,104 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/simulation/SwitchN64ControllerSim.hpp" + +#include "wpi/driverstation/SwitchN64Controller.hpp" + +using namespace wpi; +using namespace wpi::sim; + +SwitchN64ControllerSim::SwitchN64ControllerSim(const SwitchN64Controller& joystick) + : GenericHIDSim{joystick.GetHID()} { + SetAxesAvailable(0x33); + SetButtonsAvailable(0x20FE7FULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::SWITCH_PRO); + SetSupportedOutputs(SwitchN64Controller::SUPPORTED_OUTPUTS); +} + +SwitchN64ControllerSim::SwitchN64ControllerSim(int port) : GenericHIDSim{port} { + SetAxesAvailable(0x33); + SetButtonsAvailable(0x20FE7FULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::SWITCH_PRO); + SetSupportedOutputs(SwitchN64Controller::SUPPORTED_OUTPUTS); +} + +void SwitchN64ControllerSim::SetLeftX(double value) { + SetRawAxis(static_cast(SwitchN64Controller::Axis::LEFT_X), value); +} + +void SwitchN64ControllerSim::SetLeftY(double value) { + SetRawAxis(static_cast(SwitchN64Controller::Axis::LEFT_Y), value); +} + +void SwitchN64ControllerSim::SetZAxis(double value) { + SetRawAxis(static_cast(SwitchN64Controller::Axis::Z_AXIS), value); +} + +void SwitchN64ControllerSim::SetZR(double value) { + SetRawAxis(static_cast(SwitchN64Controller::Axis::ZR), value); +} + +void SwitchN64ControllerSim::SetAButton(bool value) { + SetRawButton(static_cast(SwitchN64Controller::Button::A), value); +} + +void SwitchN64ControllerSim::SetBButton(bool value) { + SetRawButton(static_cast(SwitchN64Controller::Button::B), value); +} + +void SwitchN64ControllerSim::SetCLeftButton(bool value) { + SetRawButton(static_cast(SwitchN64Controller::Button::C_LEFT), value); +} + +void SwitchN64ControllerSim::SetCUpButton(bool value) { + SetRawButton(static_cast(SwitchN64Controller::Button::C_UP), value); +} + +void SwitchN64ControllerSim::SetCaptureButton(bool value) { + SetRawButton(static_cast(SwitchN64Controller::Button::CAPTURE), value); +} + +void SwitchN64ControllerSim::SetHomeButton(bool value) { + SetRawButton(static_cast(SwitchN64Controller::Button::HOME), value); +} + +void SwitchN64ControllerSim::SetStartButton(bool value) { + SetRawButton(static_cast(SwitchN64Controller::Button::START), value); +} + +void SwitchN64ControllerSim::SetCDownButton(bool value) { + SetRawButton(static_cast(SwitchN64Controller::Button::C_DOWN), value); +} + +void SwitchN64ControllerSim::SetLButton(bool value) { + SetRawButton(static_cast(SwitchN64Controller::Button::L), value); +} + +void SwitchN64ControllerSim::SetRButton(bool value) { + SetRawButton(static_cast(SwitchN64Controller::Button::R), value); +} + +void SwitchN64ControllerSim::SetDpadUpButton(bool value) { + SetRawButton(static_cast(SwitchN64Controller::Button::DPAD_UP), value); +} + +void SwitchN64ControllerSim::SetDpadDownButton(bool value) { + SetRawButton(static_cast(SwitchN64Controller::Button::DPAD_DOWN), value); +} + +void SwitchN64ControllerSim::SetDpadLeftButton(bool value) { + SetRawButton(static_cast(SwitchN64Controller::Button::DPAD_LEFT), value); +} + +void SwitchN64ControllerSim::SetDpadRightButton(bool value) { + SetRawButton(static_cast(SwitchN64Controller::Button::DPAD_RIGHT), value); +} + +void SwitchN64ControllerSim::SetCRightButton(bool value) { + SetRawButton(static_cast(SwitchN64Controller::Button::C_RIGHT), value); +} diff --git a/wpilibc/src/generated/main/native/cpp/simulation/SwitchProControllerSim.cpp b/wpilibc/src/generated/main/native/cpp/simulation/SwitchProControllerSim.cpp new file mode 100644 index 0000000000..ccdb3dd62b --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/simulation/SwitchProControllerSim.cpp @@ -0,0 +1,116 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/simulation/SwitchProControllerSim.hpp" + +#include "wpi/driverstation/SwitchProController.hpp" + +using namespace wpi; +using namespace wpi::sim; + +SwitchProControllerSim::SwitchProControllerSim(const SwitchProController& joystick) + : GenericHIDSim{joystick.GetHID()} { + SetAxesAvailable(0x3F); + SetButtonsAvailable(0xFFFFULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::SWITCH_PRO); + SetSupportedOutputs(SwitchProController::SUPPORTED_OUTPUTS); +} + +SwitchProControllerSim::SwitchProControllerSim(int port) : GenericHIDSim{port} { + SetAxesAvailable(0x3F); + SetButtonsAvailable(0xFFFFULL); + SetPOVsAvailable(0); + SetGamepadType(GenericHID::HIDType::SWITCH_PRO); + SetSupportedOutputs(SwitchProController::SUPPORTED_OUTPUTS); +} + +void SwitchProControllerSim::SetLeftX(double value) { + SetRawAxis(static_cast(SwitchProController::Axis::LEFT_X), value); +} + +void SwitchProControllerSim::SetLeftY(double value) { + SetRawAxis(static_cast(SwitchProController::Axis::LEFT_Y), value); +} + +void SwitchProControllerSim::SetRightX(double value) { + SetRawAxis(static_cast(SwitchProController::Axis::RIGHT_X), value); +} + +void SwitchProControllerSim::SetRightY(double value) { + SetRawAxis(static_cast(SwitchProController::Axis::RIGHT_Y), value); +} + +void SwitchProControllerSim::SetZL(double value) { + SetRawAxis(static_cast(SwitchProController::Axis::ZL), value); +} + +void SwitchProControllerSim::SetZR(double value) { + SetRawAxis(static_cast(SwitchProController::Axis::ZR), value); +} + +void SwitchProControllerSim::SetBButton(bool value) { + SetRawButton(static_cast(SwitchProController::Button::B), value); +} + +void SwitchProControllerSim::SetAButton(bool value) { + SetRawButton(static_cast(SwitchProController::Button::A), value); +} + +void SwitchProControllerSim::SetYButton(bool value) { + SetRawButton(static_cast(SwitchProController::Button::Y), value); +} + +void SwitchProControllerSim::SetXButton(bool value) { + SetRawButton(static_cast(SwitchProController::Button::X), value); +} + +void SwitchProControllerSim::SetMinusButton(bool value) { + SetRawButton(static_cast(SwitchProController::Button::MINUS), value); +} + +void SwitchProControllerSim::SetHomeButton(bool value) { + SetRawButton(static_cast(SwitchProController::Button::HOME), value); +} + +void SwitchProControllerSim::SetPlusButton(bool value) { + SetRawButton(static_cast(SwitchProController::Button::PLUS), value); +} + +void SwitchProControllerSim::SetLeftStickButton(bool value) { + SetRawButton(static_cast(SwitchProController::Button::LEFT_STICK), value); +} + +void SwitchProControllerSim::SetRightStickButton(bool value) { + SetRawButton(static_cast(SwitchProController::Button::RIGHT_STICK), value); +} + +void SwitchProControllerSim::SetLButton(bool value) { + SetRawButton(static_cast(SwitchProController::Button::L), value); +} + +void SwitchProControllerSim::SetRButton(bool value) { + SetRawButton(static_cast(SwitchProController::Button::R), value); +} + +void SwitchProControllerSim::SetDpadUpButton(bool value) { + SetRawButton(static_cast(SwitchProController::Button::DPAD_UP), value); +} + +void SwitchProControllerSim::SetDpadDownButton(bool value) { + SetRawButton(static_cast(SwitchProController::Button::DPAD_DOWN), value); +} + +void SwitchProControllerSim::SetDpadLeftButton(bool value) { + SetRawButton(static_cast(SwitchProController::Button::DPAD_LEFT), value); +} + +void SwitchProControllerSim::SetDpadRightButton(bool value) { + SetRawButton(static_cast(SwitchProController::Button::DPAD_RIGHT), value); +} + +void SwitchProControllerSim::SetCaptureButton(bool value) { + SetRawButton(static_cast(SwitchProController::Button::CAPTURE), value); +} diff --git a/wpilibc/src/generated/main/native/include/wpi/driverstation/DualSenseEdgeController.hpp b/wpilibc/src/generated/main/native/include/wpi/driverstation/DualSenseEdgeController.hpp new file mode 100644 index 0000000000..066ba65e9d --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/driverstation/DualSenseEdgeController.hpp @@ -0,0 +1,957 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/driverstation/GenericHID.hpp" +#include "wpi/driverstation/HIDDevice.hpp" +#include "wpi/driverstation/TouchpadFinger.hpp" +#include "wpi/util/sendable/Sendable.hpp" +#include "wpi/util/sendable/SendableHelper.hpp" + +namespace wpi { + +class BooleanEvent; +class EventLoop; + +/** + * Handle input from DualSenseEdge controllers connected to the Driver Station. + * + * This class handles DualSenseEdge input that comes from the Driver Station. + * Each time a value is requested the most recent value is returned. + */ +class DualSenseEdgeController + : public HIDDevice, + public wpi::util::Sendable, + public wpi::util::SendableHelper { + public: + /** The number of touchpads supported by this controller. */ + static constexpr int TOUCHPAD_COUNT = 1; + + /** Whether this controller supports main rumble motors. */ + static constexpr bool SUPPORTS_RUMBLE = true; + + /** Whether this controller supports trigger rumble motors. */ + static constexpr bool SUPPORTS_TRIGGER_RUMBLE = true; + + /** Whether this controller supports mono LED output. */ + static constexpr bool SUPPORTS_MONO_LED = false; + + /** Whether this controller supports RGB LED output. */ + static constexpr bool SUPPORTS_RGB_LED = true; + + /** Supported outputs expected for this controller type. */ + static constexpr GenericHID::SupportedOutputs SUPPORTED_OUTPUTS = + static_cast(26); + + /** Represents a digital button on a DualSenseEdgeController. */ + enum class Button { + /// Cross button. + CROSS = 0, + /// Circle button. + CIRCLE = 1, + /// Square button. + SQUARE = 2, + /// Triangle button. + TRIANGLE = 3, + /// Create button. + CREATE = 4, + /// PS button. + PS = 5, + /// Options button. + OPTIONS = 6, + /// L 3 button. + L3 = 7, + /// R 3 button. + R3 = 8, + /// L 1 button. + L1 = 9, + /// R 1 button. + R1 = 10, + /// Dpad Up button. + DPAD_UP = 11, + /// Dpad Down button. + DPAD_DOWN = 12, + /// Dpad Left button. + DPAD_LEFT = 13, + /// Dpad Right button. + DPAD_RIGHT = 14, + /// Microphone button. + MICROPHONE = 15, + /// Right Paddle 1 button. + RIGHT_PADDLE_1 = 16, + /// Left Paddle 1 button. + LEFT_PADDLE_1 = 17, + /// Touchpad button. + TOUCHPAD = 20, + /// Left Function button. + LEFT_FUNCTION = 21, + /// Right Function button. + RIGHT_FUNCTION = 22, + }; + + /** Represents an axis on a DualSenseEdgeController. */ + enum class Axis { + /// Left X. + LEFT_X = 0, + /// Left Y. + LEFT_Y = 1, + /// Right X. + RIGHT_X = 2, + /// Right Y. + RIGHT_Y = 3, + /// L 2. + L2 = 4, + /// R 2. + R2 = 5, + }; + + /** + * Construct an instance of a controller. + * + * The controller index is the USB port on the Driver Station. + * + * @param port The port on the Driver Station that the controller is plugged + * into. + */ + explicit DualSenseEdgeController(int port); + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + explicit DualSenseEdgeController(GenericHID& hid); + + ~DualSenseEdgeController() override = default; + + DualSenseEdgeController(DualSenseEdgeController&&) = default; + DualSenseEdgeController& operator=(DualSenseEdgeController&&) = default; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + GenericHID& GetHID() override; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + const GenericHID& GetHID() const override; + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + int GetPort() const; + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + bool IsConnected() const; + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the Right X value of the controller. + * + * @return the axis value. + */ + double GetRightX() const; + + /** + * Get the Right Y value of the controller. + * + * @return the axis value. + */ + double GetRightY() const; + + /** + * Get the L 2 value of the controller. + * + * @return the axis value. + */ + double GetL2() const; + + /** + * Get the R 2 value of the controller. + * + * @return the axis value. + */ + double GetR2() const; + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return the axis value. + */ + double GetAxis(Axis axis) const; + + /** + * Constructs an event instance that is true when the axis value is less than + * threshold. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the + * provided threshold. + */ + BooleanEvent AxisLessThan(Axis axis, double threshold, EventLoop* loop) const; + + /** + * Constructs an event instance that is true when the axis value is greater + * than threshold. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than + * the provided threshold. + */ + BooleanEvent AxisGreaterThan(Axis axis, double threshold, + EventLoop* loop) const; + + /** + * Read the value of the Cross button on the controller. + * + * @return The state of the button. + */ + bool GetCrossButton() const; + + /** + * Whether the Cross button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetCrossButtonPressed(); + + /** + * Whether the Cross button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetCrossButtonReleased(); + + /** + * Constructs an event instance around the Cross button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Cross button's + * digital signal attached to the given loop. + */ + BooleanEvent Cross(EventLoop* loop) const; + + /** + * Read the value of the Circle button on the controller. + * + * @return The state of the button. + */ + bool GetCircleButton() const; + + /** + * Whether the Circle button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetCircleButtonPressed(); + + /** + * Whether the Circle button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetCircleButtonReleased(); + + /** + * Constructs an event instance around the Circle button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Circle button's + * digital signal attached to the given loop. + */ + BooleanEvent Circle(EventLoop* loop) const; + + /** + * Read the value of the Square button on the controller. + * + * @return The state of the button. + */ + bool GetSquareButton() const; + + /** + * Whether the Square button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetSquareButtonPressed(); + + /** + * Whether the Square button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetSquareButtonReleased(); + + /** + * Constructs an event instance around the Square button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Square button's + * digital signal attached to the given loop. + */ + BooleanEvent Square(EventLoop* loop) const; + + /** + * Read the value of the Triangle button on the controller. + * + * @return The state of the button. + */ + bool GetTriangleButton() const; + + /** + * Whether the Triangle button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetTriangleButtonPressed(); + + /** + * Whether the Triangle button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetTriangleButtonReleased(); + + /** + * Constructs an event instance around the Triangle button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Triangle button's + * digital signal attached to the given loop. + */ + BooleanEvent Triangle(EventLoop* loop) const; + + /** + * Read the value of the Create button on the controller. + * + * @return The state of the button. + */ + bool GetCreateButton() const; + + /** + * Whether the Create button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetCreateButtonPressed(); + + /** + * Whether the Create button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetCreateButtonReleased(); + + /** + * Constructs an event instance around the Create button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Create button's + * digital signal attached to the given loop. + */ + BooleanEvent Create(EventLoop* loop) const; + + /** + * Read the value of the PS button on the controller. + * + * @return The state of the button. + */ + bool GetPSButton() const; + + /** + * Whether the PS button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetPSButtonPressed(); + + /** + * Whether the PS button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetPSButtonReleased(); + + /** + * Constructs an event instance around the PS button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the PS button's + * digital signal attached to the given loop. + */ + BooleanEvent PS(EventLoop* loop) const; + + /** + * Read the value of the Options button on the controller. + * + * @return The state of the button. + */ + bool GetOptionsButton() const; + + /** + * Whether the Options button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetOptionsButtonPressed(); + + /** + * Whether the Options button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetOptionsButtonReleased(); + + /** + * Constructs an event instance around the Options button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Options button's + * digital signal attached to the given loop. + */ + BooleanEvent Options(EventLoop* loop) const; + + /** + * Read the value of the L 3 button on the controller. + * + * @return The state of the button. + */ + bool GetL3Button() const; + + /** + * Whether the L 3 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetL3ButtonPressed(); + + /** + * Whether the L 3 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetL3ButtonReleased(); + + /** + * Constructs an event instance around the L 3 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L 3 button's + * digital signal attached to the given loop. + */ + BooleanEvent L3(EventLoop* loop) const; + + /** + * Read the value of the R 3 button on the controller. + * + * @return The state of the button. + */ + bool GetR3Button() const; + + /** + * Whether the R 3 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetR3ButtonPressed(); + + /** + * Whether the R 3 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetR3ButtonReleased(); + + /** + * Constructs an event instance around the R 3 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R 3 button's + * digital signal attached to the given loop. + */ + BooleanEvent R3(EventLoop* loop) const; + + /** + * Read the value of the L 1 button on the controller. + * + * @return The state of the button. + */ + bool GetL1Button() const; + + /** + * Whether the L 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetL1ButtonPressed(); + + /** + * Whether the L 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetL1ButtonReleased(); + + /** + * Constructs an event instance around the L 1 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L 1 button's + * digital signal attached to the given loop. + */ + BooleanEvent L1(EventLoop* loop) const; + + /** + * Read the value of the R 1 button on the controller. + * + * @return The state of the button. + */ + bool GetR1Button() const; + + /** + * Whether the R 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetR1ButtonPressed(); + + /** + * Whether the R 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetR1ButtonReleased(); + + /** + * Constructs an event instance around the R 1 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R 1 button's + * digital signal attached to the given loop. + */ + BooleanEvent R1(EventLoop* loop) const; + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + bool GetDpadUpButton() const; + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadUpButtonPressed(); + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadUpButtonReleased(); + + /** + * Constructs an event instance around the Dpad Up button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadUp(EventLoop* loop) const; + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + bool GetDpadDownButton() const; + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadDownButtonPressed(); + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadDownButtonReleased(); + + /** + * Constructs an event instance around the Dpad Down button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadDown(EventLoop* loop) const; + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + bool GetDpadLeftButton() const; + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadLeftButtonPressed(); + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadLeftButtonReleased(); + + /** + * Constructs an event instance around the Dpad Left button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadLeft(EventLoop* loop) const; + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + bool GetDpadRightButton() const; + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadRightButtonPressed(); + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadRightButtonReleased(); + + /** + * Constructs an event instance around the Dpad Right button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadRight(EventLoop* loop) const; + + /** + * Read the value of the Microphone button on the controller. + * + * @return The state of the button. + */ + bool GetMicrophoneButton() const; + + /** + * Whether the Microphone button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetMicrophoneButtonPressed(); + + /** + * Whether the Microphone button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetMicrophoneButtonReleased(); + + /** + * Constructs an event instance around the Microphone button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Microphone button's + * digital signal attached to the given loop. + */ + BooleanEvent Microphone(EventLoop* loop) const; + + /** + * Read the value of the Right Paddle 1 button on the controller. + * + * @return The state of the button. + */ + bool GetRightPaddle1Button() const; + + /** + * Whether the Right Paddle 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightPaddle1ButtonPressed(); + + /** + * Whether the Right Paddle 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightPaddle1ButtonReleased(); + + /** + * Constructs an event instance around the Right Paddle 1 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Paddle 1 button's + * digital signal attached to the given loop. + */ + BooleanEvent RightPaddle1(EventLoop* loop) const; + + /** + * Read the value of the Left Paddle 1 button on the controller. + * + * @return The state of the button. + */ + bool GetLeftPaddle1Button() const; + + /** + * Whether the Left Paddle 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLeftPaddle1ButtonPressed(); + + /** + * Whether the Left Paddle 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLeftPaddle1ButtonReleased(); + + /** + * Constructs an event instance around the Left Paddle 1 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Paddle 1 button's + * digital signal attached to the given loop. + */ + BooleanEvent LeftPaddle1(EventLoop* loop) const; + + /** + * Read the value of the Touchpad button on the controller. + * + * @return The state of the button. + */ + bool GetTouchpadButton() const; + + /** + * Whether the Touchpad button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetTouchpadButtonPressed(); + + /** + * Whether the Touchpad button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetTouchpadButtonReleased(); + + /** + * Constructs an event instance around the Touchpad button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Touchpad button's + * digital signal attached to the given loop. + */ + BooleanEvent Touchpad(EventLoop* loop) const; + + /** + * Read the value of the Left Function button on the controller. + * + * @return The state of the button. + */ + bool GetLeftFunctionButton() const; + + /** + * Whether the Left Function button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLeftFunctionButtonPressed(); + + /** + * Whether the Left Function button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLeftFunctionButtonReleased(); + + /** + * Constructs an event instance around the Left Function button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Function button's + * digital signal attached to the given loop. + */ + BooleanEvent LeftFunction(EventLoop* loop) const; + + /** + * Read the value of the Right Function button on the controller. + * + * @return The state of the button. + */ + bool GetRightFunctionButton() const; + + /** + * Whether the Right Function button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightFunctionButtonPressed(); + + /** + * Whether the Right Function button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightFunctionButtonReleased(); + + /** + * Constructs an event instance around the Right Function button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Function button's + * digital signal attached to the given loop. + */ + BooleanEvent RightFunction(EventLoop* loop) const; + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + bool GetButton(Button button) const; + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + bool GetButtonPressed(Button button); + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + bool GetButtonReleased(Button button); + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + BooleanEvent ButtonEvent(Button button, EventLoop* loop) const; + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + void SetLeds(int r, int g, int b); + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + void SetRumble(GenericHID::RumbleType type, double value); + /** + * Check if a touchpad finger is available. + * @param finger The finger to check. + * @return true if the touchpad finger is available. + */ + bool GetTouchpadFingerAvailable(int finger) const; + + /** + * Get the touchpad finger data. + * @param finger The finger to read. + * @return The touchpad finger data. + */ + TouchpadFinger GetTouchpadFinger(int finger) const; + + void InitSendable(wpi::util::SendableBuilder& builder) override; + + private: + GenericHID* m_hid; +}; + +} // namespace wpi diff --git a/wpilibc/src/generated/main/native/include/wpi/driverstation/DualShock4Controller.hpp b/wpilibc/src/generated/main/native/include/wpi/driverstation/DualShock4Controller.hpp new file mode 100644 index 0000000000..79806f72ae --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/driverstation/DualShock4Controller.hpp @@ -0,0 +1,792 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/driverstation/GenericHID.hpp" +#include "wpi/driverstation/HIDDevice.hpp" +#include "wpi/driverstation/TouchpadFinger.hpp" +#include "wpi/util/sendable/Sendable.hpp" +#include "wpi/util/sendable/SendableHelper.hpp" + +namespace wpi { + +class BooleanEvent; +class EventLoop; + +/** + * Handle input from DualShock4 controllers connected to the Driver Station. + * + * This class handles DualShock4 input that comes from the Driver Station. + * Each time a value is requested the most recent value is returned. + */ +class DualShock4Controller + : public HIDDevice, + public wpi::util::Sendable, + public wpi::util::SendableHelper { + public: + /** The number of touchpads supported by this controller. */ + static constexpr int TOUCHPAD_COUNT = 1; + + /** Whether this controller supports main rumble motors. */ + static constexpr bool SUPPORTS_RUMBLE = true; + + /** Whether this controller supports trigger rumble motors. */ + static constexpr bool SUPPORTS_TRIGGER_RUMBLE = false; + + /** Whether this controller supports mono LED output. */ + static constexpr bool SUPPORTS_MONO_LED = false; + + /** Whether this controller supports RGB LED output. */ + static constexpr bool SUPPORTS_RGB_LED = true; + + /** Supported outputs expected for this controller type. */ + static constexpr GenericHID::SupportedOutputs SUPPORTED_OUTPUTS = + static_cast(10); + + /** Represents a digital button on a DualShock4Controller. */ + enum class Button { + /// Cross button. + CROSS = 0, + /// Circle button. + CIRCLE = 1, + /// Square button. + SQUARE = 2, + /// Triangle button. + TRIANGLE = 3, + /// Share button. + SHARE = 4, + /// PS button. + PS = 5, + /// Options button. + OPTIONS = 6, + /// L 3 button. + L3 = 7, + /// R 3 button. + R3 = 8, + /// L 1 button. + L1 = 9, + /// R 1 button. + R1 = 10, + /// Dpad Up button. + DPAD_UP = 11, + /// Dpad Down button. + DPAD_DOWN = 12, + /// Dpad Left button. + DPAD_LEFT = 13, + /// Dpad Right button. + DPAD_RIGHT = 14, + /// Touchpad button. + TOUCHPAD = 20, + }; + + /** Represents an axis on a DualShock4Controller. */ + enum class Axis { + /// Left X. + LEFT_X = 0, + /// Left Y. + LEFT_Y = 1, + /// Right X. + RIGHT_X = 2, + /// Right Y. + RIGHT_Y = 3, + /// L 2. + L2 = 4, + /// R 2. + R2 = 5, + }; + + /** + * Construct an instance of a controller. + * + * The controller index is the USB port on the Driver Station. + * + * @param port The port on the Driver Station that the controller is plugged + * into. + */ + explicit DualShock4Controller(int port); + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + explicit DualShock4Controller(GenericHID& hid); + + ~DualShock4Controller() override = default; + + DualShock4Controller(DualShock4Controller&&) = default; + DualShock4Controller& operator=(DualShock4Controller&&) = default; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + GenericHID& GetHID() override; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + const GenericHID& GetHID() const override; + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + int GetPort() const; + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + bool IsConnected() const; + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the Right X value of the controller. + * + * @return the axis value. + */ + double GetRightX() const; + + /** + * Get the Right Y value of the controller. + * + * @return the axis value. + */ + double GetRightY() const; + + /** + * Get the L 2 value of the controller. + * + * @return the axis value. + */ + double GetL2() const; + + /** + * Get the R 2 value of the controller. + * + * @return the axis value. + */ + double GetR2() const; + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return the axis value. + */ + double GetAxis(Axis axis) const; + + /** + * Constructs an event instance that is true when the axis value is less than + * threshold. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the + * provided threshold. + */ + BooleanEvent AxisLessThan(Axis axis, double threshold, EventLoop* loop) const; + + /** + * Constructs an event instance that is true when the axis value is greater + * than threshold. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than + * the provided threshold. + */ + BooleanEvent AxisGreaterThan(Axis axis, double threshold, + EventLoop* loop) const; + + /** + * Read the value of the Cross button on the controller. + * + * @return The state of the button. + */ + bool GetCrossButton() const; + + /** + * Whether the Cross button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetCrossButtonPressed(); + + /** + * Whether the Cross button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetCrossButtonReleased(); + + /** + * Constructs an event instance around the Cross button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Cross button's + * digital signal attached to the given loop. + */ + BooleanEvent Cross(EventLoop* loop) const; + + /** + * Read the value of the Circle button on the controller. + * + * @return The state of the button. + */ + bool GetCircleButton() const; + + /** + * Whether the Circle button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetCircleButtonPressed(); + + /** + * Whether the Circle button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetCircleButtonReleased(); + + /** + * Constructs an event instance around the Circle button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Circle button's + * digital signal attached to the given loop. + */ + BooleanEvent Circle(EventLoop* loop) const; + + /** + * Read the value of the Square button on the controller. + * + * @return The state of the button. + */ + bool GetSquareButton() const; + + /** + * Whether the Square button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetSquareButtonPressed(); + + /** + * Whether the Square button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetSquareButtonReleased(); + + /** + * Constructs an event instance around the Square button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Square button's + * digital signal attached to the given loop. + */ + BooleanEvent Square(EventLoop* loop) const; + + /** + * Read the value of the Triangle button on the controller. + * + * @return The state of the button. + */ + bool GetTriangleButton() const; + + /** + * Whether the Triangle button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetTriangleButtonPressed(); + + /** + * Whether the Triangle button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetTriangleButtonReleased(); + + /** + * Constructs an event instance around the Triangle button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Triangle button's + * digital signal attached to the given loop. + */ + BooleanEvent Triangle(EventLoop* loop) const; + + /** + * Read the value of the Share button on the controller. + * + * @return The state of the button. + */ + bool GetShareButton() const; + + /** + * Whether the Share button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetShareButtonPressed(); + + /** + * Whether the Share button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetShareButtonReleased(); + + /** + * Constructs an event instance around the Share button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Share button's + * digital signal attached to the given loop. + */ + BooleanEvent Share(EventLoop* loop) const; + + /** + * Read the value of the PS button on the controller. + * + * @return The state of the button. + */ + bool GetPSButton() const; + + /** + * Whether the PS button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetPSButtonPressed(); + + /** + * Whether the PS button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetPSButtonReleased(); + + /** + * Constructs an event instance around the PS button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the PS button's + * digital signal attached to the given loop. + */ + BooleanEvent PS(EventLoop* loop) const; + + /** + * Read the value of the Options button on the controller. + * + * @return The state of the button. + */ + bool GetOptionsButton() const; + + /** + * Whether the Options button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetOptionsButtonPressed(); + + /** + * Whether the Options button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetOptionsButtonReleased(); + + /** + * Constructs an event instance around the Options button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Options button's + * digital signal attached to the given loop. + */ + BooleanEvent Options(EventLoop* loop) const; + + /** + * Read the value of the L 3 button on the controller. + * + * @return The state of the button. + */ + bool GetL3Button() const; + + /** + * Whether the L 3 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetL3ButtonPressed(); + + /** + * Whether the L 3 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetL3ButtonReleased(); + + /** + * Constructs an event instance around the L 3 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L 3 button's + * digital signal attached to the given loop. + */ + BooleanEvent L3(EventLoop* loop) const; + + /** + * Read the value of the R 3 button on the controller. + * + * @return The state of the button. + */ + bool GetR3Button() const; + + /** + * Whether the R 3 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetR3ButtonPressed(); + + /** + * Whether the R 3 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetR3ButtonReleased(); + + /** + * Constructs an event instance around the R 3 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R 3 button's + * digital signal attached to the given loop. + */ + BooleanEvent R3(EventLoop* loop) const; + + /** + * Read the value of the L 1 button on the controller. + * + * @return The state of the button. + */ + bool GetL1Button() const; + + /** + * Whether the L 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetL1ButtonPressed(); + + /** + * Whether the L 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetL1ButtonReleased(); + + /** + * Constructs an event instance around the L 1 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L 1 button's + * digital signal attached to the given loop. + */ + BooleanEvent L1(EventLoop* loop) const; + + /** + * Read the value of the R 1 button on the controller. + * + * @return The state of the button. + */ + bool GetR1Button() const; + + /** + * Whether the R 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetR1ButtonPressed(); + + /** + * Whether the R 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetR1ButtonReleased(); + + /** + * Constructs an event instance around the R 1 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R 1 button's + * digital signal attached to the given loop. + */ + BooleanEvent R1(EventLoop* loop) const; + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + bool GetDpadUpButton() const; + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadUpButtonPressed(); + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadUpButtonReleased(); + + /** + * Constructs an event instance around the Dpad Up button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadUp(EventLoop* loop) const; + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + bool GetDpadDownButton() const; + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadDownButtonPressed(); + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadDownButtonReleased(); + + /** + * Constructs an event instance around the Dpad Down button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadDown(EventLoop* loop) const; + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + bool GetDpadLeftButton() const; + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadLeftButtonPressed(); + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadLeftButtonReleased(); + + /** + * Constructs an event instance around the Dpad Left button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadLeft(EventLoop* loop) const; + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + bool GetDpadRightButton() const; + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadRightButtonPressed(); + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadRightButtonReleased(); + + /** + * Constructs an event instance around the Dpad Right button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadRight(EventLoop* loop) const; + + /** + * Read the value of the Touchpad button on the controller. + * + * @return The state of the button. + */ + bool GetTouchpadButton() const; + + /** + * Whether the Touchpad button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetTouchpadButtonPressed(); + + /** + * Whether the Touchpad button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetTouchpadButtonReleased(); + + /** + * Constructs an event instance around the Touchpad button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Touchpad button's + * digital signal attached to the given loop. + */ + BooleanEvent Touchpad(EventLoop* loop) const; + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + bool GetButton(Button button) const; + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + bool GetButtonPressed(Button button); + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + bool GetButtonReleased(Button button); + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + BooleanEvent ButtonEvent(Button button, EventLoop* loop) const; + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + void SetLeds(int r, int g, int b); + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + void SetRumble(GenericHID::RumbleType type, double value); + /** + * Check if a touchpad finger is available. + * @param finger The finger to check. + * @return true if the touchpad finger is available. + */ + bool GetTouchpadFingerAvailable(int finger) const; + + /** + * Get the touchpad finger data. + * @param finger The finger to read. + * @return The touchpad finger data. + */ + TouchpadFinger GetTouchpadFinger(int finger) const; + + void InitSendable(wpi::util::SendableBuilder& builder) override; + + private: + GenericHID* m_hid; +}; + +} // namespace wpi diff --git a/wpilibc/src/generated/main/native/include/wpi/driverstation/GameCubeController.hpp b/wpilibc/src/generated/main/native/include/wpi/driverstation/GameCubeController.hpp new file mode 100644 index 0000000000..bdfd515acc --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/driverstation/GameCubeController.hpp @@ -0,0 +1,647 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/driverstation/GenericHID.hpp" +#include "wpi/driverstation/HIDDevice.hpp" +#include "wpi/driverstation/TouchpadFinger.hpp" +#include "wpi/util/sendable/Sendable.hpp" +#include "wpi/util/sendable/SendableHelper.hpp" + +namespace wpi { + +class BooleanEvent; +class EventLoop; + +/** + * Handle input from GameCube controllers connected to the Driver Station. + * + * This class handles GameCube input that comes from the Driver Station. + * Each time a value is requested the most recent value is returned. + */ +class GameCubeController + : public HIDDevice, + public wpi::util::Sendable, + public wpi::util::SendableHelper { + public: + /** The number of touchpads supported by this controller. */ + static constexpr int TOUCHPAD_COUNT = 0; + + /** Whether this controller supports main rumble motors. */ + static constexpr bool SUPPORTS_RUMBLE = false; + + /** Whether this controller supports trigger rumble motors. */ + static constexpr bool SUPPORTS_TRIGGER_RUMBLE = false; + + /** Whether this controller supports mono LED output. */ + static constexpr bool SUPPORTS_MONO_LED = false; + + /** Whether this controller supports RGB LED output. */ + static constexpr bool SUPPORTS_RGB_LED = false; + + /** Supported outputs expected for this controller type. */ + static constexpr GenericHID::SupportedOutputs SUPPORTED_OUTPUTS = + static_cast(0); + + /** Represents a digital button on a GameCubeController. */ + enum class Button { + /// A button. + A = 0, + /// X button. + X = 1, + /// B button. + B = 2, + /// Y button. + Y = 3, + /// Start button. + START = 6, + /// Z button. + Z = 10, + /// Dpad Up button. + DPAD_UP = 11, + /// Dpad Down button. + DPAD_DOWN = 12, + /// Dpad Left button. + DPAD_LEFT = 13, + /// Dpad Right button. + DPAD_RIGHT = 14, + /// L button. + L = 22, + /// R button. + R = 23, + }; + + /** Represents an axis on a GameCubeController. */ + enum class Axis { + /// Left X. + LEFT_X = 0, + /// Left Y. + LEFT_Y = 1, + /// C Stick X. + C_STICK_X = 2, + /// C Stick Y. + C_STICK_Y = 3, + /// L Trigger. + L_TRIGGER = 4, + /// R Trigger. + R_TRIGGER = 5, + }; + + /** + * Construct an instance of a controller. + * + * The controller index is the USB port on the Driver Station. + * + * @param port The port on the Driver Station that the controller is plugged + * into. + */ + explicit GameCubeController(int port); + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + explicit GameCubeController(GenericHID& hid); + + ~GameCubeController() override = default; + + GameCubeController(GameCubeController&&) = default; + GameCubeController& operator=(GameCubeController&&) = default; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + GenericHID& GetHID() override; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + const GenericHID& GetHID() const override; + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + int GetPort() const; + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + bool IsConnected() const; + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the C Stick X value of the controller. + * + * @return the axis value. + */ + double GetCStickX() const; + + /** + * Get the C Stick Y value of the controller. + * + * @return the axis value. + */ + double GetCStickY() const; + + /** + * Get the L Trigger value of the controller. + * + * @return the axis value. + */ + double GetLTrigger() const; + + /** + * Get the R Trigger value of the controller. + * + * @return the axis value. + */ + double GetRTrigger() const; + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return the axis value. + */ + double GetAxis(Axis axis) const; + + /** + * Constructs an event instance that is true when the axis value is less than + * threshold. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the + * provided threshold. + */ + BooleanEvent AxisLessThan(Axis axis, double threshold, EventLoop* loop) const; + + /** + * Constructs an event instance that is true when the axis value is greater + * than threshold. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than + * the provided threshold. + */ + BooleanEvent AxisGreaterThan(Axis axis, double threshold, + EventLoop* loop) const; + + /** + * Read the value of the A button on the controller. + * + * @return The state of the button. + */ + bool GetAButton() const; + + /** + * Whether the A button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetAButtonPressed(); + + /** + * Whether the A button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetAButtonReleased(); + + /** + * Constructs an event instance around the A button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the A button's + * digital signal attached to the given loop. + */ + BooleanEvent A(EventLoop* loop) const; + + /** + * Read the value of the X button on the controller. + * + * @return The state of the button. + */ + bool GetXButton() const; + + /** + * Whether the X button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetXButtonPressed(); + + /** + * Whether the X button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetXButtonReleased(); + + /** + * Constructs an event instance around the X button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the X button's + * digital signal attached to the given loop. + */ + BooleanEvent X(EventLoop* loop) const; + + /** + * Read the value of the B button on the controller. + * + * @return The state of the button. + */ + bool GetBButton() const; + + /** + * Whether the B button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetBButtonPressed(); + + /** + * Whether the B button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetBButtonReleased(); + + /** + * Constructs an event instance around the B button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the B button's + * digital signal attached to the given loop. + */ + BooleanEvent B(EventLoop* loop) const; + + /** + * Read the value of the Y button on the controller. + * + * @return The state of the button. + */ + bool GetYButton() const; + + /** + * Whether the Y button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetYButtonPressed(); + + /** + * Whether the Y button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetYButtonReleased(); + + /** + * Constructs an event instance around the Y button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Y button's + * digital signal attached to the given loop. + */ + BooleanEvent Y(EventLoop* loop) const; + + /** + * Read the value of the Start button on the controller. + * + * @return The state of the button. + */ + bool GetStartButton() const; + + /** + * Whether the Start button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetStartButtonPressed(); + + /** + * Whether the Start button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetStartButtonReleased(); + + /** + * Constructs an event instance around the Start button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Start button's + * digital signal attached to the given loop. + */ + BooleanEvent Start(EventLoop* loop) const; + + /** + * Read the value of the Z button on the controller. + * + * @return The state of the button. + */ + bool GetZButton() const; + + /** + * Whether the Z button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetZButtonPressed(); + + /** + * Whether the Z button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetZButtonReleased(); + + /** + * Constructs an event instance around the Z button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Z button's + * digital signal attached to the given loop. + */ + BooleanEvent Z(EventLoop* loop) const; + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + bool GetDpadUpButton() const; + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadUpButtonPressed(); + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadUpButtonReleased(); + + /** + * Constructs an event instance around the Dpad Up button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadUp(EventLoop* loop) const; + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + bool GetDpadDownButton() const; + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadDownButtonPressed(); + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadDownButtonReleased(); + + /** + * Constructs an event instance around the Dpad Down button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadDown(EventLoop* loop) const; + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + bool GetDpadLeftButton() const; + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadLeftButtonPressed(); + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadLeftButtonReleased(); + + /** + * Constructs an event instance around the Dpad Left button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadLeft(EventLoop* loop) const; + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + bool GetDpadRightButton() const; + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadRightButtonPressed(); + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadRightButtonReleased(); + + /** + * Constructs an event instance around the Dpad Right button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadRight(EventLoop* loop) const; + + /** + * Read the value of the L button on the controller. + * + * @return The state of the button. + */ + bool GetLButton() const; + + /** + * Whether the L button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLButtonPressed(); + + /** + * Whether the L button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLButtonReleased(); + + /** + * Constructs an event instance around the L button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L button's + * digital signal attached to the given loop. + */ + BooleanEvent L(EventLoop* loop) const; + + /** + * Read the value of the R button on the controller. + * + * @return The state of the button. + */ + bool GetRButton() const; + + /** + * Whether the R button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRButtonPressed(); + + /** + * Whether the R button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRButtonReleased(); + + /** + * Constructs an event instance around the R button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R button's + * digital signal attached to the given loop. + */ + BooleanEvent R(EventLoop* loop) const; + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + bool GetButton(Button button) const; + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + bool GetButtonPressed(Button button); + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + bool GetButtonReleased(Button button); + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + BooleanEvent ButtonEvent(Button button, EventLoop* loop) const; + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + void SetLeds(int r, int g, int b); + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + void SetRumble(GenericHID::RumbleType type, double value); + + void InitSendable(wpi::util::SendableBuilder& builder) override; + + private: + GenericHID* m_hid; +}; + +} // namespace wpi diff --git a/wpilibc/src/generated/main/native/include/wpi/driverstation/LogitechF310Controller.hpp b/wpilibc/src/generated/main/native/include/wpi/driverstation/LogitechF310Controller.hpp new file mode 100644 index 0000000000..e7917bad88 --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/driverstation/LogitechF310Controller.hpp @@ -0,0 +1,746 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/driverstation/GenericHID.hpp" +#include "wpi/driverstation/HIDDevice.hpp" +#include "wpi/driverstation/TouchpadFinger.hpp" +#include "wpi/util/sendable/Sendable.hpp" +#include "wpi/util/sendable/SendableHelper.hpp" + +namespace wpi { + +class BooleanEvent; +class EventLoop; + +/** + * Handle input from LogitechF310 controllers connected to the Driver Station. + * + * This class handles LogitechF310 input that comes from the Driver Station. + * Each time a value is requested the most recent value is returned. + */ +class LogitechF310Controller + : public HIDDevice, + public wpi::util::Sendable, + public wpi::util::SendableHelper { + public: + /** The number of touchpads supported by this controller. */ + static constexpr int TOUCHPAD_COUNT = 0; + + /** Whether this controller supports main rumble motors. */ + static constexpr bool SUPPORTS_RUMBLE = false; + + /** Whether this controller supports trigger rumble motors. */ + static constexpr bool SUPPORTS_TRIGGER_RUMBLE = false; + + /** Whether this controller supports mono LED output. */ + static constexpr bool SUPPORTS_MONO_LED = false; + + /** Whether this controller supports RGB LED output. */ + static constexpr bool SUPPORTS_RGB_LED = false; + + /** Supported outputs expected for this controller type. */ + static constexpr GenericHID::SupportedOutputs SUPPORTED_OUTPUTS = + static_cast(0); + + /** Represents a digital button on a LogitechF310Controller. */ + enum class Button { + /// A button. + A = 0, + /// B button. + B = 1, + /// X button. + X = 2, + /// Y button. + Y = 3, + /// Back button. + BACK = 4, + /// Logitech button. + LOGITECH = 5, + /// Start button. + START = 6, + /// Left Stick button. + LEFT_STICK = 7, + /// Right Stick button. + RIGHT_STICK = 8, + /// Left Bumper button. + LEFT_BUMPER = 9, + /// Right Bumper button. + RIGHT_BUMPER = 10, + /// Dpad Up button. + DPAD_UP = 11, + /// Dpad Down button. + DPAD_DOWN = 12, + /// Dpad Left button. + DPAD_LEFT = 13, + /// Dpad Right button. + DPAD_RIGHT = 14, + }; + + /** Represents an axis on a LogitechF310Controller. */ + enum class Axis { + /// Left X. + LEFT_X = 0, + /// Left Y. + LEFT_Y = 1, + /// Right X. + RIGHT_X = 2, + /// Right Y. + RIGHT_Y = 3, + /// Left Trigger. + LEFT_TRIGGER = 4, + /// Right Trigger. + RIGHT_TRIGGER = 5, + }; + + /** + * Construct an instance of a controller. + * + * The controller index is the USB port on the Driver Station. + * + * @param port The port on the Driver Station that the controller is plugged + * into. + */ + explicit LogitechF310Controller(int port); + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + explicit LogitechF310Controller(GenericHID& hid); + + ~LogitechF310Controller() override = default; + + LogitechF310Controller(LogitechF310Controller&&) = default; + LogitechF310Controller& operator=(LogitechF310Controller&&) = default; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + GenericHID& GetHID() override; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + const GenericHID& GetHID() const override; + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + int GetPort() const; + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + bool IsConnected() const; + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the Right X value of the controller. + * + * @return the axis value. + */ + double GetRightX() const; + + /** + * Get the Right Y value of the controller. + * + * @return the axis value. + */ + double GetRightY() const; + + /** + * Get the Left Trigger value of the controller. + * + * @return the axis value. + */ + double GetLeftTrigger() const; + + /** + * Get the Right Trigger value of the controller. + * + * @return the axis value. + */ + double GetRightTrigger() const; + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return the axis value. + */ + double GetAxis(Axis axis) const; + + /** + * Constructs an event instance that is true when the axis value is less than + * threshold. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the + * provided threshold. + */ + BooleanEvent AxisLessThan(Axis axis, double threshold, EventLoop* loop) const; + + /** + * Constructs an event instance that is true when the axis value is greater + * than threshold. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than + * the provided threshold. + */ + BooleanEvent AxisGreaterThan(Axis axis, double threshold, + EventLoop* loop) const; + + /** + * Read the value of the A button on the controller. + * + * @return The state of the button. + */ + bool GetAButton() const; + + /** + * Whether the A button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetAButtonPressed(); + + /** + * Whether the A button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetAButtonReleased(); + + /** + * Constructs an event instance around the A button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the A button's + * digital signal attached to the given loop. + */ + BooleanEvent A(EventLoop* loop) const; + + /** + * Read the value of the B button on the controller. + * + * @return The state of the button. + */ + bool GetBButton() const; + + /** + * Whether the B button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetBButtonPressed(); + + /** + * Whether the B button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetBButtonReleased(); + + /** + * Constructs an event instance around the B button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the B button's + * digital signal attached to the given loop. + */ + BooleanEvent B(EventLoop* loop) const; + + /** + * Read the value of the X button on the controller. + * + * @return The state of the button. + */ + bool GetXButton() const; + + /** + * Whether the X button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetXButtonPressed(); + + /** + * Whether the X button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetXButtonReleased(); + + /** + * Constructs an event instance around the X button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the X button's + * digital signal attached to the given loop. + */ + BooleanEvent X(EventLoop* loop) const; + + /** + * Read the value of the Y button on the controller. + * + * @return The state of the button. + */ + bool GetYButton() const; + + /** + * Whether the Y button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetYButtonPressed(); + + /** + * Whether the Y button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetYButtonReleased(); + + /** + * Constructs an event instance around the Y button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Y button's + * digital signal attached to the given loop. + */ + BooleanEvent Y(EventLoop* loop) const; + + /** + * Read the value of the Back button on the controller. + * + * @return The state of the button. + */ + bool GetBackButton() const; + + /** + * Whether the Back button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetBackButtonPressed(); + + /** + * Whether the Back button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetBackButtonReleased(); + + /** + * Constructs an event instance around the Back button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Back button's + * digital signal attached to the given loop. + */ + BooleanEvent Back(EventLoop* loop) const; + + /** + * Read the value of the Logitech button on the controller. + * + * @return The state of the button. + */ + bool GetLogitechButton() const; + + /** + * Whether the Logitech button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLogitechButtonPressed(); + + /** + * Whether the Logitech button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLogitechButtonReleased(); + + /** + * Constructs an event instance around the Logitech button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Logitech button's + * digital signal attached to the given loop. + */ + BooleanEvent Logitech(EventLoop* loop) const; + + /** + * Read the value of the Start button on the controller. + * + * @return The state of the button. + */ + bool GetStartButton() const; + + /** + * Whether the Start button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetStartButtonPressed(); + + /** + * Whether the Start button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetStartButtonReleased(); + + /** + * Constructs an event instance around the Start button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Start button's + * digital signal attached to the given loop. + */ + BooleanEvent Start(EventLoop* loop) const; + + /** + * Read the value of the Left Stick button on the controller. + * + * @return The state of the button. + */ + bool GetLeftStickButton() const; + + /** + * Whether the Left Stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLeftStickButtonPressed(); + + /** + * Whether the Left Stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLeftStickButtonReleased(); + + /** + * Constructs an event instance around the Left Stick button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Stick button's + * digital signal attached to the given loop. + */ + BooleanEvent LeftStick(EventLoop* loop) const; + + /** + * Read the value of the Right Stick button on the controller. + * + * @return The state of the button. + */ + bool GetRightStickButton() const; + + /** + * Whether the Right Stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightStickButtonPressed(); + + /** + * Whether the Right Stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightStickButtonReleased(); + + /** + * Constructs an event instance around the Right Stick button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Stick button's + * digital signal attached to the given loop. + */ + BooleanEvent RightStick(EventLoop* loop) const; + + /** + * Read the value of the Left Bumper button on the controller. + * + * @return The state of the button. + */ + bool GetLeftBumperButton() const; + + /** + * Whether the Left Bumper button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLeftBumperButtonPressed(); + + /** + * Whether the Left Bumper button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLeftBumperButtonReleased(); + + /** + * Constructs an event instance around the Left Bumper button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Bumper button's + * digital signal attached to the given loop. + */ + BooleanEvent LeftBumper(EventLoop* loop) const; + + /** + * Read the value of the Right Bumper button on the controller. + * + * @return The state of the button. + */ + bool GetRightBumperButton() const; + + /** + * Whether the Right Bumper button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightBumperButtonPressed(); + + /** + * Whether the Right Bumper button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightBumperButtonReleased(); + + /** + * Constructs an event instance around the Right Bumper button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Bumper button's + * digital signal attached to the given loop. + */ + BooleanEvent RightBumper(EventLoop* loop) const; + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + bool GetDpadUpButton() const; + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadUpButtonPressed(); + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadUpButtonReleased(); + + /** + * Constructs an event instance around the Dpad Up button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadUp(EventLoop* loop) const; + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + bool GetDpadDownButton() const; + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadDownButtonPressed(); + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadDownButtonReleased(); + + /** + * Constructs an event instance around the Dpad Down button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadDown(EventLoop* loop) const; + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + bool GetDpadLeftButton() const; + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadLeftButtonPressed(); + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadLeftButtonReleased(); + + /** + * Constructs an event instance around the Dpad Left button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadLeft(EventLoop* loop) const; + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + bool GetDpadRightButton() const; + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadRightButtonPressed(); + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadRightButtonReleased(); + + /** + * Constructs an event instance around the Dpad Right button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadRight(EventLoop* loop) const; + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + bool GetButton(Button button) const; + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + bool GetButtonPressed(Button button); + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + bool GetButtonReleased(Button button); + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + BooleanEvent ButtonEvent(Button button, EventLoop* loop) const; + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + void SetLeds(int r, int g, int b); + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + void SetRumble(GenericHID::RumbleType type, double value); + + void InitSendable(wpi::util::SendableBuilder& builder) override; + + private: + GenericHID* m_hid; +}; + +} // namespace wpi diff --git a/wpilibc/src/generated/main/native/include/wpi/driverstation/SteamController.hpp b/wpilibc/src/generated/main/native/include/wpi/driverstation/SteamController.hpp new file mode 100644 index 0000000000..e93803223e --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/driverstation/SteamController.hpp @@ -0,0 +1,1124 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/driverstation/GenericHID.hpp" +#include "wpi/driverstation/HIDDevice.hpp" +#include "wpi/driverstation/TouchpadFinger.hpp" +#include "wpi/util/sendable/Sendable.hpp" +#include "wpi/util/sendable/SendableHelper.hpp" + +namespace wpi { + +class BooleanEvent; +class EventLoop; + +/** + * Handle input from Steam controllers connected to the Driver Station. + * + * This class handles Steam input that comes from the Driver Station. + * Each time a value is requested the most recent value is returned. + */ +class SteamController + : public HIDDevice, + public wpi::util::Sendable, + public wpi::util::SendableHelper { + public: + /** The number of touchpads supported by this controller. */ + static constexpr int TOUCHPAD_COUNT = 2; + + /** Whether this controller supports main rumble motors. */ + static constexpr bool SUPPORTS_RUMBLE = true; + + /** Whether this controller supports trigger rumble motors. */ + static constexpr bool SUPPORTS_TRIGGER_RUMBLE = false; + + /** Whether this controller supports mono LED output. */ + static constexpr bool SUPPORTS_MONO_LED = false; + + /** Whether this controller supports RGB LED output. */ + static constexpr bool SUPPORTS_RGB_LED = false; + + /** Supported outputs expected for this controller type. */ + static constexpr GenericHID::SupportedOutputs SUPPORTED_OUTPUTS = + static_cast(8); + + /** Represents a digital button on a SteamController. */ + enum class Button { + /// A button. + A = 0, + /// B button. + B = 1, + /// X button. + X = 2, + /// Y button. + Y = 3, + /// Menu button. + MENU = 4, + /// Steam button. + STEAM = 5, + /// View button. + VIEW = 6, + /// Left Stick button. + LEFT_STICK = 7, + /// Right Stick button. + RIGHT_STICK = 8, + /// Left Bumper button. + LEFT_BUMPER = 9, + /// Right Bumper button. + RIGHT_BUMPER = 10, + /// Dpad Up button. + DPAD_UP = 11, + /// Dpad Down button. + DPAD_DOWN = 12, + /// Dpad Left button. + DPAD_LEFT = 13, + /// Dpad Right button. + DPAD_RIGHT = 14, + /// QAM button. + QAM = 15, + /// Right Paddle 1 button. + RIGHT_PADDLE_1 = 16, + /// Left Paddle 1 button. + LEFT_PADDLE_1 = 17, + /// Right Paddle 2 button. + RIGHT_PADDLE_2 = 18, + /// Left Paddle 2 button. + LEFT_PADDLE_2 = 19, + /// Left Touchpad button. + LEFT_TOUCHPAD = 20, + /// Right Touchpad button. + RIGHT_TOUCHPAD = 21, + /// Left Stick Touch button. + LEFT_STICK_TOUCH = 22, + /// Right Stick Touch button. + RIGHT_STICK_TOUCH = 23, + /// Left Grip Touch button. + LEFT_GRIP_TOUCH = 24, + /// Right Grip Touch button. + RIGHT_GRIP_TOUCH = 25, + }; + + /** Represents an axis on a SteamController. */ + enum class Axis { + /// Left X. + LEFT_X = 0, + /// Left Y. + LEFT_Y = 1, + /// Right X. + RIGHT_X = 2, + /// Right Y. + RIGHT_Y = 3, + /// Left Trigger. + LEFT_TRIGGER = 4, + /// Right Trigger. + RIGHT_TRIGGER = 5, + }; + + /** + * Construct an instance of a controller. + * + * The controller index is the USB port on the Driver Station. + * + * @param port The port on the Driver Station that the controller is plugged + * into. + */ + explicit SteamController(int port); + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + explicit SteamController(GenericHID& hid); + + ~SteamController() override = default; + + SteamController(SteamController&&) = default; + SteamController& operator=(SteamController&&) = default; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + GenericHID& GetHID() override; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + const GenericHID& GetHID() const override; + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + int GetPort() const; + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + bool IsConnected() const; + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the Right X value of the controller. + * + * @return the axis value. + */ + double GetRightX() const; + + /** + * Get the Right Y value of the controller. + * + * @return the axis value. + */ + double GetRightY() const; + + /** + * Get the Left Trigger value of the controller. + * + * @return the axis value. + */ + double GetLeftTrigger() const; + + /** + * Get the Right Trigger value of the controller. + * + * @return the axis value. + */ + double GetRightTrigger() const; + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return the axis value. + */ + double GetAxis(Axis axis) const; + + /** + * Constructs an event instance that is true when the axis value is less than + * threshold. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the + * provided threshold. + */ + BooleanEvent AxisLessThan(Axis axis, double threshold, EventLoop* loop) const; + + /** + * Constructs an event instance that is true when the axis value is greater + * than threshold. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than + * the provided threshold. + */ + BooleanEvent AxisGreaterThan(Axis axis, double threshold, + EventLoop* loop) const; + + /** + * Read the value of the A button on the controller. + * + * @return The state of the button. + */ + bool GetAButton() const; + + /** + * Whether the A button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetAButtonPressed(); + + /** + * Whether the A button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetAButtonReleased(); + + /** + * Constructs an event instance around the A button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the A button's + * digital signal attached to the given loop. + */ + BooleanEvent A(EventLoop* loop) const; + + /** + * Read the value of the B button on the controller. + * + * @return The state of the button. + */ + bool GetBButton() const; + + /** + * Whether the B button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetBButtonPressed(); + + /** + * Whether the B button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetBButtonReleased(); + + /** + * Constructs an event instance around the B button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the B button's + * digital signal attached to the given loop. + */ + BooleanEvent B(EventLoop* loop) const; + + /** + * Read the value of the X button on the controller. + * + * @return The state of the button. + */ + bool GetXButton() const; + + /** + * Whether the X button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetXButtonPressed(); + + /** + * Whether the X button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetXButtonReleased(); + + /** + * Constructs an event instance around the X button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the X button's + * digital signal attached to the given loop. + */ + BooleanEvent X(EventLoop* loop) const; + + /** + * Read the value of the Y button on the controller. + * + * @return The state of the button. + */ + bool GetYButton() const; + + /** + * Whether the Y button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetYButtonPressed(); + + /** + * Whether the Y button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetYButtonReleased(); + + /** + * Constructs an event instance around the Y button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Y button's + * digital signal attached to the given loop. + */ + BooleanEvent Y(EventLoop* loop) const; + + /** + * Read the value of the Menu button on the controller. + * + * @return The state of the button. + */ + bool GetMenuButton() const; + + /** + * Whether the Menu button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetMenuButtonPressed(); + + /** + * Whether the Menu button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetMenuButtonReleased(); + + /** + * Constructs an event instance around the Menu button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Menu button's + * digital signal attached to the given loop. + */ + BooleanEvent Menu(EventLoop* loop) const; + + /** + * Read the value of the Steam button on the controller. + * + * @return The state of the button. + */ + bool GetSteamButton() const; + + /** + * Whether the Steam button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetSteamButtonPressed(); + + /** + * Whether the Steam button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetSteamButtonReleased(); + + /** + * Constructs an event instance around the Steam button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Steam button's + * digital signal attached to the given loop. + */ + BooleanEvent Steam(EventLoop* loop) const; + + /** + * Read the value of the View button on the controller. + * + * @return The state of the button. + */ + bool GetViewButton() const; + + /** + * Whether the View button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetViewButtonPressed(); + + /** + * Whether the View button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetViewButtonReleased(); + + /** + * Constructs an event instance around the View button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the View button's + * digital signal attached to the given loop. + */ + BooleanEvent View(EventLoop* loop) const; + + /** + * Read the value of the Left Stick button on the controller. + * + * @return The state of the button. + */ + bool GetLeftStickButton() const; + + /** + * Whether the Left Stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLeftStickButtonPressed(); + + /** + * Whether the Left Stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLeftStickButtonReleased(); + + /** + * Constructs an event instance around the Left Stick button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Stick button's + * digital signal attached to the given loop. + */ + BooleanEvent LeftStick(EventLoop* loop) const; + + /** + * Read the value of the Right Stick button on the controller. + * + * @return The state of the button. + */ + bool GetRightStickButton() const; + + /** + * Whether the Right Stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightStickButtonPressed(); + + /** + * Whether the Right Stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightStickButtonReleased(); + + /** + * Constructs an event instance around the Right Stick button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Stick button's + * digital signal attached to the given loop. + */ + BooleanEvent RightStick(EventLoop* loop) const; + + /** + * Read the value of the Left Bumper button on the controller. + * + * @return The state of the button. + */ + bool GetLeftBumperButton() const; + + /** + * Whether the Left Bumper button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLeftBumperButtonPressed(); + + /** + * Whether the Left Bumper button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLeftBumperButtonReleased(); + + /** + * Constructs an event instance around the Left Bumper button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Bumper button's + * digital signal attached to the given loop. + */ + BooleanEvent LeftBumper(EventLoop* loop) const; + + /** + * Read the value of the Right Bumper button on the controller. + * + * @return The state of the button. + */ + bool GetRightBumperButton() const; + + /** + * Whether the Right Bumper button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightBumperButtonPressed(); + + /** + * Whether the Right Bumper button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightBumperButtonReleased(); + + /** + * Constructs an event instance around the Right Bumper button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Bumper button's + * digital signal attached to the given loop. + */ + BooleanEvent RightBumper(EventLoop* loop) const; + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + bool GetDpadUpButton() const; + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadUpButtonPressed(); + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadUpButtonReleased(); + + /** + * Constructs an event instance around the Dpad Up button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadUp(EventLoop* loop) const; + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + bool GetDpadDownButton() const; + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadDownButtonPressed(); + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadDownButtonReleased(); + + /** + * Constructs an event instance around the Dpad Down button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadDown(EventLoop* loop) const; + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + bool GetDpadLeftButton() const; + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadLeftButtonPressed(); + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadLeftButtonReleased(); + + /** + * Constructs an event instance around the Dpad Left button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadLeft(EventLoop* loop) const; + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + bool GetDpadRightButton() const; + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadRightButtonPressed(); + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadRightButtonReleased(); + + /** + * Constructs an event instance around the Dpad Right button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadRight(EventLoop* loop) const; + + /** + * Read the value of the QAM button on the controller. + * + * @return The state of the button. + */ + bool GetQAMButton() const; + + /** + * Whether the QAM button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetQAMButtonPressed(); + + /** + * Whether the QAM button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetQAMButtonReleased(); + + /** + * Constructs an event instance around the QAM button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the QAM button's + * digital signal attached to the given loop. + */ + BooleanEvent QAM(EventLoop* loop) const; + + /** + * Read the value of the Right Paddle 1 button on the controller. + * + * @return The state of the button. + */ + bool GetRightPaddle1Button() const; + + /** + * Whether the Right Paddle 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightPaddle1ButtonPressed(); + + /** + * Whether the Right Paddle 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightPaddle1ButtonReleased(); + + /** + * Constructs an event instance around the Right Paddle 1 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Paddle 1 button's + * digital signal attached to the given loop. + */ + BooleanEvent RightPaddle1(EventLoop* loop) const; + + /** + * Read the value of the Left Paddle 1 button on the controller. + * + * @return The state of the button. + */ + bool GetLeftPaddle1Button() const; + + /** + * Whether the Left Paddle 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLeftPaddle1ButtonPressed(); + + /** + * Whether the Left Paddle 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLeftPaddle1ButtonReleased(); + + /** + * Constructs an event instance around the Left Paddle 1 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Paddle 1 button's + * digital signal attached to the given loop. + */ + BooleanEvent LeftPaddle1(EventLoop* loop) const; + + /** + * Read the value of the Right Paddle 2 button on the controller. + * + * @return The state of the button. + */ + bool GetRightPaddle2Button() const; + + /** + * Whether the Right Paddle 2 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightPaddle2ButtonPressed(); + + /** + * Whether the Right Paddle 2 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightPaddle2ButtonReleased(); + + /** + * Constructs an event instance around the Right Paddle 2 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Paddle 2 button's + * digital signal attached to the given loop. + */ + BooleanEvent RightPaddle2(EventLoop* loop) const; + + /** + * Read the value of the Left Paddle 2 button on the controller. + * + * @return The state of the button. + */ + bool GetLeftPaddle2Button() const; + + /** + * Whether the Left Paddle 2 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLeftPaddle2ButtonPressed(); + + /** + * Whether the Left Paddle 2 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLeftPaddle2ButtonReleased(); + + /** + * Constructs an event instance around the Left Paddle 2 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Paddle 2 button's + * digital signal attached to the given loop. + */ + BooleanEvent LeftPaddle2(EventLoop* loop) const; + + /** + * Read the value of the Left Touchpad button on the controller. + * + * @return The state of the button. + */ + bool GetLeftTouchpadButton() const; + + /** + * Whether the Left Touchpad button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLeftTouchpadButtonPressed(); + + /** + * Whether the Left Touchpad button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLeftTouchpadButtonReleased(); + + /** + * Constructs an event instance around the Left Touchpad button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Touchpad button's + * digital signal attached to the given loop. + */ + BooleanEvent LeftTouchpad(EventLoop* loop) const; + + /** + * Read the value of the Right Touchpad button on the controller. + * + * @return The state of the button. + */ + bool GetRightTouchpadButton() const; + + /** + * Whether the Right Touchpad button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightTouchpadButtonPressed(); + + /** + * Whether the Right Touchpad button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightTouchpadButtonReleased(); + + /** + * Constructs an event instance around the Right Touchpad button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Touchpad button's + * digital signal attached to the given loop. + */ + BooleanEvent RightTouchpad(EventLoop* loop) const; + + /** + * Read the value of the Left Stick Touch button on the controller. + * + * @return The state of the button. + */ + bool GetLeftStickTouchButton() const; + + /** + * Whether the Left Stick Touch button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLeftStickTouchButtonPressed(); + + /** + * Whether the Left Stick Touch button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLeftStickTouchButtonReleased(); + + /** + * Constructs an event instance around the Left Stick Touch button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Stick Touch button's + * digital signal attached to the given loop. + */ + BooleanEvent LeftStickTouch(EventLoop* loop) const; + + /** + * Read the value of the Right Stick Touch button on the controller. + * + * @return The state of the button. + */ + bool GetRightStickTouchButton() const; + + /** + * Whether the Right Stick Touch button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightStickTouchButtonPressed(); + + /** + * Whether the Right Stick Touch button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightStickTouchButtonReleased(); + + /** + * Constructs an event instance around the Right Stick Touch button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Stick Touch button's + * digital signal attached to the given loop. + */ + BooleanEvent RightStickTouch(EventLoop* loop) const; + + /** + * Read the value of the Left Grip Touch button on the controller. + * + * @return The state of the button. + */ + bool GetLeftGripTouchButton() const; + + /** + * Whether the Left Grip Touch button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLeftGripTouchButtonPressed(); + + /** + * Whether the Left Grip Touch button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLeftGripTouchButtonReleased(); + + /** + * Constructs an event instance around the Left Grip Touch button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Grip Touch button's + * digital signal attached to the given loop. + */ + BooleanEvent LeftGripTouch(EventLoop* loop) const; + + /** + * Read the value of the Right Grip Touch button on the controller. + * + * @return The state of the button. + */ + bool GetRightGripTouchButton() const; + + /** + * Whether the Right Grip Touch button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightGripTouchButtonPressed(); + + /** + * Whether the Right Grip Touch button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightGripTouchButtonReleased(); + + /** + * Constructs an event instance around the Right Grip Touch button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Grip Touch button's + * digital signal attached to the given loop. + */ + BooleanEvent RightGripTouch(EventLoop* loop) const; + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + bool GetButton(Button button) const; + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + bool GetButtonPressed(Button button); + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + bool GetButtonReleased(Button button); + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + BooleanEvent ButtonEvent(Button button, EventLoop* loop) const; + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + void SetLeds(int r, int g, int b); + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + void SetRumble(GenericHID::RumbleType type, double value); + /** + * Check if a touchpad finger is available. + * @param touchpad The touchpad to check. + * @param finger The finger to check. + * @return true if the touchpad finger is available. + */ + bool GetTouchpadFingerAvailable(int touchpad, int finger) const; + + /** + * Get the touchpad finger data. + * @param touchpad The touchpad to read. + * @param finger The finger to read. + * @return The touchpad finger data. + */ + TouchpadFinger GetTouchpadFinger(int touchpad, int finger) const; + + void InitSendable(wpi::util::SendableBuilder& builder) override; + + private: + GenericHID* m_hid; +}; + +} // namespace wpi diff --git a/wpilibc/src/generated/main/native/include/wpi/driverstation/Switch2GCController.hpp b/wpilibc/src/generated/main/native/include/wpi/driverstation/Switch2GCController.hpp new file mode 100644 index 0000000000..87838cb293 --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/driverstation/Switch2GCController.hpp @@ -0,0 +1,779 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/driverstation/GenericHID.hpp" +#include "wpi/driverstation/HIDDevice.hpp" +#include "wpi/driverstation/TouchpadFinger.hpp" +#include "wpi/util/sendable/Sendable.hpp" +#include "wpi/util/sendable/SendableHelper.hpp" + +namespace wpi { + +class BooleanEvent; +class EventLoop; + +/** + * Handle input from Switch2GC controllers connected to the Driver Station. + * + * This class handles Switch2GC input that comes from the Driver Station. + * Each time a value is requested the most recent value is returned. + */ +class Switch2GCController + : public HIDDevice, + public wpi::util::Sendable, + public wpi::util::SendableHelper { + public: + /** The number of touchpads supported by this controller. */ + static constexpr int TOUCHPAD_COUNT = 0; + + /** Whether this controller supports main rumble motors. */ + static constexpr bool SUPPORTS_RUMBLE = true; + + /** Whether this controller supports trigger rumble motors. */ + static constexpr bool SUPPORTS_TRIGGER_RUMBLE = false; + + /** Whether this controller supports mono LED output. */ + static constexpr bool SUPPORTS_MONO_LED = false; + + /** Whether this controller supports RGB LED output. */ + static constexpr bool SUPPORTS_RGB_LED = false; + + /** Supported outputs expected for this controller type. */ + static constexpr GenericHID::SupportedOutputs SUPPORTED_OUTPUTS = + static_cast(8); + + /** Represents a digital button on a Switch2GCController. */ + enum class Button { + /// A button. + A = 0, + /// X button. + X = 1, + /// B button. + B = 2, + /// Y button. + Y = 3, + /// Home button. + HOME = 5, + /// Start button. + START = 6, + /// ZL button. + ZL = 9, + /// Z button. + Z = 10, + /// Dpad Up button. + DPAD_UP = 11, + /// Dpad Down button. + DPAD_DOWN = 12, + /// Dpad Left button. + DPAD_LEFT = 13, + /// Dpad Right button. + DPAD_RIGHT = 14, + /// Capture button. + CAPTURE = 15, + /// C button. + C = 21, + /// L button. + L = 22, + /// R button. + R = 23, + }; + + /** Represents an axis on a Switch2GCController. */ + enum class Axis { + /// Left X. + LEFT_X = 0, + /// Left Y. + LEFT_Y = 1, + /// C Stick X. + C_STICK_X = 2, + /// C Stick Y. + C_STICK_Y = 3, + /// L Trigger. + L_TRIGGER = 4, + /// R Trigger. + R_TRIGGER = 5, + }; + + /** + * Construct an instance of a controller. + * + * The controller index is the USB port on the Driver Station. + * + * @param port The port on the Driver Station that the controller is plugged + * into. + */ + explicit Switch2GCController(int port); + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + explicit Switch2GCController(GenericHID& hid); + + ~Switch2GCController() override = default; + + Switch2GCController(Switch2GCController&&) = default; + Switch2GCController& operator=(Switch2GCController&&) = default; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + GenericHID& GetHID() override; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + const GenericHID& GetHID() const override; + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + int GetPort() const; + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + bool IsConnected() const; + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the C Stick X value of the controller. + * + * @return the axis value. + */ + double GetCStickX() const; + + /** + * Get the C Stick Y value of the controller. + * + * @return the axis value. + */ + double GetCStickY() const; + + /** + * Get the L Trigger value of the controller. + * + * @return the axis value. + */ + double GetLTrigger() const; + + /** + * Get the R Trigger value of the controller. + * + * @return the axis value. + */ + double GetRTrigger() const; + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return the axis value. + */ + double GetAxis(Axis axis) const; + + /** + * Constructs an event instance that is true when the axis value is less than + * threshold. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the + * provided threshold. + */ + BooleanEvent AxisLessThan(Axis axis, double threshold, EventLoop* loop) const; + + /** + * Constructs an event instance that is true when the axis value is greater + * than threshold. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than + * the provided threshold. + */ + BooleanEvent AxisGreaterThan(Axis axis, double threshold, + EventLoop* loop) const; + + /** + * Read the value of the A button on the controller. + * + * @return The state of the button. + */ + bool GetAButton() const; + + /** + * Whether the A button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetAButtonPressed(); + + /** + * Whether the A button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetAButtonReleased(); + + /** + * Constructs an event instance around the A button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the A button's + * digital signal attached to the given loop. + */ + BooleanEvent A(EventLoop* loop) const; + + /** + * Read the value of the X button on the controller. + * + * @return The state of the button. + */ + bool GetXButton() const; + + /** + * Whether the X button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetXButtonPressed(); + + /** + * Whether the X button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetXButtonReleased(); + + /** + * Constructs an event instance around the X button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the X button's + * digital signal attached to the given loop. + */ + BooleanEvent X(EventLoop* loop) const; + + /** + * Read the value of the B button on the controller. + * + * @return The state of the button. + */ + bool GetBButton() const; + + /** + * Whether the B button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetBButtonPressed(); + + /** + * Whether the B button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetBButtonReleased(); + + /** + * Constructs an event instance around the B button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the B button's + * digital signal attached to the given loop. + */ + BooleanEvent B(EventLoop* loop) const; + + /** + * Read the value of the Y button on the controller. + * + * @return The state of the button. + */ + bool GetYButton() const; + + /** + * Whether the Y button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetYButtonPressed(); + + /** + * Whether the Y button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetYButtonReleased(); + + /** + * Constructs an event instance around the Y button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Y button's + * digital signal attached to the given loop. + */ + BooleanEvent Y(EventLoop* loop) const; + + /** + * Read the value of the Home button on the controller. + * + * @return The state of the button. + */ + bool GetHomeButton() const; + + /** + * Whether the Home button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetHomeButtonPressed(); + + /** + * Whether the Home button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetHomeButtonReleased(); + + /** + * Constructs an event instance around the Home button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Home button's + * digital signal attached to the given loop. + */ + BooleanEvent Home(EventLoop* loop) const; + + /** + * Read the value of the Start button on the controller. + * + * @return The state of the button. + */ + bool GetStartButton() const; + + /** + * Whether the Start button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetStartButtonPressed(); + + /** + * Whether the Start button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetStartButtonReleased(); + + /** + * Constructs an event instance around the Start button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Start button's + * digital signal attached to the given loop. + */ + BooleanEvent Start(EventLoop* loop) const; + + /** + * Read the value of the ZL button on the controller. + * + * @return The state of the button. + */ + bool GetZLButton() const; + + /** + * Whether the ZL button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetZLButtonPressed(); + + /** + * Whether the ZL button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetZLButtonReleased(); + + /** + * Constructs an event instance around the ZL button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the ZL button's + * digital signal attached to the given loop. + */ + BooleanEvent ZL(EventLoop* loop) const; + + /** + * Read the value of the Z button on the controller. + * + * @return The state of the button. + */ + bool GetZButton() const; + + /** + * Whether the Z button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetZButtonPressed(); + + /** + * Whether the Z button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetZButtonReleased(); + + /** + * Constructs an event instance around the Z button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Z button's + * digital signal attached to the given loop. + */ + BooleanEvent Z(EventLoop* loop) const; + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + bool GetDpadUpButton() const; + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadUpButtonPressed(); + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadUpButtonReleased(); + + /** + * Constructs an event instance around the Dpad Up button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadUp(EventLoop* loop) const; + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + bool GetDpadDownButton() const; + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadDownButtonPressed(); + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadDownButtonReleased(); + + /** + * Constructs an event instance around the Dpad Down button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadDown(EventLoop* loop) const; + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + bool GetDpadLeftButton() const; + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadLeftButtonPressed(); + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadLeftButtonReleased(); + + /** + * Constructs an event instance around the Dpad Left button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadLeft(EventLoop* loop) const; + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + bool GetDpadRightButton() const; + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadRightButtonPressed(); + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadRightButtonReleased(); + + /** + * Constructs an event instance around the Dpad Right button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadRight(EventLoop* loop) const; + + /** + * Read the value of the Capture button on the controller. + * + * @return The state of the button. + */ + bool GetCaptureButton() const; + + /** + * Whether the Capture button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetCaptureButtonPressed(); + + /** + * Whether the Capture button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetCaptureButtonReleased(); + + /** + * Constructs an event instance around the Capture button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Capture button's + * digital signal attached to the given loop. + */ + BooleanEvent Capture(EventLoop* loop) const; + + /** + * Read the value of the C button on the controller. + * + * @return The state of the button. + */ + bool GetCButton() const; + + /** + * Whether the C button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetCButtonPressed(); + + /** + * Whether the C button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetCButtonReleased(); + + /** + * Constructs an event instance around the C button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the C button's + * digital signal attached to the given loop. + */ + BooleanEvent C(EventLoop* loop) const; + + /** + * Read the value of the L button on the controller. + * + * @return The state of the button. + */ + bool GetLButton() const; + + /** + * Whether the L button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLButtonPressed(); + + /** + * Whether the L button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLButtonReleased(); + + /** + * Constructs an event instance around the L button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L button's + * digital signal attached to the given loop. + */ + BooleanEvent L(EventLoop* loop) const; + + /** + * Read the value of the R button on the controller. + * + * @return The state of the button. + */ + bool GetRButton() const; + + /** + * Whether the R button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRButtonPressed(); + + /** + * Whether the R button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRButtonReleased(); + + /** + * Constructs an event instance around the R button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R button's + * digital signal attached to the given loop. + */ + BooleanEvent R(EventLoop* loop) const; + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + bool GetButton(Button button) const; + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + bool GetButtonPressed(Button button); + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + bool GetButtonReleased(Button button); + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + BooleanEvent ButtonEvent(Button button, EventLoop* loop) const; + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + void SetLeds(int r, int g, int b); + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + void SetRumble(GenericHID::RumbleType type, double value); + + void InitSendable(wpi::util::SendableBuilder& builder) override; + + private: + GenericHID* m_hid; +}; + +} // namespace wpi diff --git a/wpilibc/src/generated/main/native/include/wpi/driverstation/Switch2ProController.hpp b/wpilibc/src/generated/main/native/include/wpi/driverstation/Switch2ProController.hpp new file mode 100644 index 0000000000..2cb0fa9f1c --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/driverstation/Switch2ProController.hpp @@ -0,0 +1,878 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/driverstation/GenericHID.hpp" +#include "wpi/driverstation/HIDDevice.hpp" +#include "wpi/driverstation/TouchpadFinger.hpp" +#include "wpi/util/sendable/Sendable.hpp" +#include "wpi/util/sendable/SendableHelper.hpp" + +namespace wpi { + +class BooleanEvent; +class EventLoop; + +/** + * Handle input from Switch2Pro controllers connected to the Driver Station. + * + * This class handles Switch2Pro input that comes from the Driver Station. + * Each time a value is requested the most recent value is returned. + */ +class Switch2ProController + : public HIDDevice, + public wpi::util::Sendable, + public wpi::util::SendableHelper { + public: + /** The number of touchpads supported by this controller. */ + static constexpr int TOUCHPAD_COUNT = 0; + + /** Whether this controller supports main rumble motors. */ + static constexpr bool SUPPORTS_RUMBLE = true; + + /** Whether this controller supports trigger rumble motors. */ + static constexpr bool SUPPORTS_TRIGGER_RUMBLE = false; + + /** Whether this controller supports mono LED output. */ + static constexpr bool SUPPORTS_MONO_LED = false; + + /** Whether this controller supports RGB LED output. */ + static constexpr bool SUPPORTS_RGB_LED = false; + + /** Supported outputs expected for this controller type. */ + static constexpr GenericHID::SupportedOutputs SUPPORTED_OUTPUTS = + static_cast(8); + + /** Represents a digital button on a Switch2ProController. */ + enum class Button { + /// B button. + B = 0, + /// A button. + A = 1, + /// Y button. + Y = 2, + /// X button. + X = 3, + /// Minus button. + MINUS = 4, + /// Home button. + HOME = 5, + /// Plus button. + PLUS = 6, + /// Left Stick button. + LEFT_STICK = 7, + /// Right Stick button. + RIGHT_STICK = 8, + /// L button. + L = 9, + /// R button. + R = 10, + /// Dpad Up button. + DPAD_UP = 11, + /// Dpad Down button. + DPAD_DOWN = 12, + /// Dpad Left button. + DPAD_LEFT = 13, + /// Dpad Right button. + DPAD_RIGHT = 14, + /// Capture button. + CAPTURE = 15, + /// GR button. + GR = 16, + /// GL button. + GL = 17, + /// C button. + C = 21, + }; + + /** Represents an axis on a Switch2ProController. */ + enum class Axis { + /// Left X. + LEFT_X = 0, + /// Left Y. + LEFT_Y = 1, + /// Right X. + RIGHT_X = 2, + /// Right Y. + RIGHT_Y = 3, + /// ZL. + ZL = 4, + /// ZR. + ZR = 5, + }; + + /** + * Construct an instance of a controller. + * + * The controller index is the USB port on the Driver Station. + * + * @param port The port on the Driver Station that the controller is plugged + * into. + */ + explicit Switch2ProController(int port); + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + explicit Switch2ProController(GenericHID& hid); + + ~Switch2ProController() override = default; + + Switch2ProController(Switch2ProController&&) = default; + Switch2ProController& operator=(Switch2ProController&&) = default; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + GenericHID& GetHID() override; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + const GenericHID& GetHID() const override; + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + int GetPort() const; + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + bool IsConnected() const; + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the Right X value of the controller. + * + * @return the axis value. + */ + double GetRightX() const; + + /** + * Get the Right Y value of the controller. + * + * @return the axis value. + */ + double GetRightY() const; + + /** + * Get the ZL value of the controller. + * + * @return the axis value. + */ + double GetZL() const; + + /** + * Get the ZR value of the controller. + * + * @return the axis value. + */ + double GetZR() const; + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return the axis value. + */ + double GetAxis(Axis axis) const; + + /** + * Constructs an event instance that is true when the axis value is less than + * threshold. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the + * provided threshold. + */ + BooleanEvent AxisLessThan(Axis axis, double threshold, EventLoop* loop) const; + + /** + * Constructs an event instance that is true when the axis value is greater + * than threshold. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than + * the provided threshold. + */ + BooleanEvent AxisGreaterThan(Axis axis, double threshold, + EventLoop* loop) const; + + /** + * Read the value of the B button on the controller. + * + * @return The state of the button. + */ + bool GetBButton() const; + + /** + * Whether the B button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetBButtonPressed(); + + /** + * Whether the B button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetBButtonReleased(); + + /** + * Constructs an event instance around the B button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the B button's + * digital signal attached to the given loop. + */ + BooleanEvent B(EventLoop* loop) const; + + /** + * Read the value of the A button on the controller. + * + * @return The state of the button. + */ + bool GetAButton() const; + + /** + * Whether the A button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetAButtonPressed(); + + /** + * Whether the A button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetAButtonReleased(); + + /** + * Constructs an event instance around the A button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the A button's + * digital signal attached to the given loop. + */ + BooleanEvent A(EventLoop* loop) const; + + /** + * Read the value of the Y button on the controller. + * + * @return The state of the button. + */ + bool GetYButton() const; + + /** + * Whether the Y button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetYButtonPressed(); + + /** + * Whether the Y button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetYButtonReleased(); + + /** + * Constructs an event instance around the Y button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Y button's + * digital signal attached to the given loop. + */ + BooleanEvent Y(EventLoop* loop) const; + + /** + * Read the value of the X button on the controller. + * + * @return The state of the button. + */ + bool GetXButton() const; + + /** + * Whether the X button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetXButtonPressed(); + + /** + * Whether the X button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetXButtonReleased(); + + /** + * Constructs an event instance around the X button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the X button's + * digital signal attached to the given loop. + */ + BooleanEvent X(EventLoop* loop) const; + + /** + * Read the value of the Minus button on the controller. + * + * @return The state of the button. + */ + bool GetMinusButton() const; + + /** + * Whether the Minus button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetMinusButtonPressed(); + + /** + * Whether the Minus button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetMinusButtonReleased(); + + /** + * Constructs an event instance around the Minus button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Minus button's + * digital signal attached to the given loop. + */ + BooleanEvent Minus(EventLoop* loop) const; + + /** + * Read the value of the Home button on the controller. + * + * @return The state of the button. + */ + bool GetHomeButton() const; + + /** + * Whether the Home button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetHomeButtonPressed(); + + /** + * Whether the Home button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetHomeButtonReleased(); + + /** + * Constructs an event instance around the Home button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Home button's + * digital signal attached to the given loop. + */ + BooleanEvent Home(EventLoop* loop) const; + + /** + * Read the value of the Plus button on the controller. + * + * @return The state of the button. + */ + bool GetPlusButton() const; + + /** + * Whether the Plus button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetPlusButtonPressed(); + + /** + * Whether the Plus button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetPlusButtonReleased(); + + /** + * Constructs an event instance around the Plus button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Plus button's + * digital signal attached to the given loop. + */ + BooleanEvent Plus(EventLoop* loop) const; + + /** + * Read the value of the Left Stick button on the controller. + * + * @return The state of the button. + */ + bool GetLeftStickButton() const; + + /** + * Whether the Left Stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLeftStickButtonPressed(); + + /** + * Whether the Left Stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLeftStickButtonReleased(); + + /** + * Constructs an event instance around the Left Stick button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Stick button's + * digital signal attached to the given loop. + */ + BooleanEvent LeftStick(EventLoop* loop) const; + + /** + * Read the value of the Right Stick button on the controller. + * + * @return The state of the button. + */ + bool GetRightStickButton() const; + + /** + * Whether the Right Stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightStickButtonPressed(); + + /** + * Whether the Right Stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightStickButtonReleased(); + + /** + * Constructs an event instance around the Right Stick button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Stick button's + * digital signal attached to the given loop. + */ + BooleanEvent RightStick(EventLoop* loop) const; + + /** + * Read the value of the L button on the controller. + * + * @return The state of the button. + */ + bool GetLButton() const; + + /** + * Whether the L button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLButtonPressed(); + + /** + * Whether the L button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLButtonReleased(); + + /** + * Constructs an event instance around the L button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L button's + * digital signal attached to the given loop. + */ + BooleanEvent L(EventLoop* loop) const; + + /** + * Read the value of the R button on the controller. + * + * @return The state of the button. + */ + bool GetRButton() const; + + /** + * Whether the R button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRButtonPressed(); + + /** + * Whether the R button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRButtonReleased(); + + /** + * Constructs an event instance around the R button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R button's + * digital signal attached to the given loop. + */ + BooleanEvent R(EventLoop* loop) const; + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + bool GetDpadUpButton() const; + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadUpButtonPressed(); + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadUpButtonReleased(); + + /** + * Constructs an event instance around the Dpad Up button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadUp(EventLoop* loop) const; + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + bool GetDpadDownButton() const; + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadDownButtonPressed(); + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadDownButtonReleased(); + + /** + * Constructs an event instance around the Dpad Down button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadDown(EventLoop* loop) const; + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + bool GetDpadLeftButton() const; + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadLeftButtonPressed(); + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadLeftButtonReleased(); + + /** + * Constructs an event instance around the Dpad Left button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadLeft(EventLoop* loop) const; + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + bool GetDpadRightButton() const; + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadRightButtonPressed(); + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadRightButtonReleased(); + + /** + * Constructs an event instance around the Dpad Right button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadRight(EventLoop* loop) const; + + /** + * Read the value of the Capture button on the controller. + * + * @return The state of the button. + */ + bool GetCaptureButton() const; + + /** + * Whether the Capture button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetCaptureButtonPressed(); + + /** + * Whether the Capture button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetCaptureButtonReleased(); + + /** + * Constructs an event instance around the Capture button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Capture button's + * digital signal attached to the given loop. + */ + BooleanEvent Capture(EventLoop* loop) const; + + /** + * Read the value of the GR button on the controller. + * + * @return The state of the button. + */ + bool GetGRButton() const; + + /** + * Whether the GR button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetGRButtonPressed(); + + /** + * Whether the GR button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetGRButtonReleased(); + + /** + * Constructs an event instance around the GR button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the GR button's + * digital signal attached to the given loop. + */ + BooleanEvent GR(EventLoop* loop) const; + + /** + * Read the value of the GL button on the controller. + * + * @return The state of the button. + */ + bool GetGLButton() const; + + /** + * Whether the GL button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetGLButtonPressed(); + + /** + * Whether the GL button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetGLButtonReleased(); + + /** + * Constructs an event instance around the GL button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the GL button's + * digital signal attached to the given loop. + */ + BooleanEvent GL(EventLoop* loop) const; + + /** + * Read the value of the C button on the controller. + * + * @return The state of the button. + */ + bool GetCButton() const; + + /** + * Whether the C button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetCButtonPressed(); + + /** + * Whether the C button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetCButtonReleased(); + + /** + * Constructs an event instance around the C button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the C button's + * digital signal attached to the given loop. + */ + BooleanEvent C(EventLoop* loop) const; + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + bool GetButton(Button button) const; + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + bool GetButtonPressed(Button button); + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + bool GetButtonReleased(Button button); + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + BooleanEvent ButtonEvent(Button button, EventLoop* loop) const; + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + void SetLeds(int r, int g, int b); + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + void SetRumble(GenericHID::RumbleType type, double value); + + void InitSendable(wpi::util::SendableBuilder& builder) override; + + private: + GenericHID* m_hid; +}; + +} // namespace wpi diff --git a/wpilibc/src/generated/main/native/include/wpi/driverstation/SwitchN64Controller.hpp b/wpilibc/src/generated/main/native/include/wpi/driverstation/SwitchN64Controller.hpp new file mode 100644 index 0000000000..6c11218830 --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/driverstation/SwitchN64Controller.hpp @@ -0,0 +1,728 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/driverstation/GenericHID.hpp" +#include "wpi/driverstation/HIDDevice.hpp" +#include "wpi/driverstation/TouchpadFinger.hpp" +#include "wpi/util/sendable/Sendable.hpp" +#include "wpi/util/sendable/SendableHelper.hpp" + +namespace wpi { + +class BooleanEvent; +class EventLoop; + +/** + * Handle input from SwitchN64 controllers connected to the Driver Station. + * + * This class handles SwitchN64 input that comes from the Driver Station. + * Each time a value is requested the most recent value is returned. + */ +class SwitchN64Controller + : public HIDDevice, + public wpi::util::Sendable, + public wpi::util::SendableHelper { + public: + /** The number of touchpads supported by this controller. */ + static constexpr int TOUCHPAD_COUNT = 0; + + /** Whether this controller supports main rumble motors. */ + static constexpr bool SUPPORTS_RUMBLE = false; + + /** Whether this controller supports trigger rumble motors. */ + static constexpr bool SUPPORTS_TRIGGER_RUMBLE = false; + + /** Whether this controller supports mono LED output. */ + static constexpr bool SUPPORTS_MONO_LED = false; + + /** Whether this controller supports RGB LED output. */ + static constexpr bool SUPPORTS_RGB_LED = false; + + /** Supported outputs expected for this controller type. */ + static constexpr GenericHID::SupportedOutputs SUPPORTED_OUTPUTS = + static_cast(0); + + /** Represents a digital button on a SwitchN64Controller. */ + enum class Button { + /// A button. + A = 0, + /// B button. + B = 1, + /// C Left button. + C_LEFT = 3, + /// C Up button. + C_UP = 4, + /// Capture button. + CAPTURE = 15, + /// Home button. + HOME = 5, + /// Start button. + START = 6, + /// C Down button. + C_DOWN = 2, + /// L button. + L = 9, + /// R button. + R = 10, + /// Dpad Up button. + DPAD_UP = 11, + /// Dpad Down button. + DPAD_DOWN = 12, + /// Dpad Left button. + DPAD_LEFT = 13, + /// Dpad Right button. + DPAD_RIGHT = 14, + /// C Right button. + C_RIGHT = 21, + }; + + /** Represents an axis on a SwitchN64Controller. */ + enum class Axis { + /// Left X. + LEFT_X = 0, + /// Left Y. + LEFT_Y = 1, + /// Z Axis. + Z_AXIS = 4, + /// ZR. + ZR = 5, + }; + + /** + * Construct an instance of a controller. + * + * The controller index is the USB port on the Driver Station. + * + * @param port The port on the Driver Station that the controller is plugged + * into. + */ + explicit SwitchN64Controller(int port); + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + explicit SwitchN64Controller(GenericHID& hid); + + ~SwitchN64Controller() override = default; + + SwitchN64Controller(SwitchN64Controller&&) = default; + SwitchN64Controller& operator=(SwitchN64Controller&&) = default; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + GenericHID& GetHID() override; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + const GenericHID& GetHID() const override; + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + int GetPort() const; + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + bool IsConnected() const; + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the Z Axis value of the controller. + * + * @return the axis value. + */ + double GetZAxis() const; + + /** + * Get the ZR value of the controller. + * + * @return the axis value. + */ + double GetZR() const; + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return the axis value. + */ + double GetAxis(Axis axis) const; + + /** + * Constructs an event instance that is true when the axis value is less than + * threshold. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the + * provided threshold. + */ + BooleanEvent AxisLessThan(Axis axis, double threshold, EventLoop* loop) const; + + /** + * Constructs an event instance that is true when the axis value is greater + * than threshold. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than + * the provided threshold. + */ + BooleanEvent AxisGreaterThan(Axis axis, double threshold, + EventLoop* loop) const; + + /** + * Read the value of the A button on the controller. + * + * @return The state of the button. + */ + bool GetAButton() const; + + /** + * Whether the A button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetAButtonPressed(); + + /** + * Whether the A button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetAButtonReleased(); + + /** + * Constructs an event instance around the A button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the A button's + * digital signal attached to the given loop. + */ + BooleanEvent A(EventLoop* loop) const; + + /** + * Read the value of the B button on the controller. + * + * @return The state of the button. + */ + bool GetBButton() const; + + /** + * Whether the B button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetBButtonPressed(); + + /** + * Whether the B button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetBButtonReleased(); + + /** + * Constructs an event instance around the B button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the B button's + * digital signal attached to the given loop. + */ + BooleanEvent B(EventLoop* loop) const; + + /** + * Read the value of the C Left button on the controller. + * + * @return The state of the button. + */ + bool GetCLeftButton() const; + + /** + * Whether the C Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetCLeftButtonPressed(); + + /** + * Whether the C Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetCLeftButtonReleased(); + + /** + * Constructs an event instance around the C Left button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the C Left button's + * digital signal attached to the given loop. + */ + BooleanEvent CLeft(EventLoop* loop) const; + + /** + * Read the value of the C Up button on the controller. + * + * @return The state of the button. + */ + bool GetCUpButton() const; + + /** + * Whether the C Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetCUpButtonPressed(); + + /** + * Whether the C Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetCUpButtonReleased(); + + /** + * Constructs an event instance around the C Up button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the C Up button's + * digital signal attached to the given loop. + */ + BooleanEvent CUp(EventLoop* loop) const; + + /** + * Read the value of the Capture button on the controller. + * + * @return The state of the button. + */ + bool GetCaptureButton() const; + + /** + * Whether the Capture button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetCaptureButtonPressed(); + + /** + * Whether the Capture button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetCaptureButtonReleased(); + + /** + * Constructs an event instance around the Capture button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Capture button's + * digital signal attached to the given loop. + */ + BooleanEvent Capture(EventLoop* loop) const; + + /** + * Read the value of the Home button on the controller. + * + * @return The state of the button. + */ + bool GetHomeButton() const; + + /** + * Whether the Home button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetHomeButtonPressed(); + + /** + * Whether the Home button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetHomeButtonReleased(); + + /** + * Constructs an event instance around the Home button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Home button's + * digital signal attached to the given loop. + */ + BooleanEvent Home(EventLoop* loop) const; + + /** + * Read the value of the Start button on the controller. + * + * @return The state of the button. + */ + bool GetStartButton() const; + + /** + * Whether the Start button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetStartButtonPressed(); + + /** + * Whether the Start button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetStartButtonReleased(); + + /** + * Constructs an event instance around the Start button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Start button's + * digital signal attached to the given loop. + */ + BooleanEvent Start(EventLoop* loop) const; + + /** + * Read the value of the C Down button on the controller. + * + * @return The state of the button. + */ + bool GetCDownButton() const; + + /** + * Whether the C Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetCDownButtonPressed(); + + /** + * Whether the C Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetCDownButtonReleased(); + + /** + * Constructs an event instance around the C Down button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the C Down button's + * digital signal attached to the given loop. + */ + BooleanEvent CDown(EventLoop* loop) const; + + /** + * Read the value of the L button on the controller. + * + * @return The state of the button. + */ + bool GetLButton() const; + + /** + * Whether the L button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLButtonPressed(); + + /** + * Whether the L button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLButtonReleased(); + + /** + * Constructs an event instance around the L button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L button's + * digital signal attached to the given loop. + */ + BooleanEvent L(EventLoop* loop) const; + + /** + * Read the value of the R button on the controller. + * + * @return The state of the button. + */ + bool GetRButton() const; + + /** + * Whether the R button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRButtonPressed(); + + /** + * Whether the R button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRButtonReleased(); + + /** + * Constructs an event instance around the R button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R button's + * digital signal attached to the given loop. + */ + BooleanEvent R(EventLoop* loop) const; + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + bool GetDpadUpButton() const; + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadUpButtonPressed(); + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadUpButtonReleased(); + + /** + * Constructs an event instance around the Dpad Up button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadUp(EventLoop* loop) const; + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + bool GetDpadDownButton() const; + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadDownButtonPressed(); + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadDownButtonReleased(); + + /** + * Constructs an event instance around the Dpad Down button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadDown(EventLoop* loop) const; + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + bool GetDpadLeftButton() const; + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadLeftButtonPressed(); + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadLeftButtonReleased(); + + /** + * Constructs an event instance around the Dpad Left button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadLeft(EventLoop* loop) const; + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + bool GetDpadRightButton() const; + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadRightButtonPressed(); + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadRightButtonReleased(); + + /** + * Constructs an event instance around the Dpad Right button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadRight(EventLoop* loop) const; + + /** + * Read the value of the C Right button on the controller. + * + * @return The state of the button. + */ + bool GetCRightButton() const; + + /** + * Whether the C Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetCRightButtonPressed(); + + /** + * Whether the C Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetCRightButtonReleased(); + + /** + * Constructs an event instance around the C Right button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the C Right button's + * digital signal attached to the given loop. + */ + BooleanEvent CRight(EventLoop* loop) const; + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + bool GetButton(Button button) const; + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + bool GetButtonPressed(Button button); + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + bool GetButtonReleased(Button button); + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + BooleanEvent ButtonEvent(Button button, EventLoop* loop) const; + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + void SetLeds(int r, int g, int b); + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + void SetRumble(GenericHID::RumbleType type, double value); + + void InitSendable(wpi::util::SendableBuilder& builder) override; + + private: + GenericHID* m_hid; +}; + +} // namespace wpi diff --git a/wpilibc/src/generated/main/native/include/wpi/driverstation/SwitchProController.hpp b/wpilibc/src/generated/main/native/include/wpi/driverstation/SwitchProController.hpp new file mode 100644 index 0000000000..93d6aa75f6 --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/driverstation/SwitchProController.hpp @@ -0,0 +1,779 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/driverstation/GenericHID.hpp" +#include "wpi/driverstation/HIDDevice.hpp" +#include "wpi/driverstation/TouchpadFinger.hpp" +#include "wpi/util/sendable/Sendable.hpp" +#include "wpi/util/sendable/SendableHelper.hpp" + +namespace wpi { + +class BooleanEvent; +class EventLoop; + +/** + * Handle input from SwitchPro controllers connected to the Driver Station. + * + * This class handles SwitchPro input that comes from the Driver Station. + * Each time a value is requested the most recent value is returned. + */ +class SwitchProController + : public HIDDevice, + public wpi::util::Sendable, + public wpi::util::SendableHelper { + public: + /** The number of touchpads supported by this controller. */ + static constexpr int TOUCHPAD_COUNT = 0; + + /** Whether this controller supports main rumble motors. */ + static constexpr bool SUPPORTS_RUMBLE = true; + + /** Whether this controller supports trigger rumble motors. */ + static constexpr bool SUPPORTS_TRIGGER_RUMBLE = false; + + /** Whether this controller supports mono LED output. */ + static constexpr bool SUPPORTS_MONO_LED = true; + + /** Whether this controller supports RGB LED output. */ + static constexpr bool SUPPORTS_RGB_LED = false; + + /** Supported outputs expected for this controller type. */ + static constexpr GenericHID::SupportedOutputs SUPPORTED_OUTPUTS = + static_cast(9); + + /** Represents a digital button on a SwitchProController. */ + enum class Button { + /// B button. + B = 0, + /// A button. + A = 1, + /// Y button. + Y = 2, + /// X button. + X = 3, + /// Minus button. + MINUS = 4, + /// Home button. + HOME = 5, + /// Plus button. + PLUS = 6, + /// Left Stick button. + LEFT_STICK = 7, + /// Right Stick button. + RIGHT_STICK = 8, + /// L button. + L = 9, + /// R button. + R = 10, + /// Dpad Up button. + DPAD_UP = 11, + /// Dpad Down button. + DPAD_DOWN = 12, + /// Dpad Left button. + DPAD_LEFT = 13, + /// Dpad Right button. + DPAD_RIGHT = 14, + /// Capture button. + CAPTURE = 15, + }; + + /** Represents an axis on a SwitchProController. */ + enum class Axis { + /// Left X. + LEFT_X = 0, + /// Left Y. + LEFT_Y = 1, + /// Right X. + RIGHT_X = 2, + /// Right Y. + RIGHT_Y = 3, + /// ZL. + ZL = 4, + /// ZR. + ZR = 5, + }; + + /** + * Construct an instance of a controller. + * + * The controller index is the USB port on the Driver Station. + * + * @param port The port on the Driver Station that the controller is plugged + * into. + */ + explicit SwitchProController(int port); + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + explicit SwitchProController(GenericHID& hid); + + ~SwitchProController() override = default; + + SwitchProController(SwitchProController&&) = default; + SwitchProController& operator=(SwitchProController&&) = default; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + GenericHID& GetHID() override; + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + const GenericHID& GetHID() const override; + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + int GetPort() const; + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + bool IsConnected() const; + + /** + * Get the Left X value of the controller. + * + * @return the axis value. + */ + double GetLeftX() const; + + /** + * Get the Left Y value of the controller. + * + * @return the axis value. + */ + double GetLeftY() const; + + /** + * Get the Right X value of the controller. + * + * @return the axis value. + */ + double GetRightX() const; + + /** + * Get the Right Y value of the controller. + * + * @return the axis value. + */ + double GetRightY() const; + + /** + * Get the ZL value of the controller. + * + * @return the axis value. + */ + double GetZL() const; + + /** + * Get the ZR value of the controller. + * + * @return the axis value. + */ + double GetZR() const; + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return the axis value. + */ + double GetAxis(Axis axis) const; + + /** + * Constructs an event instance that is true when the axis value is less than + * threshold. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the + * provided threshold. + */ + BooleanEvent AxisLessThan(Axis axis, double threshold, EventLoop* loop) const; + + /** + * Constructs an event instance that is true when the axis value is greater + * than threshold. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than + * the provided threshold. + */ + BooleanEvent AxisGreaterThan(Axis axis, double threshold, + EventLoop* loop) const; + + /** + * Read the value of the B button on the controller. + * + * @return The state of the button. + */ + bool GetBButton() const; + + /** + * Whether the B button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetBButtonPressed(); + + /** + * Whether the B button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetBButtonReleased(); + + /** + * Constructs an event instance around the B button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the B button's + * digital signal attached to the given loop. + */ + BooleanEvent B(EventLoop* loop) const; + + /** + * Read the value of the A button on the controller. + * + * @return The state of the button. + */ + bool GetAButton() const; + + /** + * Whether the A button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetAButtonPressed(); + + /** + * Whether the A button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetAButtonReleased(); + + /** + * Constructs an event instance around the A button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the A button's + * digital signal attached to the given loop. + */ + BooleanEvent A(EventLoop* loop) const; + + /** + * Read the value of the Y button on the controller. + * + * @return The state of the button. + */ + bool GetYButton() const; + + /** + * Whether the Y button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetYButtonPressed(); + + /** + * Whether the Y button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetYButtonReleased(); + + /** + * Constructs an event instance around the Y button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Y button's + * digital signal attached to the given loop. + */ + BooleanEvent Y(EventLoop* loop) const; + + /** + * Read the value of the X button on the controller. + * + * @return The state of the button. + */ + bool GetXButton() const; + + /** + * Whether the X button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetXButtonPressed(); + + /** + * Whether the X button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetXButtonReleased(); + + /** + * Constructs an event instance around the X button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the X button's + * digital signal attached to the given loop. + */ + BooleanEvent X(EventLoop* loop) const; + + /** + * Read the value of the Minus button on the controller. + * + * @return The state of the button. + */ + bool GetMinusButton() const; + + /** + * Whether the Minus button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetMinusButtonPressed(); + + /** + * Whether the Minus button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetMinusButtonReleased(); + + /** + * Constructs an event instance around the Minus button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Minus button's + * digital signal attached to the given loop. + */ + BooleanEvent Minus(EventLoop* loop) const; + + /** + * Read the value of the Home button on the controller. + * + * @return The state of the button. + */ + bool GetHomeButton() const; + + /** + * Whether the Home button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetHomeButtonPressed(); + + /** + * Whether the Home button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetHomeButtonReleased(); + + /** + * Constructs an event instance around the Home button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Home button's + * digital signal attached to the given loop. + */ + BooleanEvent Home(EventLoop* loop) const; + + /** + * Read the value of the Plus button on the controller. + * + * @return The state of the button. + */ + bool GetPlusButton() const; + + /** + * Whether the Plus button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetPlusButtonPressed(); + + /** + * Whether the Plus button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetPlusButtonReleased(); + + /** + * Constructs an event instance around the Plus button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Plus button's + * digital signal attached to the given loop. + */ + BooleanEvent Plus(EventLoop* loop) const; + + /** + * Read the value of the Left Stick button on the controller. + * + * @return The state of the button. + */ + bool GetLeftStickButton() const; + + /** + * Whether the Left Stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLeftStickButtonPressed(); + + /** + * Whether the Left Stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLeftStickButtonReleased(); + + /** + * Constructs an event instance around the Left Stick button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Stick button's + * digital signal attached to the given loop. + */ + BooleanEvent LeftStick(EventLoop* loop) const; + + /** + * Read the value of the Right Stick button on the controller. + * + * @return The state of the button. + */ + bool GetRightStickButton() const; + + /** + * Whether the Right Stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightStickButtonPressed(); + + /** + * Whether the Right Stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightStickButtonReleased(); + + /** + * Constructs an event instance around the Right Stick button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Stick button's + * digital signal attached to the given loop. + */ + BooleanEvent RightStick(EventLoop* loop) const; + + /** + * Read the value of the L button on the controller. + * + * @return The state of the button. + */ + bool GetLButton() const; + + /** + * Whether the L button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLButtonPressed(); + + /** + * Whether the L button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLButtonReleased(); + + /** + * Constructs an event instance around the L button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L button's + * digital signal attached to the given loop. + */ + BooleanEvent L(EventLoop* loop) const; + + /** + * Read the value of the R button on the controller. + * + * @return The state of the button. + */ + bool GetRButton() const; + + /** + * Whether the R button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRButtonPressed(); + + /** + * Whether the R button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRButtonReleased(); + + /** + * Constructs an event instance around the R button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R button's + * digital signal attached to the given loop. + */ + BooleanEvent R(EventLoop* loop) const; + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + bool GetDpadUpButton() const; + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadUpButtonPressed(); + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadUpButtonReleased(); + + /** + * Constructs an event instance around the Dpad Up button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadUp(EventLoop* loop) const; + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + bool GetDpadDownButton() const; + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadDownButtonPressed(); + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadDownButtonReleased(); + + /** + * Constructs an event instance around the Dpad Down button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadDown(EventLoop* loop) const; + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + bool GetDpadLeftButton() const; + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadLeftButtonPressed(); + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadLeftButtonReleased(); + + /** + * Constructs an event instance around the Dpad Left button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadLeft(EventLoop* loop) const; + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + bool GetDpadRightButton() const; + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetDpadRightButtonPressed(); + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetDpadRightButtonReleased(); + + /** + * Constructs an event instance around the Dpad Right button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's + * digital signal attached to the given loop. + */ + BooleanEvent DpadRight(EventLoop* loop) const; + + /** + * Read the value of the Capture button on the controller. + * + * @return The state of the button. + */ + bool GetCaptureButton() const; + + /** + * Whether the Capture button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetCaptureButtonPressed(); + + /** + * Whether the Capture button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetCaptureButtonReleased(); + + /** + * Constructs an event instance around the Capture button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Capture button's + * digital signal attached to the given loop. + */ + BooleanEvent Capture(EventLoop* loop) const; + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + bool GetButton(Button button) const; + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + bool GetButtonPressed(Button button); + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + bool GetButtonReleased(Button button); + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + BooleanEvent ButtonEvent(Button button, EventLoop* loop) const; + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + void SetLeds(int r, int g, int b); + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + void SetRumble(GenericHID::RumbleType type, double value); + + void InitSendable(wpi::util::SendableBuilder& builder) override; + + private: + GenericHID* m_hid; +}; + +} // namespace wpi diff --git a/wpilibc/src/generated/main/native/include/wpi/simulation/DualSenseEdgeControllerSim.hpp b/wpilibc/src/generated/main/native/include/wpi/simulation/DualSenseEdgeControllerSim.hpp new file mode 100644 index 0000000000..219a261f83 --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/simulation/DualSenseEdgeControllerSim.hpp @@ -0,0 +1,226 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/simulation/GenericHIDSim.hpp" + +namespace wpi { + +class DualSenseEdgeController; + +namespace sim { + +/** + * Class to control a simulated DualSenseEdge controller. + */ +class DualSenseEdgeControllerSim : public GenericHIDSim { + public: + /** + * Constructs from a DualSenseEdgeController object. + * + * @param joystick controller to simulate + */ + explicit DualSenseEdgeControllerSim(const DualSenseEdgeController& joystick); + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + explicit DualSenseEdgeControllerSim(int port); + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + void SetLeftX(double value); + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + void SetLeftY(double value); + + /** + * Change the Right X value of the controller. + * + * @param value the new value + */ + void SetRightX(double value); + + /** + * Change the Right Y value of the controller. + * + * @param value the new value + */ + void SetRightY(double value); + + /** + * Change the L 2 value of the controller. + * + * @param value the new value + */ + void SetL2(double value); + + /** + * Change the R 2 value of the controller. + * + * @param value the new value + */ + void SetR2(double value); + + /** + * Change the value of the Cross button on the controller. + * + * @param value the new value + */ + void SetCrossButton(bool value); + + /** + * Change the value of the Circle button on the controller. + * + * @param value the new value + */ + void SetCircleButton(bool value); + + /** + * Change the value of the Square button on the controller. + * + * @param value the new value + */ + void SetSquareButton(bool value); + + /** + * Change the value of the Triangle button on the controller. + * + * @param value the new value + */ + void SetTriangleButton(bool value); + + /** + * Change the value of the Create button on the controller. + * + * @param value the new value + */ + void SetCreateButton(bool value); + + /** + * Change the value of the PS button on the controller. + * + * @param value the new value + */ + void SetPSButton(bool value); + + /** + * Change the value of the Options button on the controller. + * + * @param value the new value + */ + void SetOptionsButton(bool value); + + /** + * Change the value of the L 3 button on the controller. + * + * @param value the new value + */ + void SetL3Button(bool value); + + /** + * Change the value of the R 3 button on the controller. + * + * @param value the new value + */ + void SetR3Button(bool value); + + /** + * Change the value of the L 1 button on the controller. + * + * @param value the new value + */ + void SetL1Button(bool value); + + /** + * Change the value of the R 1 button on the controller. + * + * @param value the new value + */ + void SetR1Button(bool value); + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + void SetDpadUpButton(bool value); + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + void SetDpadDownButton(bool value); + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + void SetDpadLeftButton(bool value); + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + void SetDpadRightButton(bool value); + + /** + * Change the value of the Microphone button on the controller. + * + * @param value the new value + */ + void SetMicrophoneButton(bool value); + + /** + * Change the value of the Right Paddle 1 button on the controller. + * + * @param value the new value + */ + void SetRightPaddle1Button(bool value); + + /** + * Change the value of the Left Paddle 1 button on the controller. + * + * @param value the new value + */ + void SetLeftPaddle1Button(bool value); + + /** + * Change the value of the Touchpad button on the controller. + * + * @param value the new value + */ + void SetTouchpadButton(bool value); + + /** + * Change the value of the Left Function button on the controller. + * + * @param value the new value + */ + void SetLeftFunctionButton(bool value); + + /** + * Change the value of the Right Function button on the controller. + * + * @param value the new value + */ + void SetRightFunctionButton(bool value); +}; + +} // namespace sim +} // namespace wpi diff --git a/wpilibc/src/generated/main/native/include/wpi/simulation/DualShock4ControllerSim.hpp b/wpilibc/src/generated/main/native/include/wpi/simulation/DualShock4ControllerSim.hpp new file mode 100644 index 0000000000..9db6bcf44a --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/simulation/DualShock4ControllerSim.hpp @@ -0,0 +1,191 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/simulation/GenericHIDSim.hpp" + +namespace wpi { + +class DualShock4Controller; + +namespace sim { + +/** + * Class to control a simulated DualShock4 controller. + */ +class DualShock4ControllerSim : public GenericHIDSim { + public: + /** + * Constructs from a DualShock4Controller object. + * + * @param joystick controller to simulate + */ + explicit DualShock4ControllerSim(const DualShock4Controller& joystick); + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + explicit DualShock4ControllerSim(int port); + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + void SetLeftX(double value); + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + void SetLeftY(double value); + + /** + * Change the Right X value of the controller. + * + * @param value the new value + */ + void SetRightX(double value); + + /** + * Change the Right Y value of the controller. + * + * @param value the new value + */ + void SetRightY(double value); + + /** + * Change the L 2 value of the controller. + * + * @param value the new value + */ + void SetL2(double value); + + /** + * Change the R 2 value of the controller. + * + * @param value the new value + */ + void SetR2(double value); + + /** + * Change the value of the Cross button on the controller. + * + * @param value the new value + */ + void SetCrossButton(bool value); + + /** + * Change the value of the Circle button on the controller. + * + * @param value the new value + */ + void SetCircleButton(bool value); + + /** + * Change the value of the Square button on the controller. + * + * @param value the new value + */ + void SetSquareButton(bool value); + + /** + * Change the value of the Triangle button on the controller. + * + * @param value the new value + */ + void SetTriangleButton(bool value); + + /** + * Change the value of the Share button on the controller. + * + * @param value the new value + */ + void SetShareButton(bool value); + + /** + * Change the value of the PS button on the controller. + * + * @param value the new value + */ + void SetPSButton(bool value); + + /** + * Change the value of the Options button on the controller. + * + * @param value the new value + */ + void SetOptionsButton(bool value); + + /** + * Change the value of the L 3 button on the controller. + * + * @param value the new value + */ + void SetL3Button(bool value); + + /** + * Change the value of the R 3 button on the controller. + * + * @param value the new value + */ + void SetR3Button(bool value); + + /** + * Change the value of the L 1 button on the controller. + * + * @param value the new value + */ + void SetL1Button(bool value); + + /** + * Change the value of the R 1 button on the controller. + * + * @param value the new value + */ + void SetR1Button(bool value); + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + void SetDpadUpButton(bool value); + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + void SetDpadDownButton(bool value); + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + void SetDpadLeftButton(bool value); + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + void SetDpadRightButton(bool value); + + /** + * Change the value of the Touchpad button on the controller. + * + * @param value the new value + */ + void SetTouchpadButton(bool value); +}; + +} // namespace sim +} // namespace wpi diff --git a/wpilibc/src/generated/main/native/include/wpi/simulation/GameCubeControllerSim.hpp b/wpilibc/src/generated/main/native/include/wpi/simulation/GameCubeControllerSim.hpp new file mode 100644 index 0000000000..3ee07076d4 --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/simulation/GameCubeControllerSim.hpp @@ -0,0 +1,163 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/simulation/GenericHIDSim.hpp" + +namespace wpi { + +class GameCubeController; + +namespace sim { + +/** + * Class to control a simulated GameCube controller. + */ +class GameCubeControllerSim : public GenericHIDSim { + public: + /** + * Constructs from a GameCubeController object. + * + * @param joystick controller to simulate + */ + explicit GameCubeControllerSim(const GameCubeController& joystick); + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + explicit GameCubeControllerSim(int port); + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + void SetLeftX(double value); + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + void SetLeftY(double value); + + /** + * Change the C Stick X value of the controller. + * + * @param value the new value + */ + void SetCStickX(double value); + + /** + * Change the C Stick Y value of the controller. + * + * @param value the new value + */ + void SetCStickY(double value); + + /** + * Change the L Trigger value of the controller. + * + * @param value the new value + */ + void SetLTrigger(double value); + + /** + * Change the R Trigger value of the controller. + * + * @param value the new value + */ + void SetRTrigger(double value); + + /** + * Change the value of the A button on the controller. + * + * @param value the new value + */ + void SetAButton(bool value); + + /** + * Change the value of the X button on the controller. + * + * @param value the new value + */ + void SetXButton(bool value); + + /** + * Change the value of the B button on the controller. + * + * @param value the new value + */ + void SetBButton(bool value); + + /** + * Change the value of the Y button on the controller. + * + * @param value the new value + */ + void SetYButton(bool value); + + /** + * Change the value of the Start button on the controller. + * + * @param value the new value + */ + void SetStartButton(bool value); + + /** + * Change the value of the Z button on the controller. + * + * @param value the new value + */ + void SetZButton(bool value); + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + void SetDpadUpButton(bool value); + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + void SetDpadDownButton(bool value); + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + void SetDpadLeftButton(bool value); + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + void SetDpadRightButton(bool value); + + /** + * Change the value of the L button on the controller. + * + * @param value the new value + */ + void SetLButton(bool value); + + /** + * Change the value of the R button on the controller. + * + * @param value the new value + */ + void SetRButton(bool value); +}; + +} // namespace sim +} // namespace wpi diff --git a/wpilibc/src/generated/main/native/include/wpi/simulation/LogitechF310ControllerSim.hpp b/wpilibc/src/generated/main/native/include/wpi/simulation/LogitechF310ControllerSim.hpp new file mode 100644 index 0000000000..69e0923af8 --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/simulation/LogitechF310ControllerSim.hpp @@ -0,0 +1,184 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/simulation/GenericHIDSim.hpp" + +namespace wpi { + +class LogitechF310Controller; + +namespace sim { + +/** + * Class to control a simulated LogitechF310 controller. + */ +class LogitechF310ControllerSim : public GenericHIDSim { + public: + /** + * Constructs from a LogitechF310Controller object. + * + * @param joystick controller to simulate + */ + explicit LogitechF310ControllerSim(const LogitechF310Controller& joystick); + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + explicit LogitechF310ControllerSim(int port); + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + void SetLeftX(double value); + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + void SetLeftY(double value); + + /** + * Change the Right X value of the controller. + * + * @param value the new value + */ + void SetRightX(double value); + + /** + * Change the Right Y value of the controller. + * + * @param value the new value + */ + void SetRightY(double value); + + /** + * Change the Left Trigger value of the controller. + * + * @param value the new value + */ + void SetLeftTrigger(double value); + + /** + * Change the Right Trigger value of the controller. + * + * @param value the new value + */ + void SetRightTrigger(double value); + + /** + * Change the value of the A button on the controller. + * + * @param value the new value + */ + void SetAButton(bool value); + + /** + * Change the value of the B button on the controller. + * + * @param value the new value + */ + void SetBButton(bool value); + + /** + * Change the value of the X button on the controller. + * + * @param value the new value + */ + void SetXButton(bool value); + + /** + * Change the value of the Y button on the controller. + * + * @param value the new value + */ + void SetYButton(bool value); + + /** + * Change the value of the Back button on the controller. + * + * @param value the new value + */ + void SetBackButton(bool value); + + /** + * Change the value of the Logitech button on the controller. + * + * @param value the new value + */ + void SetLogitechButton(bool value); + + /** + * Change the value of the Start button on the controller. + * + * @param value the new value + */ + void SetStartButton(bool value); + + /** + * Change the value of the Left Stick button on the controller. + * + * @param value the new value + */ + void SetLeftStickButton(bool value); + + /** + * Change the value of the Right Stick button on the controller. + * + * @param value the new value + */ + void SetRightStickButton(bool value); + + /** + * Change the value of the Left Bumper button on the controller. + * + * @param value the new value + */ + void SetLeftBumperButton(bool value); + + /** + * Change the value of the Right Bumper button on the controller. + * + * @param value the new value + */ + void SetRightBumperButton(bool value); + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + void SetDpadUpButton(bool value); + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + void SetDpadDownButton(bool value); + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + void SetDpadLeftButton(bool value); + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + void SetDpadRightButton(bool value); +}; + +} // namespace sim +} // namespace wpi diff --git a/wpilibc/src/generated/main/native/include/wpi/simulation/SteamControllerSim.hpp b/wpilibc/src/generated/main/native/include/wpi/simulation/SteamControllerSim.hpp new file mode 100644 index 0000000000..0cad81161c --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/simulation/SteamControllerSim.hpp @@ -0,0 +1,261 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/simulation/GenericHIDSim.hpp" + +namespace wpi { + +class SteamController; + +namespace sim { + +/** + * Class to control a simulated Steam controller. + */ +class SteamControllerSim : public GenericHIDSim { + public: + /** + * Constructs from a SteamController object. + * + * @param joystick controller to simulate + */ + explicit SteamControllerSim(const SteamController& joystick); + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + explicit SteamControllerSim(int port); + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + void SetLeftX(double value); + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + void SetLeftY(double value); + + /** + * Change the Right X value of the controller. + * + * @param value the new value + */ + void SetRightX(double value); + + /** + * Change the Right Y value of the controller. + * + * @param value the new value + */ + void SetRightY(double value); + + /** + * Change the Left Trigger value of the controller. + * + * @param value the new value + */ + void SetLeftTrigger(double value); + + /** + * Change the Right Trigger value of the controller. + * + * @param value the new value + */ + void SetRightTrigger(double value); + + /** + * Change the value of the A button on the controller. + * + * @param value the new value + */ + void SetAButton(bool value); + + /** + * Change the value of the B button on the controller. + * + * @param value the new value + */ + void SetBButton(bool value); + + /** + * Change the value of the X button on the controller. + * + * @param value the new value + */ + void SetXButton(bool value); + + /** + * Change the value of the Y button on the controller. + * + * @param value the new value + */ + void SetYButton(bool value); + + /** + * Change the value of the Menu button on the controller. + * + * @param value the new value + */ + void SetMenuButton(bool value); + + /** + * Change the value of the Steam button on the controller. + * + * @param value the new value + */ + void SetSteamButton(bool value); + + /** + * Change the value of the View button on the controller. + * + * @param value the new value + */ + void SetViewButton(bool value); + + /** + * Change the value of the Left Stick button on the controller. + * + * @param value the new value + */ + void SetLeftStickButton(bool value); + + /** + * Change the value of the Right Stick button on the controller. + * + * @param value the new value + */ + void SetRightStickButton(bool value); + + /** + * Change the value of the Left Bumper button on the controller. + * + * @param value the new value + */ + void SetLeftBumperButton(bool value); + + /** + * Change the value of the Right Bumper button on the controller. + * + * @param value the new value + */ + void SetRightBumperButton(bool value); + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + void SetDpadUpButton(bool value); + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + void SetDpadDownButton(bool value); + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + void SetDpadLeftButton(bool value); + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + void SetDpadRightButton(bool value); + + /** + * Change the value of the QAM button on the controller. + * + * @param value the new value + */ + void SetQAMButton(bool value); + + /** + * Change the value of the Right Paddle 1 button on the controller. + * + * @param value the new value + */ + void SetRightPaddle1Button(bool value); + + /** + * Change the value of the Left Paddle 1 button on the controller. + * + * @param value the new value + */ + void SetLeftPaddle1Button(bool value); + + /** + * Change the value of the Right Paddle 2 button on the controller. + * + * @param value the new value + */ + void SetRightPaddle2Button(bool value); + + /** + * Change the value of the Left Paddle 2 button on the controller. + * + * @param value the new value + */ + void SetLeftPaddle2Button(bool value); + + /** + * Change the value of the Left Touchpad button on the controller. + * + * @param value the new value + */ + void SetLeftTouchpadButton(bool value); + + /** + * Change the value of the Right Touchpad button on the controller. + * + * @param value the new value + */ + void SetRightTouchpadButton(bool value); + + /** + * Change the value of the Left Stick Touch button on the controller. + * + * @param value the new value + */ + void SetLeftStickTouchButton(bool value); + + /** + * Change the value of the Right Stick Touch button on the controller. + * + * @param value the new value + */ + void SetRightStickTouchButton(bool value); + + /** + * Change the value of the Left Grip Touch button on the controller. + * + * @param value the new value + */ + void SetLeftGripTouchButton(bool value); + + /** + * Change the value of the Right Grip Touch button on the controller. + * + * @param value the new value + */ + void SetRightGripTouchButton(bool value); +}; + +} // namespace sim +} // namespace wpi diff --git a/wpilibc/src/generated/main/native/include/wpi/simulation/Switch2GCControllerSim.hpp b/wpilibc/src/generated/main/native/include/wpi/simulation/Switch2GCControllerSim.hpp new file mode 100644 index 0000000000..3f1357ff3d --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/simulation/Switch2GCControllerSim.hpp @@ -0,0 +1,191 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/simulation/GenericHIDSim.hpp" + +namespace wpi { + +class Switch2GCController; + +namespace sim { + +/** + * Class to control a simulated Switch2GC controller. + */ +class Switch2GCControllerSim : public GenericHIDSim { + public: + /** + * Constructs from a Switch2GCController object. + * + * @param joystick controller to simulate + */ + explicit Switch2GCControllerSim(const Switch2GCController& joystick); + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + explicit Switch2GCControllerSim(int port); + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + void SetLeftX(double value); + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + void SetLeftY(double value); + + /** + * Change the C Stick X value of the controller. + * + * @param value the new value + */ + void SetCStickX(double value); + + /** + * Change the C Stick Y value of the controller. + * + * @param value the new value + */ + void SetCStickY(double value); + + /** + * Change the L Trigger value of the controller. + * + * @param value the new value + */ + void SetLTrigger(double value); + + /** + * Change the R Trigger value of the controller. + * + * @param value the new value + */ + void SetRTrigger(double value); + + /** + * Change the value of the A button on the controller. + * + * @param value the new value + */ + void SetAButton(bool value); + + /** + * Change the value of the X button on the controller. + * + * @param value the new value + */ + void SetXButton(bool value); + + /** + * Change the value of the B button on the controller. + * + * @param value the new value + */ + void SetBButton(bool value); + + /** + * Change the value of the Y button on the controller. + * + * @param value the new value + */ + void SetYButton(bool value); + + /** + * Change the value of the Home button on the controller. + * + * @param value the new value + */ + void SetHomeButton(bool value); + + /** + * Change the value of the Start button on the controller. + * + * @param value the new value + */ + void SetStartButton(bool value); + + /** + * Change the value of the ZL button on the controller. + * + * @param value the new value + */ + void SetZLButton(bool value); + + /** + * Change the value of the Z button on the controller. + * + * @param value the new value + */ + void SetZButton(bool value); + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + void SetDpadUpButton(bool value); + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + void SetDpadDownButton(bool value); + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + void SetDpadLeftButton(bool value); + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + void SetDpadRightButton(bool value); + + /** + * Change the value of the Capture button on the controller. + * + * @param value the new value + */ + void SetCaptureButton(bool value); + + /** + * Change the value of the C button on the controller. + * + * @param value the new value + */ + void SetCButton(bool value); + + /** + * Change the value of the L button on the controller. + * + * @param value the new value + */ + void SetLButton(bool value); + + /** + * Change the value of the R button on the controller. + * + * @param value the new value + */ + void SetRButton(bool value); +}; + +} // namespace sim +} // namespace wpi diff --git a/wpilibc/src/generated/main/native/include/wpi/simulation/Switch2ProControllerSim.hpp b/wpilibc/src/generated/main/native/include/wpi/simulation/Switch2ProControllerSim.hpp new file mode 100644 index 0000000000..b9d9aa5037 --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/simulation/Switch2ProControllerSim.hpp @@ -0,0 +1,212 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/simulation/GenericHIDSim.hpp" + +namespace wpi { + +class Switch2ProController; + +namespace sim { + +/** + * Class to control a simulated Switch2Pro controller. + */ +class Switch2ProControllerSim : public GenericHIDSim { + public: + /** + * Constructs from a Switch2ProController object. + * + * @param joystick controller to simulate + */ + explicit Switch2ProControllerSim(const Switch2ProController& joystick); + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + explicit Switch2ProControllerSim(int port); + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + void SetLeftX(double value); + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + void SetLeftY(double value); + + /** + * Change the Right X value of the controller. + * + * @param value the new value + */ + void SetRightX(double value); + + /** + * Change the Right Y value of the controller. + * + * @param value the new value + */ + void SetRightY(double value); + + /** + * Change the ZL value of the controller. + * + * @param value the new value + */ + void SetZL(double value); + + /** + * Change the ZR value of the controller. + * + * @param value the new value + */ + void SetZR(double value); + + /** + * Change the value of the B button on the controller. + * + * @param value the new value + */ + void SetBButton(bool value); + + /** + * Change the value of the A button on the controller. + * + * @param value the new value + */ + void SetAButton(bool value); + + /** + * Change the value of the Y button on the controller. + * + * @param value the new value + */ + void SetYButton(bool value); + + /** + * Change the value of the X button on the controller. + * + * @param value the new value + */ + void SetXButton(bool value); + + /** + * Change the value of the Minus button on the controller. + * + * @param value the new value + */ + void SetMinusButton(bool value); + + /** + * Change the value of the Home button on the controller. + * + * @param value the new value + */ + void SetHomeButton(bool value); + + /** + * Change the value of the Plus button on the controller. + * + * @param value the new value + */ + void SetPlusButton(bool value); + + /** + * Change the value of the Left Stick button on the controller. + * + * @param value the new value + */ + void SetLeftStickButton(bool value); + + /** + * Change the value of the Right Stick button on the controller. + * + * @param value the new value + */ + void SetRightStickButton(bool value); + + /** + * Change the value of the L button on the controller. + * + * @param value the new value + */ + void SetLButton(bool value); + + /** + * Change the value of the R button on the controller. + * + * @param value the new value + */ + void SetRButton(bool value); + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + void SetDpadUpButton(bool value); + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + void SetDpadDownButton(bool value); + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + void SetDpadLeftButton(bool value); + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + void SetDpadRightButton(bool value); + + /** + * Change the value of the Capture button on the controller. + * + * @param value the new value + */ + void SetCaptureButton(bool value); + + /** + * Change the value of the GR button on the controller. + * + * @param value the new value + */ + void SetGRButton(bool value); + + /** + * Change the value of the GL button on the controller. + * + * @param value the new value + */ + void SetGLButton(bool value); + + /** + * Change the value of the C button on the controller. + * + * @param value the new value + */ + void SetCButton(bool value); +}; + +} // namespace sim +} // namespace wpi diff --git a/wpilibc/src/generated/main/native/include/wpi/simulation/SwitchN64ControllerSim.hpp b/wpilibc/src/generated/main/native/include/wpi/simulation/SwitchN64ControllerSim.hpp new file mode 100644 index 0000000000..da3bd98080 --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/simulation/SwitchN64ControllerSim.hpp @@ -0,0 +1,170 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/simulation/GenericHIDSim.hpp" + +namespace wpi { + +class SwitchN64Controller; + +namespace sim { + +/** + * Class to control a simulated SwitchN64 controller. + */ +class SwitchN64ControllerSim : public GenericHIDSim { + public: + /** + * Constructs from a SwitchN64Controller object. + * + * @param joystick controller to simulate + */ + explicit SwitchN64ControllerSim(const SwitchN64Controller& joystick); + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + explicit SwitchN64ControllerSim(int port); + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + void SetLeftX(double value); + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + void SetLeftY(double value); + + /** + * Change the Z Axis value of the controller. + * + * @param value the new value + */ + void SetZAxis(double value); + + /** + * Change the ZR value of the controller. + * + * @param value the new value + */ + void SetZR(double value); + + /** + * Change the value of the A button on the controller. + * + * @param value the new value + */ + void SetAButton(bool value); + + /** + * Change the value of the B button on the controller. + * + * @param value the new value + */ + void SetBButton(bool value); + + /** + * Change the value of the C Left button on the controller. + * + * @param value the new value + */ + void SetCLeftButton(bool value); + + /** + * Change the value of the C Up button on the controller. + * + * @param value the new value + */ + void SetCUpButton(bool value); + + /** + * Change the value of the Capture button on the controller. + * + * @param value the new value + */ + void SetCaptureButton(bool value); + + /** + * Change the value of the Home button on the controller. + * + * @param value the new value + */ + void SetHomeButton(bool value); + + /** + * Change the value of the Start button on the controller. + * + * @param value the new value + */ + void SetStartButton(bool value); + + /** + * Change the value of the C Down button on the controller. + * + * @param value the new value + */ + void SetCDownButton(bool value); + + /** + * Change the value of the L button on the controller. + * + * @param value the new value + */ + void SetLButton(bool value); + + /** + * Change the value of the R button on the controller. + * + * @param value the new value + */ + void SetRButton(bool value); + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + void SetDpadUpButton(bool value); + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + void SetDpadDownButton(bool value); + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + void SetDpadLeftButton(bool value); + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + void SetDpadRightButton(bool value); + + /** + * Change the value of the C Right button on the controller. + * + * @param value the new value + */ + void SetCRightButton(bool value); +}; + +} // namespace sim +} // namespace wpi diff --git a/wpilibc/src/generated/main/native/include/wpi/simulation/SwitchProControllerSim.hpp b/wpilibc/src/generated/main/native/include/wpi/simulation/SwitchProControllerSim.hpp new file mode 100644 index 0000000000..c69c3b95a4 --- /dev/null +++ b/wpilibc/src/generated/main/native/include/wpi/simulation/SwitchProControllerSim.hpp @@ -0,0 +1,191 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#pragma once + +#include "wpi/simulation/GenericHIDSim.hpp" + +namespace wpi { + +class SwitchProController; + +namespace sim { + +/** + * Class to control a simulated SwitchPro controller. + */ +class SwitchProControllerSim : public GenericHIDSim { + public: + /** + * Constructs from a SwitchProController object. + * + * @param joystick controller to simulate + */ + explicit SwitchProControllerSim(const SwitchProController& joystick); + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + explicit SwitchProControllerSim(int port); + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + void SetLeftX(double value); + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + void SetLeftY(double value); + + /** + * Change the Right X value of the controller. + * + * @param value the new value + */ + void SetRightX(double value); + + /** + * Change the Right Y value of the controller. + * + * @param value the new value + */ + void SetRightY(double value); + + /** + * Change the ZL value of the controller. + * + * @param value the new value + */ + void SetZL(double value); + + /** + * Change the ZR value of the controller. + * + * @param value the new value + */ + void SetZR(double value); + + /** + * Change the value of the B button on the controller. + * + * @param value the new value + */ + void SetBButton(bool value); + + /** + * Change the value of the A button on the controller. + * + * @param value the new value + */ + void SetAButton(bool value); + + /** + * Change the value of the Y button on the controller. + * + * @param value the new value + */ + void SetYButton(bool value); + + /** + * Change the value of the X button on the controller. + * + * @param value the new value + */ + void SetXButton(bool value); + + /** + * Change the value of the Minus button on the controller. + * + * @param value the new value + */ + void SetMinusButton(bool value); + + /** + * Change the value of the Home button on the controller. + * + * @param value the new value + */ + void SetHomeButton(bool value); + + /** + * Change the value of the Plus button on the controller. + * + * @param value the new value + */ + void SetPlusButton(bool value); + + /** + * Change the value of the Left Stick button on the controller. + * + * @param value the new value + */ + void SetLeftStickButton(bool value); + + /** + * Change the value of the Right Stick button on the controller. + * + * @param value the new value + */ + void SetRightStickButton(bool value); + + /** + * Change the value of the L button on the controller. + * + * @param value the new value + */ + void SetLButton(bool value); + + /** + * Change the value of the R button on the controller. + * + * @param value the new value + */ + void SetRButton(bool value); + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + void SetDpadUpButton(bool value); + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + void SetDpadDownButton(bool value); + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + void SetDpadLeftButton(bool value); + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + void SetDpadRightButton(bool value); + + /** + * Change the value of the Capture button on the controller. + * + * @param value the new value + */ + void SetCaptureButton(bool value); +}; + +} // namespace sim +} // namespace wpi diff --git a/wpilibc/src/generated/test/native/cpp/DualSenseEdgeControllerTest.cpp b/wpilibc/src/generated/test/native/cpp/DualSenseEdgeControllerTest.cpp new file mode 100644 index 0000000000..eaa9bf0afe --- /dev/null +++ b/wpilibc/src/generated/test/native/cpp/DualSenseEdgeControllerTest.cpp @@ -0,0 +1,54 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/DualSenseEdgeController.hpp" + +#include + +#include "JoystickTestMacros.hpp" +#include "wpi/simulation/DualSenseEdgeControllerSim.hpp" + +using namespace wpi; + +TEST(DualSenseEdgeControllerTest, WrappedHID) { + DualSenseEdgeController controller{2}; + sim::DualSenseEdgeControllerSim sim{controller}; + sim.NotifyNewData(); + + ASSERT_EQ(controller.GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetAxesAvailable(), 0x3F); + ASSERT_EQ(controller.GetHID().GetButtonsAvailable(), 0x73FFFFULL); + ASSERT_EQ(controller.GetHID().GetPOVsAvailable(), 0); +} + +BUTTON_TEST(DualSenseEdgeController, CrossButton) +BUTTON_TEST(DualSenseEdgeController, CircleButton) +BUTTON_TEST(DualSenseEdgeController, SquareButton) +BUTTON_TEST(DualSenseEdgeController, TriangleButton) +BUTTON_TEST(DualSenseEdgeController, CreateButton) +BUTTON_TEST(DualSenseEdgeController, PSButton) +BUTTON_TEST(DualSenseEdgeController, OptionsButton) +BUTTON_TEST(DualSenseEdgeController, L3Button) +BUTTON_TEST(DualSenseEdgeController, R3Button) +BUTTON_TEST(DualSenseEdgeController, L1Button) +BUTTON_TEST(DualSenseEdgeController, R1Button) +BUTTON_TEST(DualSenseEdgeController, DpadUpButton) +BUTTON_TEST(DualSenseEdgeController, DpadDownButton) +BUTTON_TEST(DualSenseEdgeController, DpadLeftButton) +BUTTON_TEST(DualSenseEdgeController, DpadRightButton) +BUTTON_TEST(DualSenseEdgeController, MicrophoneButton) +BUTTON_TEST(DualSenseEdgeController, RightPaddle1Button) +BUTTON_TEST(DualSenseEdgeController, LeftPaddle1Button) +BUTTON_TEST(DualSenseEdgeController, TouchpadButton) +BUTTON_TEST(DualSenseEdgeController, LeftFunctionButton) +BUTTON_TEST(DualSenseEdgeController, RightFunctionButton) + +AXIS_TEST(DualSenseEdgeController, LeftX) +AXIS_TEST(DualSenseEdgeController, LeftY) +AXIS_TEST(DualSenseEdgeController, RightX) +AXIS_TEST(DualSenseEdgeController, RightY) +AXIS_TEST(DualSenseEdgeController, L2) +AXIS_TEST(DualSenseEdgeController, R2) diff --git a/wpilibc/src/generated/test/native/cpp/DualShock4ControllerTest.cpp b/wpilibc/src/generated/test/native/cpp/DualShock4ControllerTest.cpp new file mode 100644 index 0000000000..29712a6547 --- /dev/null +++ b/wpilibc/src/generated/test/native/cpp/DualShock4ControllerTest.cpp @@ -0,0 +1,49 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/DualShock4Controller.hpp" + +#include + +#include "JoystickTestMacros.hpp" +#include "wpi/simulation/DualShock4ControllerSim.hpp" + +using namespace wpi; + +TEST(DualShock4ControllerTest, WrappedHID) { + DualShock4Controller controller{2}; + sim::DualShock4ControllerSim sim{controller}; + sim.NotifyNewData(); + + ASSERT_EQ(controller.GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetAxesAvailable(), 0x3F); + ASSERT_EQ(controller.GetHID().GetButtonsAvailable(), 0x107FFFULL); + ASSERT_EQ(controller.GetHID().GetPOVsAvailable(), 0); +} + +BUTTON_TEST(DualShock4Controller, CrossButton) +BUTTON_TEST(DualShock4Controller, CircleButton) +BUTTON_TEST(DualShock4Controller, SquareButton) +BUTTON_TEST(DualShock4Controller, TriangleButton) +BUTTON_TEST(DualShock4Controller, ShareButton) +BUTTON_TEST(DualShock4Controller, PSButton) +BUTTON_TEST(DualShock4Controller, OptionsButton) +BUTTON_TEST(DualShock4Controller, L3Button) +BUTTON_TEST(DualShock4Controller, R3Button) +BUTTON_TEST(DualShock4Controller, L1Button) +BUTTON_TEST(DualShock4Controller, R1Button) +BUTTON_TEST(DualShock4Controller, DpadUpButton) +BUTTON_TEST(DualShock4Controller, DpadDownButton) +BUTTON_TEST(DualShock4Controller, DpadLeftButton) +BUTTON_TEST(DualShock4Controller, DpadRightButton) +BUTTON_TEST(DualShock4Controller, TouchpadButton) + +AXIS_TEST(DualShock4Controller, LeftX) +AXIS_TEST(DualShock4Controller, LeftY) +AXIS_TEST(DualShock4Controller, RightX) +AXIS_TEST(DualShock4Controller, RightY) +AXIS_TEST(DualShock4Controller, L2) +AXIS_TEST(DualShock4Controller, R2) diff --git a/wpilibc/src/generated/test/native/cpp/GameCubeControllerTest.cpp b/wpilibc/src/generated/test/native/cpp/GameCubeControllerTest.cpp new file mode 100644 index 0000000000..6b966255c8 --- /dev/null +++ b/wpilibc/src/generated/test/native/cpp/GameCubeControllerTest.cpp @@ -0,0 +1,45 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/GameCubeController.hpp" + +#include + +#include "JoystickTestMacros.hpp" +#include "wpi/simulation/GameCubeControllerSim.hpp" + +using namespace wpi; + +TEST(GameCubeControllerTest, WrappedHID) { + GameCubeController controller{2}; + sim::GameCubeControllerSim sim{controller}; + sim.NotifyNewData(); + + ASSERT_EQ(controller.GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetAxesAvailable(), 0x3F); + ASSERT_EQ(controller.GetHID().GetButtonsAvailable(), 0xC07C4FULL); + ASSERT_EQ(controller.GetHID().GetPOVsAvailable(), 0); +} + +BUTTON_TEST(GameCubeController, AButton) +BUTTON_TEST(GameCubeController, XButton) +BUTTON_TEST(GameCubeController, BButton) +BUTTON_TEST(GameCubeController, YButton) +BUTTON_TEST(GameCubeController, StartButton) +BUTTON_TEST(GameCubeController, ZButton) +BUTTON_TEST(GameCubeController, DpadUpButton) +BUTTON_TEST(GameCubeController, DpadDownButton) +BUTTON_TEST(GameCubeController, DpadLeftButton) +BUTTON_TEST(GameCubeController, DpadRightButton) +BUTTON_TEST(GameCubeController, LButton) +BUTTON_TEST(GameCubeController, RButton) + +AXIS_TEST(GameCubeController, LeftX) +AXIS_TEST(GameCubeController, LeftY) +AXIS_TEST(GameCubeController, CStickX) +AXIS_TEST(GameCubeController, CStickY) +AXIS_TEST(GameCubeController, LTrigger) +AXIS_TEST(GameCubeController, RTrigger) diff --git a/wpilibc/src/generated/test/native/cpp/LogitechF310ControllerTest.cpp b/wpilibc/src/generated/test/native/cpp/LogitechF310ControllerTest.cpp new file mode 100644 index 0000000000..cdcee86c5e --- /dev/null +++ b/wpilibc/src/generated/test/native/cpp/LogitechF310ControllerTest.cpp @@ -0,0 +1,48 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/LogitechF310Controller.hpp" + +#include + +#include "JoystickTestMacros.hpp" +#include "wpi/simulation/LogitechF310ControllerSim.hpp" + +using namespace wpi; + +TEST(LogitechF310ControllerTest, WrappedHID) { + LogitechF310Controller controller{2}; + sim::LogitechF310ControllerSim sim{controller}; + sim.NotifyNewData(); + + ASSERT_EQ(controller.GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetAxesAvailable(), 0x3F); + ASSERT_EQ(controller.GetHID().GetButtonsAvailable(), 0x7FFFULL); + ASSERT_EQ(controller.GetHID().GetPOVsAvailable(), 0); +} + +BUTTON_TEST(LogitechF310Controller, AButton) +BUTTON_TEST(LogitechF310Controller, BButton) +BUTTON_TEST(LogitechF310Controller, XButton) +BUTTON_TEST(LogitechF310Controller, YButton) +BUTTON_TEST(LogitechF310Controller, BackButton) +BUTTON_TEST(LogitechF310Controller, LogitechButton) +BUTTON_TEST(LogitechF310Controller, StartButton) +BUTTON_TEST(LogitechF310Controller, LeftStickButton) +BUTTON_TEST(LogitechF310Controller, RightStickButton) +BUTTON_TEST(LogitechF310Controller, LeftBumperButton) +BUTTON_TEST(LogitechF310Controller, RightBumperButton) +BUTTON_TEST(LogitechF310Controller, DpadUpButton) +BUTTON_TEST(LogitechF310Controller, DpadDownButton) +BUTTON_TEST(LogitechF310Controller, DpadLeftButton) +BUTTON_TEST(LogitechF310Controller, DpadRightButton) + +AXIS_TEST(LogitechF310Controller, LeftX) +AXIS_TEST(LogitechF310Controller, LeftY) +AXIS_TEST(LogitechF310Controller, RightX) +AXIS_TEST(LogitechF310Controller, RightY) +AXIS_TEST(LogitechF310Controller, LeftTrigger) +AXIS_TEST(LogitechF310Controller, RightTrigger) diff --git a/wpilibc/src/generated/test/native/cpp/SteamControllerTest.cpp b/wpilibc/src/generated/test/native/cpp/SteamControllerTest.cpp new file mode 100644 index 0000000000..7d5ae7d7cd --- /dev/null +++ b/wpilibc/src/generated/test/native/cpp/SteamControllerTest.cpp @@ -0,0 +1,59 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/SteamController.hpp" + +#include + +#include "JoystickTestMacros.hpp" +#include "wpi/simulation/SteamControllerSim.hpp" + +using namespace wpi; + +TEST(SteamControllerTest, WrappedHID) { + SteamController controller{2}; + sim::SteamControllerSim sim{controller}; + sim.NotifyNewData(); + + ASSERT_EQ(controller.GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetAxesAvailable(), 0x3F); + ASSERT_EQ(controller.GetHID().GetButtonsAvailable(), 0x3FFFFFFULL); + ASSERT_EQ(controller.GetHID().GetPOVsAvailable(), 0); +} + +BUTTON_TEST(SteamController, AButton) +BUTTON_TEST(SteamController, BButton) +BUTTON_TEST(SteamController, XButton) +BUTTON_TEST(SteamController, YButton) +BUTTON_TEST(SteamController, MenuButton) +BUTTON_TEST(SteamController, SteamButton) +BUTTON_TEST(SteamController, ViewButton) +BUTTON_TEST(SteamController, LeftStickButton) +BUTTON_TEST(SteamController, RightStickButton) +BUTTON_TEST(SteamController, LeftBumperButton) +BUTTON_TEST(SteamController, RightBumperButton) +BUTTON_TEST(SteamController, DpadUpButton) +BUTTON_TEST(SteamController, DpadDownButton) +BUTTON_TEST(SteamController, DpadLeftButton) +BUTTON_TEST(SteamController, DpadRightButton) +BUTTON_TEST(SteamController, QAMButton) +BUTTON_TEST(SteamController, RightPaddle1Button) +BUTTON_TEST(SteamController, LeftPaddle1Button) +BUTTON_TEST(SteamController, RightPaddle2Button) +BUTTON_TEST(SteamController, LeftPaddle2Button) +BUTTON_TEST(SteamController, LeftTouchpadButton) +BUTTON_TEST(SteamController, RightTouchpadButton) +BUTTON_TEST(SteamController, LeftStickTouchButton) +BUTTON_TEST(SteamController, RightStickTouchButton) +BUTTON_TEST(SteamController, LeftGripTouchButton) +BUTTON_TEST(SteamController, RightGripTouchButton) + +AXIS_TEST(SteamController, LeftX) +AXIS_TEST(SteamController, LeftY) +AXIS_TEST(SteamController, RightX) +AXIS_TEST(SteamController, RightY) +AXIS_TEST(SteamController, LeftTrigger) +AXIS_TEST(SteamController, RightTrigger) diff --git a/wpilibc/src/generated/test/native/cpp/Switch2GCControllerTest.cpp b/wpilibc/src/generated/test/native/cpp/Switch2GCControllerTest.cpp new file mode 100644 index 0000000000..e260c6e8a0 --- /dev/null +++ b/wpilibc/src/generated/test/native/cpp/Switch2GCControllerTest.cpp @@ -0,0 +1,49 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/Switch2GCController.hpp" + +#include + +#include "JoystickTestMacros.hpp" +#include "wpi/simulation/Switch2GCControllerSim.hpp" + +using namespace wpi; + +TEST(Switch2GCControllerTest, WrappedHID) { + Switch2GCController controller{2}; + sim::Switch2GCControllerSim sim{controller}; + sim.NotifyNewData(); + + ASSERT_EQ(controller.GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetAxesAvailable(), 0x3F); + ASSERT_EQ(controller.GetHID().GetButtonsAvailable(), 0xE0FE6FULL); + ASSERT_EQ(controller.GetHID().GetPOVsAvailable(), 0); +} + +BUTTON_TEST(Switch2GCController, AButton) +BUTTON_TEST(Switch2GCController, XButton) +BUTTON_TEST(Switch2GCController, BButton) +BUTTON_TEST(Switch2GCController, YButton) +BUTTON_TEST(Switch2GCController, HomeButton) +BUTTON_TEST(Switch2GCController, StartButton) +BUTTON_TEST(Switch2GCController, ZLButton) +BUTTON_TEST(Switch2GCController, ZButton) +BUTTON_TEST(Switch2GCController, DpadUpButton) +BUTTON_TEST(Switch2GCController, DpadDownButton) +BUTTON_TEST(Switch2GCController, DpadLeftButton) +BUTTON_TEST(Switch2GCController, DpadRightButton) +BUTTON_TEST(Switch2GCController, CaptureButton) +BUTTON_TEST(Switch2GCController, CButton) +BUTTON_TEST(Switch2GCController, LButton) +BUTTON_TEST(Switch2GCController, RButton) + +AXIS_TEST(Switch2GCController, LeftX) +AXIS_TEST(Switch2GCController, LeftY) +AXIS_TEST(Switch2GCController, CStickX) +AXIS_TEST(Switch2GCController, CStickY) +AXIS_TEST(Switch2GCController, LTrigger) +AXIS_TEST(Switch2GCController, RTrigger) diff --git a/wpilibc/src/generated/test/native/cpp/Switch2ProControllerTest.cpp b/wpilibc/src/generated/test/native/cpp/Switch2ProControllerTest.cpp new file mode 100644 index 0000000000..2281747a75 --- /dev/null +++ b/wpilibc/src/generated/test/native/cpp/Switch2ProControllerTest.cpp @@ -0,0 +1,52 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/Switch2ProController.hpp" + +#include + +#include "JoystickTestMacros.hpp" +#include "wpi/simulation/Switch2ProControllerSim.hpp" + +using namespace wpi; + +TEST(Switch2ProControllerTest, WrappedHID) { + Switch2ProController controller{2}; + sim::Switch2ProControllerSim sim{controller}; + sim.NotifyNewData(); + + ASSERT_EQ(controller.GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetAxesAvailable(), 0x3F); + ASSERT_EQ(controller.GetHID().GetButtonsAvailable(), 0x23FFFFULL); + ASSERT_EQ(controller.GetHID().GetPOVsAvailable(), 0); +} + +BUTTON_TEST(Switch2ProController, BButton) +BUTTON_TEST(Switch2ProController, AButton) +BUTTON_TEST(Switch2ProController, YButton) +BUTTON_TEST(Switch2ProController, XButton) +BUTTON_TEST(Switch2ProController, MinusButton) +BUTTON_TEST(Switch2ProController, HomeButton) +BUTTON_TEST(Switch2ProController, PlusButton) +BUTTON_TEST(Switch2ProController, LeftStickButton) +BUTTON_TEST(Switch2ProController, RightStickButton) +BUTTON_TEST(Switch2ProController, LButton) +BUTTON_TEST(Switch2ProController, RButton) +BUTTON_TEST(Switch2ProController, DpadUpButton) +BUTTON_TEST(Switch2ProController, DpadDownButton) +BUTTON_TEST(Switch2ProController, DpadLeftButton) +BUTTON_TEST(Switch2ProController, DpadRightButton) +BUTTON_TEST(Switch2ProController, CaptureButton) +BUTTON_TEST(Switch2ProController, GRButton) +BUTTON_TEST(Switch2ProController, GLButton) +BUTTON_TEST(Switch2ProController, CButton) + +AXIS_TEST(Switch2ProController, LeftX) +AXIS_TEST(Switch2ProController, LeftY) +AXIS_TEST(Switch2ProController, RightX) +AXIS_TEST(Switch2ProController, RightY) +AXIS_TEST(Switch2ProController, ZL) +AXIS_TEST(Switch2ProController, ZR) diff --git a/wpilibc/src/generated/test/native/cpp/SwitchN64ControllerTest.cpp b/wpilibc/src/generated/test/native/cpp/SwitchN64ControllerTest.cpp new file mode 100644 index 0000000000..69f2543d97 --- /dev/null +++ b/wpilibc/src/generated/test/native/cpp/SwitchN64ControllerTest.cpp @@ -0,0 +1,46 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/SwitchN64Controller.hpp" + +#include + +#include "JoystickTestMacros.hpp" +#include "wpi/simulation/SwitchN64ControllerSim.hpp" + +using namespace wpi; + +TEST(SwitchN64ControllerTest, WrappedHID) { + SwitchN64Controller controller{2}; + sim::SwitchN64ControllerSim sim{controller}; + sim.NotifyNewData(); + + ASSERT_EQ(controller.GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetAxesAvailable(), 0x33); + ASSERT_EQ(controller.GetHID().GetButtonsAvailable(), 0x20FE7FULL); + ASSERT_EQ(controller.GetHID().GetPOVsAvailable(), 0); +} + +BUTTON_TEST(SwitchN64Controller, AButton) +BUTTON_TEST(SwitchN64Controller, BButton) +BUTTON_TEST(SwitchN64Controller, CLeftButton) +BUTTON_TEST(SwitchN64Controller, CUpButton) +BUTTON_TEST(SwitchN64Controller, CaptureButton) +BUTTON_TEST(SwitchN64Controller, HomeButton) +BUTTON_TEST(SwitchN64Controller, StartButton) +BUTTON_TEST(SwitchN64Controller, CDownButton) +BUTTON_TEST(SwitchN64Controller, LButton) +BUTTON_TEST(SwitchN64Controller, RButton) +BUTTON_TEST(SwitchN64Controller, DpadUpButton) +BUTTON_TEST(SwitchN64Controller, DpadDownButton) +BUTTON_TEST(SwitchN64Controller, DpadLeftButton) +BUTTON_TEST(SwitchN64Controller, DpadRightButton) +BUTTON_TEST(SwitchN64Controller, CRightButton) + +AXIS_TEST(SwitchN64Controller, LeftX) +AXIS_TEST(SwitchN64Controller, LeftY) +AXIS_TEST(SwitchN64Controller, ZAxis) +AXIS_TEST(SwitchN64Controller, ZR) diff --git a/wpilibc/src/generated/test/native/cpp/SwitchProControllerTest.cpp b/wpilibc/src/generated/test/native/cpp/SwitchProControllerTest.cpp new file mode 100644 index 0000000000..c97d0c2efd --- /dev/null +++ b/wpilibc/src/generated/test/native/cpp/SwitchProControllerTest.cpp @@ -0,0 +1,49 @@ +// 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 ./wpilibc/generate_first_ds_hids.py. DO NOT MODIFY +#include "wpi/driverstation/SwitchProController.hpp" + +#include + +#include "JoystickTestMacros.hpp" +#include "wpi/simulation/SwitchProControllerSim.hpp" + +using namespace wpi; + +TEST(SwitchProControllerTest, WrappedHID) { + SwitchProController controller{2}; + sim::SwitchProControllerSim sim{controller}; + sim.NotifyNewData(); + + ASSERT_EQ(controller.GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetPort(), 2); + ASSERT_EQ(controller.GetHID().GetAxesAvailable(), 0x3F); + ASSERT_EQ(controller.GetHID().GetButtonsAvailable(), 0xFFFFULL); + ASSERT_EQ(controller.GetHID().GetPOVsAvailable(), 0); +} + +BUTTON_TEST(SwitchProController, BButton) +BUTTON_TEST(SwitchProController, AButton) +BUTTON_TEST(SwitchProController, YButton) +BUTTON_TEST(SwitchProController, XButton) +BUTTON_TEST(SwitchProController, MinusButton) +BUTTON_TEST(SwitchProController, HomeButton) +BUTTON_TEST(SwitchProController, PlusButton) +BUTTON_TEST(SwitchProController, LeftStickButton) +BUTTON_TEST(SwitchProController, RightStickButton) +BUTTON_TEST(SwitchProController, LButton) +BUTTON_TEST(SwitchProController, RButton) +BUTTON_TEST(SwitchProController, DpadUpButton) +BUTTON_TEST(SwitchProController, DpadDownButton) +BUTTON_TEST(SwitchProController, DpadLeftButton) +BUTTON_TEST(SwitchProController, DpadRightButton) +BUTTON_TEST(SwitchProController, CaptureButton) + +AXIS_TEST(SwitchProController, LeftX) +AXIS_TEST(SwitchProController, LeftY) +AXIS_TEST(SwitchProController, RightX) +AXIS_TEST(SwitchProController, RightY) +AXIS_TEST(SwitchProController, ZL) +AXIS_TEST(SwitchProController, ZR) diff --git a/wpilibc/src/main/python/pyproject.toml b/wpilibc/src/main/python/pyproject.toml index aed2ce283b..6f1b698f4a 100644 --- a/wpilibc/src/main/python/pyproject.toml +++ b/wpilibc/src/main/python/pyproject.toml @@ -122,7 +122,16 @@ Gamepad = "wpi/driverstation/Gamepad.hpp" GenericHID = "wpi/driverstation/GenericHID.hpp" HIDDevice = "wpi/driverstation/HIDDevice.hpp" Joystick = "wpi/driverstation/Joystick.hpp" +GameCubeController = "wpi/driverstation/GameCubeController.hpp" +DualSenseEdgeController = "wpi/driverstation/DualSenseEdgeController.hpp" DualSenseController = "wpi/driverstation/DualSenseController.hpp" +DualShock4Controller = "wpi/driverstation/DualShock4Controller.hpp" +LogitechF310Controller = "wpi/driverstation/LogitechF310Controller.hpp" +SteamController = "wpi/driverstation/SteamController.hpp" +Switch2GCController = "wpi/driverstation/Switch2GCController.hpp" +Switch2ProController = "wpi/driverstation/Switch2ProController.hpp" +SwitchN64Controller = "wpi/driverstation/SwitchN64Controller.hpp" +SwitchProController = "wpi/driverstation/SwitchProController.hpp" XboxController = "wpi/driverstation/XboxController.hpp" NiDsPS4Controller = "wpi/driverstation/NiDsPS4Controller.hpp" NiDsPS5Controller = "wpi/driverstation/NiDsPS5Controller.hpp" @@ -282,7 +291,16 @@ GamepadSim = "wpi/simulation/GamepadSim.hpp" GenericHIDSim = "wpi/simulation/GenericHIDSim.hpp" JoystickSim = "wpi/simulation/JoystickSim.hpp" LinearSystemSim = "wpi/simulation/LinearSystemSim.hpp" +GameCubeControllerSim = "wpi/simulation/GameCubeControllerSim.hpp" +DualSenseEdgeControllerSim = "wpi/simulation/DualSenseEdgeControllerSim.hpp" DualSenseControllerSim = "wpi/simulation/DualSenseControllerSim.hpp" +DualShock4ControllerSim = "wpi/simulation/DualShock4ControllerSim.hpp" +LogitechF310ControllerSim = "wpi/simulation/LogitechF310ControllerSim.hpp" +SteamControllerSim = "wpi/simulation/SteamControllerSim.hpp" +Switch2GCControllerSim = "wpi/simulation/Switch2GCControllerSim.hpp" +Switch2ProControllerSim = "wpi/simulation/Switch2ProControllerSim.hpp" +SwitchN64ControllerSim = "wpi/simulation/SwitchN64ControllerSim.hpp" +SwitchProControllerSim = "wpi/simulation/SwitchProControllerSim.hpp" XboxControllerSim = "wpi/simulation/XboxControllerSim.hpp" NiDsPS4ControllerSim = "wpi/simulation/NiDsPS4ControllerSim.hpp" NiDsPS5ControllerSim = "wpi/simulation/NiDsPS5ControllerSim.hpp" diff --git a/wpilibc/src/main/python/semiwrap/DualSenseEdgeController.yml b/wpilibc/src/main/python/semiwrap/DualSenseEdgeController.yml new file mode 100644 index 0000000000..4071586d2f --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/DualSenseEdgeController.yml @@ -0,0 +1,136 @@ +extra_includes: +- wpi/util/sendable/SendableBuilder.hpp +- wpi/driverstation/internal/DriverStationBackend.hpp +- wpi/event/BooleanEvent.hpp + +classes: + wpi::DualSenseEdgeController: + force_no_trampoline: true + ignored_bases: + - wpi::util::SendableHelper + attributes: + TOUCHPAD_COUNT: + SUPPORTS_RUMBLE: + SUPPORTS_TRIGGER_RUMBLE: + SUPPORTS_MONO_LED: + SUPPORTS_RGB_LED: + SUPPORTED_OUTPUTS: + methods: + DualSenseEdgeController: + overloads: + int: + GenericHID&: + GetHID: + overloads: + "": + return_value_policy: reference_internal + '[const]': + ignore: true + GetPort: + IsConnected: + GetLeftX: + GetLeftY: + GetRightX: + GetRightY: + GetL2: + GetR2: + GetAxis: + AxisLessThan: + AxisGreaterThan: + GetCrossButton: + GetCrossButtonPressed: + GetCrossButtonReleased: + Cross: + GetCircleButton: + GetCircleButtonPressed: + GetCircleButtonReleased: + Circle: + GetSquareButton: + GetSquareButtonPressed: + GetSquareButtonReleased: + Square: + GetTriangleButton: + GetTriangleButtonPressed: + GetTriangleButtonReleased: + Triangle: + GetCreateButton: + GetCreateButtonPressed: + GetCreateButtonReleased: + Create: + GetPSButton: + GetPSButtonPressed: + GetPSButtonReleased: + PS: + GetOptionsButton: + GetOptionsButtonPressed: + GetOptionsButtonReleased: + Options: + GetL3Button: + GetL3ButtonPressed: + GetL3ButtonReleased: + L3: + GetR3Button: + GetR3ButtonPressed: + GetR3ButtonReleased: + R3: + GetL1Button: + GetL1ButtonPressed: + GetL1ButtonReleased: + L1: + GetR1Button: + GetR1ButtonPressed: + GetR1ButtonReleased: + R1: + GetDpadUpButton: + GetDpadUpButtonPressed: + GetDpadUpButtonReleased: + DpadUp: + GetDpadDownButton: + GetDpadDownButtonPressed: + GetDpadDownButtonReleased: + DpadDown: + GetDpadLeftButton: + GetDpadLeftButtonPressed: + GetDpadLeftButtonReleased: + DpadLeft: + GetDpadRightButton: + GetDpadRightButtonPressed: + GetDpadRightButtonReleased: + DpadRight: + GetMicrophoneButton: + GetMicrophoneButtonPressed: + GetMicrophoneButtonReleased: + Microphone: + GetRightPaddle1Button: + GetRightPaddle1ButtonPressed: + GetRightPaddle1ButtonReleased: + RightPaddle1: + GetLeftPaddle1Button: + GetLeftPaddle1ButtonPressed: + GetLeftPaddle1ButtonReleased: + LeftPaddle1: + GetTouchpadButton: + GetTouchpadButtonPressed: + GetTouchpadButtonReleased: + Touchpad: + GetLeftFunctionButton: + GetLeftFunctionButtonPressed: + GetLeftFunctionButtonReleased: + LeftFunction: + GetRightFunctionButton: + GetRightFunctionButtonPressed: + GetRightFunctionButtonReleased: + RightFunction: + GetButton: + GetButtonPressed: + GetButtonReleased: + ButtonEvent: + rename: button + SetLeds: + SetRumble: + GetTouchpadFingerAvailable: + GetTouchpadFinger: + InitSendable: + enums: + Button: + Axis: diff --git a/wpilibc/src/main/python/semiwrap/DualShock4Controller.yml b/wpilibc/src/main/python/semiwrap/DualShock4Controller.yml new file mode 100644 index 0000000000..0c8d1f19e2 --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/DualShock4Controller.yml @@ -0,0 +1,116 @@ +extra_includes: +- wpi/util/sendable/SendableBuilder.hpp +- wpi/driverstation/internal/DriverStationBackend.hpp +- wpi/event/BooleanEvent.hpp + +classes: + wpi::DualShock4Controller: + force_no_trampoline: true + ignored_bases: + - wpi::util::SendableHelper + attributes: + TOUCHPAD_COUNT: + SUPPORTS_RUMBLE: + SUPPORTS_TRIGGER_RUMBLE: + SUPPORTS_MONO_LED: + SUPPORTS_RGB_LED: + SUPPORTED_OUTPUTS: + methods: + DualShock4Controller: + overloads: + int: + GenericHID&: + GetHID: + overloads: + "": + return_value_policy: reference_internal + '[const]': + ignore: true + GetPort: + IsConnected: + GetLeftX: + GetLeftY: + GetRightX: + GetRightY: + GetL2: + GetR2: + GetAxis: + AxisLessThan: + AxisGreaterThan: + GetCrossButton: + GetCrossButtonPressed: + GetCrossButtonReleased: + Cross: + GetCircleButton: + GetCircleButtonPressed: + GetCircleButtonReleased: + Circle: + GetSquareButton: + GetSquareButtonPressed: + GetSquareButtonReleased: + Square: + GetTriangleButton: + GetTriangleButtonPressed: + GetTriangleButtonReleased: + Triangle: + GetShareButton: + GetShareButtonPressed: + GetShareButtonReleased: + Share: + GetPSButton: + GetPSButtonPressed: + GetPSButtonReleased: + PS: + GetOptionsButton: + GetOptionsButtonPressed: + GetOptionsButtonReleased: + Options: + GetL3Button: + GetL3ButtonPressed: + GetL3ButtonReleased: + L3: + GetR3Button: + GetR3ButtonPressed: + GetR3ButtonReleased: + R3: + GetL1Button: + GetL1ButtonPressed: + GetL1ButtonReleased: + L1: + GetR1Button: + GetR1ButtonPressed: + GetR1ButtonReleased: + R1: + GetDpadUpButton: + GetDpadUpButtonPressed: + GetDpadUpButtonReleased: + DpadUp: + GetDpadDownButton: + GetDpadDownButtonPressed: + GetDpadDownButtonReleased: + DpadDown: + GetDpadLeftButton: + GetDpadLeftButtonPressed: + GetDpadLeftButtonReleased: + DpadLeft: + GetDpadRightButton: + GetDpadRightButtonPressed: + GetDpadRightButtonReleased: + DpadRight: + GetTouchpadButton: + GetTouchpadButtonPressed: + GetTouchpadButtonReleased: + Touchpad: + GetButton: + GetButtonPressed: + GetButtonReleased: + ButtonEvent: + rename: button + SetLeds: + SetRumble: + GetTouchpadFingerAvailable: + GetTouchpadFinger: + InitSendable: + enums: + Button: + Axis: diff --git a/wpilibc/src/main/python/semiwrap/GameCubeController.yml b/wpilibc/src/main/python/semiwrap/GameCubeController.yml new file mode 100644 index 0000000000..9e0fc4975a --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/GameCubeController.yml @@ -0,0 +1,98 @@ +extra_includes: +- wpi/util/sendable/SendableBuilder.hpp +- wpi/driverstation/internal/DriverStationBackend.hpp +- wpi/event/BooleanEvent.hpp + +classes: + wpi::GameCubeController: + force_no_trampoline: true + ignored_bases: + - wpi::util::SendableHelper + attributes: + TOUCHPAD_COUNT: + SUPPORTS_RUMBLE: + SUPPORTS_TRIGGER_RUMBLE: + SUPPORTS_MONO_LED: + SUPPORTS_RGB_LED: + SUPPORTED_OUTPUTS: + methods: + GameCubeController: + overloads: + int: + GenericHID&: + GetHID: + overloads: + "": + return_value_policy: reference_internal + '[const]': + ignore: true + GetPort: + IsConnected: + GetLeftX: + GetLeftY: + GetCStickX: + GetCStickY: + GetLTrigger: + GetRTrigger: + GetAxis: + AxisLessThan: + AxisGreaterThan: + GetAButton: + GetAButtonPressed: + GetAButtonReleased: + A: + GetXButton: + GetXButtonPressed: + GetXButtonReleased: + X: + GetBButton: + GetBButtonPressed: + GetBButtonReleased: + B: + GetYButton: + GetYButtonPressed: + GetYButtonReleased: + Y: + GetStartButton: + GetStartButtonPressed: + GetStartButtonReleased: + Start: + GetZButton: + GetZButtonPressed: + GetZButtonReleased: + Z: + GetDpadUpButton: + GetDpadUpButtonPressed: + GetDpadUpButtonReleased: + DpadUp: + GetDpadDownButton: + GetDpadDownButtonPressed: + GetDpadDownButtonReleased: + DpadDown: + GetDpadLeftButton: + GetDpadLeftButtonPressed: + GetDpadLeftButtonReleased: + DpadLeft: + GetDpadRightButton: + GetDpadRightButtonPressed: + GetDpadRightButtonReleased: + DpadRight: + GetLButton: + GetLButtonPressed: + GetLButtonReleased: + L: + GetRButton: + GetRButtonPressed: + GetRButtonReleased: + R: + GetButton: + GetButtonPressed: + GetButtonReleased: + ButtonEvent: + rename: button + SetLeds: + SetRumble: + InitSendable: + enums: + Button: + Axis: diff --git a/wpilibc/src/main/python/semiwrap/LogitechF310Controller.yml b/wpilibc/src/main/python/semiwrap/LogitechF310Controller.yml new file mode 100644 index 0000000000..639f1e77fd --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/LogitechF310Controller.yml @@ -0,0 +1,110 @@ +extra_includes: +- wpi/util/sendable/SendableBuilder.hpp +- wpi/driverstation/internal/DriverStationBackend.hpp +- wpi/event/BooleanEvent.hpp + +classes: + wpi::LogitechF310Controller: + force_no_trampoline: true + ignored_bases: + - wpi::util::SendableHelper + attributes: + TOUCHPAD_COUNT: + SUPPORTS_RUMBLE: + SUPPORTS_TRIGGER_RUMBLE: + SUPPORTS_MONO_LED: + SUPPORTS_RGB_LED: + SUPPORTED_OUTPUTS: + methods: + LogitechF310Controller: + overloads: + int: + GenericHID&: + GetHID: + overloads: + "": + return_value_policy: reference_internal + '[const]': + ignore: true + GetPort: + IsConnected: + GetLeftX: + GetLeftY: + GetRightX: + GetRightY: + GetLeftTrigger: + GetRightTrigger: + GetAxis: + AxisLessThan: + AxisGreaterThan: + GetAButton: + GetAButtonPressed: + GetAButtonReleased: + A: + GetBButton: + GetBButtonPressed: + GetBButtonReleased: + B: + GetXButton: + GetXButtonPressed: + GetXButtonReleased: + X: + GetYButton: + GetYButtonPressed: + GetYButtonReleased: + Y: + GetBackButton: + GetBackButtonPressed: + GetBackButtonReleased: + Back: + GetLogitechButton: + GetLogitechButtonPressed: + GetLogitechButtonReleased: + Logitech: + GetStartButton: + GetStartButtonPressed: + GetStartButtonReleased: + Start: + GetLeftStickButton: + GetLeftStickButtonPressed: + GetLeftStickButtonReleased: + LeftStick: + GetRightStickButton: + GetRightStickButtonPressed: + GetRightStickButtonReleased: + RightStick: + GetLeftBumperButton: + GetLeftBumperButtonPressed: + GetLeftBumperButtonReleased: + LeftBumper: + GetRightBumperButton: + GetRightBumperButtonPressed: + GetRightBumperButtonReleased: + RightBumper: + GetDpadUpButton: + GetDpadUpButtonPressed: + GetDpadUpButtonReleased: + DpadUp: + GetDpadDownButton: + GetDpadDownButtonPressed: + GetDpadDownButtonReleased: + DpadDown: + GetDpadLeftButton: + GetDpadLeftButtonPressed: + GetDpadLeftButtonReleased: + DpadLeft: + GetDpadRightButton: + GetDpadRightButtonPressed: + GetDpadRightButtonReleased: + DpadRight: + GetButton: + GetButtonPressed: + GetButtonReleased: + ButtonEvent: + rename: button + SetLeds: + SetRumble: + InitSendable: + enums: + Button: + Axis: diff --git a/wpilibc/src/main/python/semiwrap/SteamController.yml b/wpilibc/src/main/python/semiwrap/SteamController.yml new file mode 100644 index 0000000000..c98457a59a --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/SteamController.yml @@ -0,0 +1,156 @@ +extra_includes: +- wpi/util/sendable/SendableBuilder.hpp +- wpi/driverstation/internal/DriverStationBackend.hpp +- wpi/event/BooleanEvent.hpp + +classes: + wpi::SteamController: + force_no_trampoline: true + ignored_bases: + - wpi::util::SendableHelper + attributes: + TOUCHPAD_COUNT: + SUPPORTS_RUMBLE: + SUPPORTS_TRIGGER_RUMBLE: + SUPPORTS_MONO_LED: + SUPPORTS_RGB_LED: + SUPPORTED_OUTPUTS: + methods: + SteamController: + overloads: + int: + GenericHID&: + GetHID: + overloads: + "": + return_value_policy: reference_internal + '[const]': + ignore: true + GetPort: + IsConnected: + GetLeftX: + GetLeftY: + GetRightX: + GetRightY: + GetLeftTrigger: + GetRightTrigger: + GetAxis: + AxisLessThan: + AxisGreaterThan: + GetAButton: + GetAButtonPressed: + GetAButtonReleased: + A: + GetBButton: + GetBButtonPressed: + GetBButtonReleased: + B: + GetXButton: + GetXButtonPressed: + GetXButtonReleased: + X: + GetYButton: + GetYButtonPressed: + GetYButtonReleased: + Y: + GetMenuButton: + GetMenuButtonPressed: + GetMenuButtonReleased: + Menu: + GetSteamButton: + GetSteamButtonPressed: + GetSteamButtonReleased: + Steam: + GetViewButton: + GetViewButtonPressed: + GetViewButtonReleased: + View: + GetLeftStickButton: + GetLeftStickButtonPressed: + GetLeftStickButtonReleased: + LeftStick: + GetRightStickButton: + GetRightStickButtonPressed: + GetRightStickButtonReleased: + RightStick: + GetLeftBumperButton: + GetLeftBumperButtonPressed: + GetLeftBumperButtonReleased: + LeftBumper: + GetRightBumperButton: + GetRightBumperButtonPressed: + GetRightBumperButtonReleased: + RightBumper: + GetDpadUpButton: + GetDpadUpButtonPressed: + GetDpadUpButtonReleased: + DpadUp: + GetDpadDownButton: + GetDpadDownButtonPressed: + GetDpadDownButtonReleased: + DpadDown: + GetDpadLeftButton: + GetDpadLeftButtonPressed: + GetDpadLeftButtonReleased: + DpadLeft: + GetDpadRightButton: + GetDpadRightButtonPressed: + GetDpadRightButtonReleased: + DpadRight: + GetQAMButton: + GetQAMButtonPressed: + GetQAMButtonReleased: + QAM: + GetRightPaddle1Button: + GetRightPaddle1ButtonPressed: + GetRightPaddle1ButtonReleased: + RightPaddle1: + GetLeftPaddle1Button: + GetLeftPaddle1ButtonPressed: + GetLeftPaddle1ButtonReleased: + LeftPaddle1: + GetRightPaddle2Button: + GetRightPaddle2ButtonPressed: + GetRightPaddle2ButtonReleased: + RightPaddle2: + GetLeftPaddle2Button: + GetLeftPaddle2ButtonPressed: + GetLeftPaddle2ButtonReleased: + LeftPaddle2: + GetLeftTouchpadButton: + GetLeftTouchpadButtonPressed: + GetLeftTouchpadButtonReleased: + LeftTouchpad: + GetRightTouchpadButton: + GetRightTouchpadButtonPressed: + GetRightTouchpadButtonReleased: + RightTouchpad: + GetLeftStickTouchButton: + GetLeftStickTouchButtonPressed: + GetLeftStickTouchButtonReleased: + LeftStickTouch: + GetRightStickTouchButton: + GetRightStickTouchButtonPressed: + GetRightStickTouchButtonReleased: + RightStickTouch: + GetLeftGripTouchButton: + GetLeftGripTouchButtonPressed: + GetLeftGripTouchButtonReleased: + LeftGripTouch: + GetRightGripTouchButton: + GetRightGripTouchButtonPressed: + GetRightGripTouchButtonReleased: + RightGripTouch: + GetButton: + GetButtonPressed: + GetButtonReleased: + ButtonEvent: + rename: button + SetLeds: + SetRumble: + GetTouchpadFingerAvailable: + GetTouchpadFinger: + InitSendable: + enums: + Button: + Axis: diff --git a/wpilibc/src/main/python/semiwrap/Switch2GCController.yml b/wpilibc/src/main/python/semiwrap/Switch2GCController.yml new file mode 100644 index 0000000000..3fb859ab99 --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/Switch2GCController.yml @@ -0,0 +1,114 @@ +extra_includes: +- wpi/util/sendable/SendableBuilder.hpp +- wpi/driverstation/internal/DriverStationBackend.hpp +- wpi/event/BooleanEvent.hpp + +classes: + wpi::Switch2GCController: + force_no_trampoline: true + ignored_bases: + - wpi::util::SendableHelper + attributes: + TOUCHPAD_COUNT: + SUPPORTS_RUMBLE: + SUPPORTS_TRIGGER_RUMBLE: + SUPPORTS_MONO_LED: + SUPPORTS_RGB_LED: + SUPPORTED_OUTPUTS: + methods: + Switch2GCController: + overloads: + int: + GenericHID&: + GetHID: + overloads: + "": + return_value_policy: reference_internal + '[const]': + ignore: true + GetPort: + IsConnected: + GetLeftX: + GetLeftY: + GetCStickX: + GetCStickY: + GetLTrigger: + GetRTrigger: + GetAxis: + AxisLessThan: + AxisGreaterThan: + GetAButton: + GetAButtonPressed: + GetAButtonReleased: + A: + GetXButton: + GetXButtonPressed: + GetXButtonReleased: + X: + GetBButton: + GetBButtonPressed: + GetBButtonReleased: + B: + GetYButton: + GetYButtonPressed: + GetYButtonReleased: + Y: + GetHomeButton: + GetHomeButtonPressed: + GetHomeButtonReleased: + Home: + GetStartButton: + GetStartButtonPressed: + GetStartButtonReleased: + Start: + GetZLButton: + GetZLButtonPressed: + GetZLButtonReleased: + ZL: + GetZButton: + GetZButtonPressed: + GetZButtonReleased: + Z: + GetDpadUpButton: + GetDpadUpButtonPressed: + GetDpadUpButtonReleased: + DpadUp: + GetDpadDownButton: + GetDpadDownButtonPressed: + GetDpadDownButtonReleased: + DpadDown: + GetDpadLeftButton: + GetDpadLeftButtonPressed: + GetDpadLeftButtonReleased: + DpadLeft: + GetDpadRightButton: + GetDpadRightButtonPressed: + GetDpadRightButtonReleased: + DpadRight: + GetCaptureButton: + GetCaptureButtonPressed: + GetCaptureButtonReleased: + Capture: + GetCButton: + GetCButtonPressed: + GetCButtonReleased: + C: + GetLButton: + GetLButtonPressed: + GetLButtonReleased: + L: + GetRButton: + GetRButtonPressed: + GetRButtonReleased: + R: + GetButton: + GetButtonPressed: + GetButtonReleased: + ButtonEvent: + rename: button + SetLeds: + SetRumble: + InitSendable: + enums: + Button: + Axis: diff --git a/wpilibc/src/main/python/semiwrap/Switch2ProController.yml b/wpilibc/src/main/python/semiwrap/Switch2ProController.yml new file mode 100644 index 0000000000..fb5d42b63f --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/Switch2ProController.yml @@ -0,0 +1,126 @@ +extra_includes: +- wpi/util/sendable/SendableBuilder.hpp +- wpi/driverstation/internal/DriverStationBackend.hpp +- wpi/event/BooleanEvent.hpp + +classes: + wpi::Switch2ProController: + force_no_trampoline: true + ignored_bases: + - wpi::util::SendableHelper + attributes: + TOUCHPAD_COUNT: + SUPPORTS_RUMBLE: + SUPPORTS_TRIGGER_RUMBLE: + SUPPORTS_MONO_LED: + SUPPORTS_RGB_LED: + SUPPORTED_OUTPUTS: + methods: + Switch2ProController: + overloads: + int: + GenericHID&: + GetHID: + overloads: + "": + return_value_policy: reference_internal + '[const]': + ignore: true + GetPort: + IsConnected: + GetLeftX: + GetLeftY: + GetRightX: + GetRightY: + GetZL: + GetZR: + GetAxis: + AxisLessThan: + AxisGreaterThan: + GetBButton: + GetBButtonPressed: + GetBButtonReleased: + B: + GetAButton: + GetAButtonPressed: + GetAButtonReleased: + A: + GetYButton: + GetYButtonPressed: + GetYButtonReleased: + Y: + GetXButton: + GetXButtonPressed: + GetXButtonReleased: + X: + GetMinusButton: + GetMinusButtonPressed: + GetMinusButtonReleased: + Minus: + GetHomeButton: + GetHomeButtonPressed: + GetHomeButtonReleased: + Home: + GetPlusButton: + GetPlusButtonPressed: + GetPlusButtonReleased: + Plus: + GetLeftStickButton: + GetLeftStickButtonPressed: + GetLeftStickButtonReleased: + LeftStick: + GetRightStickButton: + GetRightStickButtonPressed: + GetRightStickButtonReleased: + RightStick: + GetLButton: + GetLButtonPressed: + GetLButtonReleased: + L: + GetRButton: + GetRButtonPressed: + GetRButtonReleased: + R: + GetDpadUpButton: + GetDpadUpButtonPressed: + GetDpadUpButtonReleased: + DpadUp: + GetDpadDownButton: + GetDpadDownButtonPressed: + GetDpadDownButtonReleased: + DpadDown: + GetDpadLeftButton: + GetDpadLeftButtonPressed: + GetDpadLeftButtonReleased: + DpadLeft: + GetDpadRightButton: + GetDpadRightButtonPressed: + GetDpadRightButtonReleased: + DpadRight: + GetCaptureButton: + GetCaptureButtonPressed: + GetCaptureButtonReleased: + Capture: + GetGRButton: + GetGRButtonPressed: + GetGRButtonReleased: + GR: + GetGLButton: + GetGLButtonPressed: + GetGLButtonReleased: + GL: + GetCButton: + GetCButtonPressed: + GetCButtonReleased: + C: + GetButton: + GetButtonPressed: + GetButtonReleased: + ButtonEvent: + rename: button + SetLeds: + SetRumble: + InitSendable: + enums: + Button: + Axis: diff --git a/wpilibc/src/main/python/semiwrap/SwitchN64Controller.yml b/wpilibc/src/main/python/semiwrap/SwitchN64Controller.yml new file mode 100644 index 0000000000..dc77d9c3bf --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/SwitchN64Controller.yml @@ -0,0 +1,108 @@ +extra_includes: +- wpi/util/sendable/SendableBuilder.hpp +- wpi/driverstation/internal/DriverStationBackend.hpp +- wpi/event/BooleanEvent.hpp + +classes: + wpi::SwitchN64Controller: + force_no_trampoline: true + ignored_bases: + - wpi::util::SendableHelper + attributes: + TOUCHPAD_COUNT: + SUPPORTS_RUMBLE: + SUPPORTS_TRIGGER_RUMBLE: + SUPPORTS_MONO_LED: + SUPPORTS_RGB_LED: + SUPPORTED_OUTPUTS: + methods: + SwitchN64Controller: + overloads: + int: + GenericHID&: + GetHID: + overloads: + "": + return_value_policy: reference_internal + '[const]': + ignore: true + GetPort: + IsConnected: + GetLeftX: + GetLeftY: + GetZAxis: + GetZR: + GetAxis: + AxisLessThan: + AxisGreaterThan: + GetAButton: + GetAButtonPressed: + GetAButtonReleased: + A: + GetBButton: + GetBButtonPressed: + GetBButtonReleased: + B: + GetCLeftButton: + GetCLeftButtonPressed: + GetCLeftButtonReleased: + CLeft: + GetCUpButton: + GetCUpButtonPressed: + GetCUpButtonReleased: + CUp: + GetCaptureButton: + GetCaptureButtonPressed: + GetCaptureButtonReleased: + Capture: + GetHomeButton: + GetHomeButtonPressed: + GetHomeButtonReleased: + Home: + GetStartButton: + GetStartButtonPressed: + GetStartButtonReleased: + Start: + GetCDownButton: + GetCDownButtonPressed: + GetCDownButtonReleased: + CDown: + GetLButton: + GetLButtonPressed: + GetLButtonReleased: + L: + GetRButton: + GetRButtonPressed: + GetRButtonReleased: + R: + GetDpadUpButton: + GetDpadUpButtonPressed: + GetDpadUpButtonReleased: + DpadUp: + GetDpadDownButton: + GetDpadDownButtonPressed: + GetDpadDownButtonReleased: + DpadDown: + GetDpadLeftButton: + GetDpadLeftButtonPressed: + GetDpadLeftButtonReleased: + DpadLeft: + GetDpadRightButton: + GetDpadRightButtonPressed: + GetDpadRightButtonReleased: + DpadRight: + GetCRightButton: + GetCRightButtonPressed: + GetCRightButtonReleased: + CRight: + GetButton: + GetButtonPressed: + GetButtonReleased: + ButtonEvent: + rename: button + SetLeds: + SetRumble: + InitSendable: + enums: + Button: + Axis: diff --git a/wpilibc/src/main/python/semiwrap/SwitchProController.yml b/wpilibc/src/main/python/semiwrap/SwitchProController.yml new file mode 100644 index 0000000000..8cd1fcb9c5 --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/SwitchProController.yml @@ -0,0 +1,114 @@ +extra_includes: +- wpi/util/sendable/SendableBuilder.hpp +- wpi/driverstation/internal/DriverStationBackend.hpp +- wpi/event/BooleanEvent.hpp + +classes: + wpi::SwitchProController: + force_no_trampoline: true + ignored_bases: + - wpi::util::SendableHelper + attributes: + TOUCHPAD_COUNT: + SUPPORTS_RUMBLE: + SUPPORTS_TRIGGER_RUMBLE: + SUPPORTS_MONO_LED: + SUPPORTS_RGB_LED: + SUPPORTED_OUTPUTS: + methods: + SwitchProController: + overloads: + int: + GenericHID&: + GetHID: + overloads: + "": + return_value_policy: reference_internal + '[const]': + ignore: true + GetPort: + IsConnected: + GetLeftX: + GetLeftY: + GetRightX: + GetRightY: + GetZL: + GetZR: + GetAxis: + AxisLessThan: + AxisGreaterThan: + GetBButton: + GetBButtonPressed: + GetBButtonReleased: + B: + GetAButton: + GetAButtonPressed: + GetAButtonReleased: + A: + GetYButton: + GetYButtonPressed: + GetYButtonReleased: + Y: + GetXButton: + GetXButtonPressed: + GetXButtonReleased: + X: + GetMinusButton: + GetMinusButtonPressed: + GetMinusButtonReleased: + Minus: + GetHomeButton: + GetHomeButtonPressed: + GetHomeButtonReleased: + Home: + GetPlusButton: + GetPlusButtonPressed: + GetPlusButtonReleased: + Plus: + GetLeftStickButton: + GetLeftStickButtonPressed: + GetLeftStickButtonReleased: + LeftStick: + GetRightStickButton: + GetRightStickButtonPressed: + GetRightStickButtonReleased: + RightStick: + GetLButton: + GetLButtonPressed: + GetLButtonReleased: + L: + GetRButton: + GetRButtonPressed: + GetRButtonReleased: + R: + GetDpadUpButton: + GetDpadUpButtonPressed: + GetDpadUpButtonReleased: + DpadUp: + GetDpadDownButton: + GetDpadDownButtonPressed: + GetDpadDownButtonReleased: + DpadDown: + GetDpadLeftButton: + GetDpadLeftButtonPressed: + GetDpadLeftButtonReleased: + DpadLeft: + GetDpadRightButton: + GetDpadRightButtonPressed: + GetDpadRightButtonReleased: + DpadRight: + GetCaptureButton: + GetCaptureButtonPressed: + GetCaptureButtonReleased: + Capture: + GetButton: + GetButtonPressed: + GetButtonReleased: + ButtonEvent: + rename: button + SetLeds: + SetRumble: + InitSendable: + enums: + Button: + Axis: diff --git a/wpilibc/src/main/python/semiwrap/simulation/DualSenseEdgeControllerSim.yml b/wpilibc/src/main/python/semiwrap/simulation/DualSenseEdgeControllerSim.yml new file mode 100644 index 0000000000..d6614002b5 --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/simulation/DualSenseEdgeControllerSim.yml @@ -0,0 +1,40 @@ +extra_includes: +- wpi/driverstation/DualSenseEdgeController.hpp + +classes: + wpi::sim::DualSenseEdgeControllerSim: + force_no_trampoline: true + typealias: + - wpi::DualSenseEdgeController + methods: + DualSenseEdgeControllerSim: + overloads: + const DualSenseEdgeController&: + int: + SetLeftX: + SetLeftY: + SetRightX: + SetRightY: + SetL2: + SetR2: + SetCrossButton: + SetCircleButton: + SetSquareButton: + SetTriangleButton: + SetCreateButton: + SetPSButton: + SetOptionsButton: + SetL3Button: + SetR3Button: + SetL1Button: + SetR1Button: + SetDpadUpButton: + SetDpadDownButton: + SetDpadLeftButton: + SetDpadRightButton: + SetMicrophoneButton: + SetRightPaddle1Button: + SetLeftPaddle1Button: + SetTouchpadButton: + SetLeftFunctionButton: + SetRightFunctionButton: diff --git a/wpilibc/src/main/python/semiwrap/simulation/DualShock4ControllerSim.yml b/wpilibc/src/main/python/semiwrap/simulation/DualShock4ControllerSim.yml new file mode 100644 index 0000000000..d6e936e91a --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/simulation/DualShock4ControllerSim.yml @@ -0,0 +1,35 @@ +extra_includes: +- wpi/driverstation/DualShock4Controller.hpp + +classes: + wpi::sim::DualShock4ControllerSim: + force_no_trampoline: true + typealias: + - wpi::DualShock4Controller + methods: + DualShock4ControllerSim: + overloads: + const DualShock4Controller&: + int: + SetLeftX: + SetLeftY: + SetRightX: + SetRightY: + SetL2: + SetR2: + SetCrossButton: + SetCircleButton: + SetSquareButton: + SetTriangleButton: + SetShareButton: + SetPSButton: + SetOptionsButton: + SetL3Button: + SetR3Button: + SetL1Button: + SetR1Button: + SetDpadUpButton: + SetDpadDownButton: + SetDpadLeftButton: + SetDpadRightButton: + SetTouchpadButton: diff --git a/wpilibc/src/main/python/semiwrap/simulation/GameCubeControllerSim.yml b/wpilibc/src/main/python/semiwrap/simulation/GameCubeControllerSim.yml new file mode 100644 index 0000000000..cc812d58e3 --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/simulation/GameCubeControllerSim.yml @@ -0,0 +1,31 @@ +extra_includes: +- wpi/driverstation/GameCubeController.hpp + +classes: + wpi::sim::GameCubeControllerSim: + force_no_trampoline: true + typealias: + - wpi::GameCubeController + methods: + GameCubeControllerSim: + overloads: + const GameCubeController&: + int: + SetLeftX: + SetLeftY: + SetCStickX: + SetCStickY: + SetLTrigger: + SetRTrigger: + SetAButton: + SetXButton: + SetBButton: + SetYButton: + SetStartButton: + SetZButton: + SetDpadUpButton: + SetDpadDownButton: + SetDpadLeftButton: + SetDpadRightButton: + SetLButton: + SetRButton: diff --git a/wpilibc/src/main/python/semiwrap/simulation/LogitechF310ControllerSim.yml b/wpilibc/src/main/python/semiwrap/simulation/LogitechF310ControllerSim.yml new file mode 100644 index 0000000000..98aa4e4f77 --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/simulation/LogitechF310ControllerSim.yml @@ -0,0 +1,34 @@ +extra_includes: +- wpi/driverstation/LogitechF310Controller.hpp + +classes: + wpi::sim::LogitechF310ControllerSim: + force_no_trampoline: true + typealias: + - wpi::LogitechF310Controller + methods: + LogitechF310ControllerSim: + overloads: + const LogitechF310Controller&: + int: + SetLeftX: + SetLeftY: + SetRightX: + SetRightY: + SetLeftTrigger: + SetRightTrigger: + SetAButton: + SetBButton: + SetXButton: + SetYButton: + SetBackButton: + SetLogitechButton: + SetStartButton: + SetLeftStickButton: + SetRightStickButton: + SetLeftBumperButton: + SetRightBumperButton: + SetDpadUpButton: + SetDpadDownButton: + SetDpadLeftButton: + SetDpadRightButton: diff --git a/wpilibc/src/main/python/semiwrap/simulation/SteamControllerSim.yml b/wpilibc/src/main/python/semiwrap/simulation/SteamControllerSim.yml new file mode 100644 index 0000000000..b01d4cd409 --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/simulation/SteamControllerSim.yml @@ -0,0 +1,45 @@ +extra_includes: +- wpi/driverstation/SteamController.hpp + +classes: + wpi::sim::SteamControllerSim: + force_no_trampoline: true + typealias: + - wpi::SteamController + methods: + SteamControllerSim: + overloads: + const SteamController&: + int: + SetLeftX: + SetLeftY: + SetRightX: + SetRightY: + SetLeftTrigger: + SetRightTrigger: + SetAButton: + SetBButton: + SetXButton: + SetYButton: + SetMenuButton: + SetSteamButton: + SetViewButton: + SetLeftStickButton: + SetRightStickButton: + SetLeftBumperButton: + SetRightBumperButton: + SetDpadUpButton: + SetDpadDownButton: + SetDpadLeftButton: + SetDpadRightButton: + SetQAMButton: + SetRightPaddle1Button: + SetLeftPaddle1Button: + SetRightPaddle2Button: + SetLeftPaddle2Button: + SetLeftTouchpadButton: + SetRightTouchpadButton: + SetLeftStickTouchButton: + SetRightStickTouchButton: + SetLeftGripTouchButton: + SetRightGripTouchButton: diff --git a/wpilibc/src/main/python/semiwrap/simulation/Switch2GCControllerSim.yml b/wpilibc/src/main/python/semiwrap/simulation/Switch2GCControllerSim.yml new file mode 100644 index 0000000000..59372acbcd --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/simulation/Switch2GCControllerSim.yml @@ -0,0 +1,35 @@ +extra_includes: +- wpi/driverstation/Switch2GCController.hpp + +classes: + wpi::sim::Switch2GCControllerSim: + force_no_trampoline: true + typealias: + - wpi::Switch2GCController + methods: + Switch2GCControllerSim: + overloads: + const Switch2GCController&: + int: + SetLeftX: + SetLeftY: + SetCStickX: + SetCStickY: + SetLTrigger: + SetRTrigger: + SetAButton: + SetXButton: + SetBButton: + SetYButton: + SetHomeButton: + SetStartButton: + SetZLButton: + SetZButton: + SetDpadUpButton: + SetDpadDownButton: + SetDpadLeftButton: + SetDpadRightButton: + SetCaptureButton: + SetCButton: + SetLButton: + SetRButton: diff --git a/wpilibc/src/main/python/semiwrap/simulation/Switch2ProControllerSim.yml b/wpilibc/src/main/python/semiwrap/simulation/Switch2ProControllerSim.yml new file mode 100644 index 0000000000..9a37bba5de --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/simulation/Switch2ProControllerSim.yml @@ -0,0 +1,38 @@ +extra_includes: +- wpi/driverstation/Switch2ProController.hpp + +classes: + wpi::sim::Switch2ProControllerSim: + force_no_trampoline: true + typealias: + - wpi::Switch2ProController + methods: + Switch2ProControllerSim: + overloads: + const Switch2ProController&: + int: + SetLeftX: + SetLeftY: + SetRightX: + SetRightY: + SetZL: + SetZR: + SetBButton: + SetAButton: + SetYButton: + SetXButton: + SetMinusButton: + SetHomeButton: + SetPlusButton: + SetLeftStickButton: + SetRightStickButton: + SetLButton: + SetRButton: + SetDpadUpButton: + SetDpadDownButton: + SetDpadLeftButton: + SetDpadRightButton: + SetCaptureButton: + SetGRButton: + SetGLButton: + SetCButton: diff --git a/wpilibc/src/main/python/semiwrap/simulation/SwitchN64ControllerSim.yml b/wpilibc/src/main/python/semiwrap/simulation/SwitchN64ControllerSim.yml new file mode 100644 index 0000000000..ca9183f081 --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/simulation/SwitchN64ControllerSim.yml @@ -0,0 +1,32 @@ +extra_includes: +- wpi/driverstation/SwitchN64Controller.hpp + +classes: + wpi::sim::SwitchN64ControllerSim: + force_no_trampoline: true + typealias: + - wpi::SwitchN64Controller + methods: + SwitchN64ControllerSim: + overloads: + const SwitchN64Controller&: + int: + SetLeftX: + SetLeftY: + SetZAxis: + SetZR: + SetAButton: + SetBButton: + SetCLeftButton: + SetCUpButton: + SetCaptureButton: + SetHomeButton: + SetStartButton: + SetCDownButton: + SetLButton: + SetRButton: + SetDpadUpButton: + SetDpadDownButton: + SetDpadLeftButton: + SetDpadRightButton: + SetCRightButton: diff --git a/wpilibc/src/main/python/semiwrap/simulation/SwitchProControllerSim.yml b/wpilibc/src/main/python/semiwrap/simulation/SwitchProControllerSim.yml new file mode 100644 index 0000000000..f0a1ba7f84 --- /dev/null +++ b/wpilibc/src/main/python/semiwrap/simulation/SwitchProControllerSim.yml @@ -0,0 +1,35 @@ +extra_includes: +- wpi/driverstation/SwitchProController.hpp + +classes: + wpi::sim::SwitchProControllerSim: + force_no_trampoline: true + typealias: + - wpi::SwitchProController + methods: + SwitchProControllerSim: + overloads: + const SwitchProController&: + int: + SetLeftX: + SetLeftY: + SetRightX: + SetRightY: + SetZL: + SetZR: + SetBButton: + SetAButton: + SetYButton: + SetXButton: + SetMinusButton: + SetHomeButton: + SetPlusButton: + SetLeftStickButton: + SetRightStickButton: + SetLButton: + SetRButton: + SetDpadUpButton: + SetDpadDownButton: + SetDpadLeftButton: + SetDpadRightButton: + SetCaptureButton: diff --git a/wpilibc/src/main/python/wpilib/__init__.py b/wpilibc/src/main/python/wpilib/__init__.py index 01dbfb970a..8057d3acc7 100644 --- a/wpilibc/src/main/python/wpilib/__init__.py +++ b/wpilibc/src/main/python/wpilib/__init__.py @@ -26,7 +26,9 @@ from ._wpilib import ( DriverStation, DriverStationBackend, DriverStationDisplay, + DualSenseEdgeController, DualSenseController, + DualShock4Controller, DutyCycle, DutyCycleEncoder, EdgeConfiguration, @@ -39,13 +41,16 @@ from ._wpilib import ( ExpansionHubVelocityConstants, Field2d, FieldObject2d, + GameCubeController, Gamepad, GenericHID, + HIDDevice, I2C, IterativeRobotBase, Joystick, Koors40, LEDPattern, + LogitechF310Controller, MatchState, MatchType, MecanumDrive, @@ -97,6 +102,11 @@ from ._wpilib import ( Solenoid, Spark, SparkMini, + SteamController, + Switch2GCController, + Switch2ProController, + SwitchN64Controller, + SwitchProController, SystemServer, Tachometer, Talon, @@ -144,7 +154,9 @@ __all__ = [ "DriverStation", "DriverStationBackend", "DriverStationDisplay", + "DualSenseEdgeController", "DualSenseController", + "DualShock4Controller", "DutyCycle", "DutyCycleEncoder", "EdgeConfiguration", @@ -157,13 +169,16 @@ __all__ = [ "ExpansionHubVelocityConstants", "Field2d", "FieldObject2d", + "GameCubeController", "Gamepad", "GenericHID", + "HIDDevice", "I2C", "IterativeRobotBase", "Joystick", "Koors40", "LEDPattern", + "LogitechF310Controller", "MatchState", "MatchType", "MecanumDrive", @@ -215,6 +230,11 @@ __all__ = [ "Solenoid", "Spark", "SparkMini", + "SteamController", + "Switch2GCController", + "Switch2ProController", + "SwitchN64Controller", + "SwitchProController", "SystemServer", "Tachometer", "Talon", diff --git a/wpilibc/src/main/python/wpilib/simulation/__init__.py b/wpilibc/src/main/python/wpilib/simulation/__init__.py index 342056d28a..e13378d0a9 100644 --- a/wpilibc/src/main/python/wpilib/simulation/__init__.py +++ b/wpilibc/src/main/python/wpilib/simulation/__init__.py @@ -16,12 +16,15 @@ from ._simulation import ( DigitalPWMSim, DoubleSolenoidSim, DriverStationSim, + DualSenseEdgeControllerSim, DualSenseControllerSim, + DualShock4ControllerSim, DutyCycleEncoderSim, DutyCycleSim, ElevatorSim, EncoderSim, FlywheelSim, + GameCubeControllerSim, GamepadSim, GenericHIDSim, JoystickSim, @@ -35,6 +38,7 @@ from ._simulation import ( NiDsPS5ControllerSim, NiDsStadiaControllerSim, NiDsXboxControllerSim, + LogitechF310ControllerSim, OnboardIMUSim, OpModeOptions, PWMMotorControllerSim, @@ -48,6 +52,11 @@ from ._simulation import ( SimDeviceSim, SingleJointedArmSim, SolenoidSim, + SteamControllerSim, + Switch2GCControllerSim, + Switch2ProControllerSim, + SwitchN64ControllerSim, + SwitchProControllerSim, XboxControllerSim, getProgramStarted, getProgramState, @@ -77,12 +86,15 @@ __all__ = [ "DigitalPWMSim", "DoubleSolenoidSim", "DriverStationSim", + "DualSenseEdgeControllerSim", "DualSenseControllerSim", + "DualShock4ControllerSim", "DutyCycleEncoderSim", "DutyCycleSim", "ElevatorSim", "EncoderSim", "FlywheelSim", + "GameCubeControllerSim", "GamepadSim", "GenericHIDSim", "JoystickSim", @@ -96,6 +108,7 @@ __all__ = [ "NiDsPS5ControllerSim", "NiDsStadiaControllerSim", "NiDsXboxControllerSim", + "LogitechF310ControllerSim", "OnboardIMUSim", "OpModeOptions", "PWMMotorControllerSim", @@ -109,6 +122,11 @@ __all__ = [ "SimDeviceSim", "SingleJointedArmSim", "SolenoidSim", + "SteamControllerSim", + "Switch2GCControllerSim", + "Switch2ProControllerSim", + "SwitchN64ControllerSim", + "SwitchProControllerSim", "XboxControllerSim", "getProgramStarted", "getProgramState", diff --git a/wpilibj/src/generate/first_ds_hids.json b/wpilibj/src/generate/first_ds_hids.json index 721662788a..0908002cb6 100644 --- a/wpilibj/src/generate/first_ds_hids.json +++ b/wpilibj/src/generate/first_ds_hids.json @@ -72,5 +72,348 @@ "monoLed": false, "rgbLed": true } + }, + { + "ClassName": "DualSenseEdge", + "HIDType": "PS5", + "axes": { + "leftX": 0, + "leftY": 1, + "rightX": 2, + "rightY": 3, + "L2": 4, + "R2": 5 + }, + "buttons": { + "cross": 0, + "circle": 1, + "square": 2, + "triangle": 3, + "create": 4, + "PS": 5, + "options": 6, + "L3": 7, + "R3": 8, + "L1": 9, + "R1": 10, + "dpadUp": 11, + "dpadDown": 12, + "dpadLeft": 13, + "dpadRight": 14, + "microphone": 15, + "rightPaddle1": 16, + "leftPaddle1": 17, + "touchpad": 20, + "leftFunction": 21, + "rightFunction": 22 + }, + "touchpads": 1, + "supports": { + "rumble": true, + "triggerRumble": true, + "monoLed": false, + "rgbLed": true + } + }, + { + "ClassName": "DualShock4", + "HIDType": "PS4", + "axes": { + "leftX": 0, + "leftY": 1, + "rightX": 2, + "rightY": 3, + "L2": 4, + "R2": 5 + }, + "buttons": { + "cross": 0, + "circle": 1, + "square": 2, + "triangle": 3, + "share": 4, + "PS": 5, + "options": 6, + "L3": 7, + "R3": 8, + "L1": 9, + "R1": 10, + "dpadUp": 11, + "dpadDown": 12, + "dpadLeft": 13, + "dpadRight": 14, + "touchpad": 20 + }, + "touchpads": 1, + "supports": { + "rumble": true, + "triggerRumble": false, + "monoLed": false, + "rgbLed": true + } + }, + { + "ClassName": "Switch2Pro", + "HIDType": "SWITCH_PRO", + "axes": { + "leftX": 0, + "leftY": 1, + "rightX": 2, + "rightY": 3, + "ZL": 4, + "ZR": 5 + }, + "buttons": { + "b": 0, + "a": 1, + "y": 2, + "x": 3, + "minus": 4, + "home": 5, + "plus": 6, + "leftStick": 7, + "rightStick": 8, + "L": 9, + "R": 10, + "dpadUp": 11, + "dpadDown": 12, + "dpadLeft": 13, + "dpadRight": 14, + "capture": 15, + "GR": 16, + "GL": 17, + "C": 21 + }, + "touchpads": 0, + "supports": { + "rumble": true, + "triggerRumble": false, + "monoLed": false, + "rgbLed": false + } + }, + { + "ClassName": "Switch2GC", + "HIDType": "SWITCH_PRO", + "axes": { + "leftX": 0, + "leftY": 1, + "CStickX": 2, + "CStickY": 3, + "LTrigger": 4, + "RTrigger": 5 + }, + "buttons": { + "a": 0, + "x": 1, + "b": 2, + "y": 3, + "home": 5, + "start": 6, + "ZL": 9, + "Z": 10, + "dpadUp": 11, + "dpadDown": 12, + "dpadLeft": 13, + "dpadRight": 14, + "capture": 15, + "C": 21, + "L": 22, + "R": 23 + }, + "touchpads": 0, + "supports": { + "rumble": true, + "triggerRumble": false, + "monoLed": false, + "rgbLed": false + } + }, + { + "ClassName": "GameCube", + "HIDType": "STANDARD", + "axes": { + "leftX": 0, + "leftY": 1, + "CStickX": 2, + "CStickY": 3, + "LTrigger": 4, + "RTrigger": 5 + }, + "buttons": { + "a": 0, + "x": 1, + "b": 2, + "y": 3, + "start": 6, + "Z": 10, + "dpadUp": 11, + "dpadDown": 12, + "dpadLeft": 13, + "dpadRight": 14, + "L": 22, + "R": 23 + }, + "touchpads": 0, + "supports": { + "rumble": false, + "triggerRumble": false, + "monoLed": false, + "rgbLed": false + } + }, + { + "ClassName": "SwitchPro", + "HIDType": "SWITCH_PRO", + "axes": { + "leftX": 0, + "leftY": 1, + "rightX": 2, + "rightY": 3, + "ZL": 4, + "ZR": 5 + }, + "buttons": { + "b": 0, + "a": 1, + "y": 2, + "x": 3, + "minus": 4, + "home": 5, + "plus": 6, + "leftStick": 7, + "rightStick": 8, + "L": 9, + "R": 10, + "dpadUp": 11, + "dpadDown": 12, + "dpadLeft": 13, + "dpadRight": 14, + "capture": 15 + }, + "touchpads": 0, + "supports": { + "rumble": true, + "triggerRumble": false, + "monoLed": true, + "rgbLed": false + } + }, + { + "ClassName": "SwitchN64", + "HIDType": "SWITCH_PRO", + "axes": { + "leftX": 0, + "leftY": 1, + "ZAxis": 4, + "ZR": 5 + }, + "buttons": { + "a": 0, + "b": 1, + "CLeft": 3, + "CUp": 4, + "capture": 15, + "home": 5, + "start": 6, + "CDown": 2, + "L": 9, + "R": 10, + "dpadUp": 11, + "dpadDown": 12, + "dpadLeft": 13, + "dpadRight": 14, + "CRight": 21 + }, + "touchpads": 0, + "supports": { + "rumble": false, + "triggerRumble": false, + "monoLed": false, + "rgbLed": false + } + }, + { + "ClassName": "Steam", + "HIDType": "STANDARD", + "axes": { + "leftX": 0, + "leftY": 1, + "rightX": 2, + "rightY": 3, + "leftTrigger": 4, + "rightTrigger": 5 + }, + "buttons": { + "a": 0, + "b": 1, + "x": 2, + "y": 3, + "menu": 4, + "steam": 5, + "view": 6, + "leftStick": 7, + "rightStick": 8, + "leftBumper": 9, + "rightBumper": 10, + "dpadUp": 11, + "dpadDown": 12, + "dpadLeft": 13, + "dpadRight": 14, + "QAM": 15, + "rightPaddle1": 16, + "leftPaddle1": 17, + "rightPaddle2": 18, + "leftPaddle2": 19, + "leftTouchpad": 20, + "rightTouchpad": 21, + "leftStickTouch": 22, + "rightStickTouch": 23, + "leftGripTouch": 24, + "rightGripTouch": 25 + }, + "touchpads": 2, + "supports": { + "rumble": true, + "triggerRumble": false, + "monoLed": false, + "rgbLed": false + } + }, + { + "ClassName": "LogitechF310", + "HIDType": "XBOX_360", + "axes": { + "leftX": 0, + "leftY": 1, + "rightX": 2, + "rightY": 3, + "leftTrigger": 4, + "rightTrigger": 5 + }, + "buttons": { + "a": 0, + "b": 1, + "x": 2, + "y": 3, + "back": 4, + "logitech": 5, + "start": 6, + "leftStick": 7, + "rightStick": 8, + "leftBumper": 9, + "rightBumper": 10, + "dpadUp": 11, + "dpadDown": 12, + "dpadLeft": 13, + "dpadRight": 14 + }, + "touchpads": 0, + "supports": { + "rumble": false, + "triggerRumble": false, + "monoLed": false, + "rgbLed": false + } } ] diff --git a/wpilibj/src/generated/main/java/org/wpilib/driverstation/DualSenseEdgeController.java b/wpilibj/src/generated/main/java/org/wpilib/driverstation/DualSenseEdgeController.java new file mode 100644 index 0000000000..a46acf7dc0 --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/driverstation/DualSenseEdgeController.java @@ -0,0 +1,1198 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import java.util.EnumSet; +import java.util.Objects; +import org.wpilib.event.BooleanEvent; +import org.wpilib.event.EventLoop; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.util.sendable.Sendable; +import org.wpilib.util.sendable.SendableBuilder; + +/** + * Handle input from DualSenseEdge controllers connected to the Driver Station. + * + *

This class handles DualSenseEdge input that comes from the Driver Station. Each time a value + * is requested the most recent value is returned. + */ +public class DualSenseEdgeController implements HIDDevice, Sendable { + /** The number of touchpads supported by this controller. */ + public static final int TOUCHPAD_COUNT = 1; + + /** Whether this controller supports main rumble motors. */ + public static final boolean SUPPORTS_RUMBLE = true; + + /** Whether this controller supports trigger rumble motors. */ + public static final boolean SUPPORTS_TRIGGER_RUMBLE = true; + + /** Whether this controller supports mono LED output. */ + public static final boolean SUPPORTS_MONO_LED = false; + + /** Whether this controller supports RGB LED output. */ + public static final boolean SUPPORTS_RGB_LED = true; + + /** Represents a digital button on a DualSenseEdgeController. */ + public enum Button { + /** Cross button. */ + CROSS(0, "CrossButton"), + /** Circle button. */ + CIRCLE(1, "CircleButton"), + /** Square button. */ + SQUARE(2, "SquareButton"), + /** Triangle button. */ + TRIANGLE(3, "TriangleButton"), + /** Create button. */ + CREATE(4, "CreateButton"), + /** PS button. */ + PS(5, "PSButton"), + /** Options button. */ + OPTIONS(6, "OptionsButton"), + /** L 3 button. */ + L3(7, "L3Button"), + /** R 3 button. */ + R3(8, "R3Button"), + /** L 1 button. */ + L1(9, "L1Button"), + /** R 1 button. */ + R1(10, "R1Button"), + /** Dpad Up button. */ + DPAD_UP(11, "DpadUpButton"), + /** Dpad Down button. */ + DPAD_DOWN(12, "DpadDownButton"), + /** Dpad Left button. */ + DPAD_LEFT(13, "DpadLeftButton"), + /** Dpad Right button. */ + DPAD_RIGHT(14, "DpadRightButton"), + /** Microphone button. */ + MICROPHONE(15, "MicrophoneButton"), + /** Right Paddle 1 button. */ + RIGHT_PADDLE_1(16, "RightPaddle1Button"), + /** Left Paddle 1 button. */ + LEFT_PADDLE_1(17, "LeftPaddle1Button"), + /** Touchpad button. */ + TOUCHPAD(20, "TouchpadButton"), + /** Left Function button. */ + LEFT_FUNCTION(21, "LeftFunctionButton"), + /** Right Function button. */ + RIGHT_FUNCTION(22, "RightFunctionButton"); + + /** Button value. */ + public final int value; + + private final String m_name; + + Button(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + /** Represents an axis on a DualSenseEdgeController. */ + public enum Axis { + /** Left X. */ + LEFT_X(0, "LeftX"), + /** Left Y. */ + LEFT_Y(1, "LeftY"), + /** Right X. */ + RIGHT_X(2, "RightX"), + /** Right Y. */ + RIGHT_Y(3, "RightY"), + /** L 2. */ + L2(4, "L2"), + /** R 2. */ + R2(5, "R2"); + + /** Axis value. */ + public final int value; + + private final String m_name; + + Axis(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + private final GenericHID m_hid; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public DualSenseEdgeController(final int port) { + this(DriverStation.getGenericHID(port)); + } + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + public DualSenseEdgeController(final GenericHID hid) { + m_hid = Objects.requireNonNull(hid, "Provided HID object cannot be null"); + HAL.reportUsage("HID", hid.getPort(), "DualSenseEdgeController"); + } + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + @Override + public GenericHID getHID() { + return m_hid; + } + + /** + * Get the supported outputs expected for this controller type. + * + * @return the expected supported outputs + */ + public static EnumSet getSupportedOutputCapabilities() { + return EnumSet.of( + GenericHID.SupportedOutput.RGB_LED, + GenericHID.SupportedOutput.RUMBLE, + GenericHID.SupportedOutput.TRIGGER_RUMBLE + ); + } + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + public int getPort() { + return m_hid.getPort(); + } + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + public boolean isConnected() { + return m_hid.isConnected(); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return getAxis(Axis.LEFT_X); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return getAxis(Axis.LEFT_Y); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return getAxis(Axis.RIGHT_X); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return getAxis(Axis.RIGHT_Y); + } + + /** + * Get the L 2 value of the controller. + * + * @return The axis value. + */ + public double getL2() { + return getAxis(Axis.L2); + } + + /** + * Get the R 2 value of the controller. + * + * @return The axis value. + */ + public double getR2() { + return getAxis(Axis.R2); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The axis value. + */ + public double getAxis(Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + /** + * Constructs an event instance that is true when the axis value is less than {@code threshold}. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the provided + * threshold. + */ + public BooleanEvent axisLessThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs an event instance that is true when the axis value is greater than {@code + * threshold}. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than the provided + * threshold. + */ + public BooleanEvent axisGreaterThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Read the value of the Cross button on the controller. + * + * @return The state of the button. + */ + public boolean getCrossButton() { + return getButton(Button.CROSS); + } + + /** + * Whether the Cross button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getCrossButtonPressed() { + return getButtonPressed(Button.CROSS); + } + + /** + * Whether the Cross button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getCrossButtonReleased() { + return getButtonReleased(Button.CROSS); + } + + /** + * Constructs an event instance around the Cross button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Cross button's digital signal + * attached to the given loop. + */ + public BooleanEvent cross(EventLoop loop) { + return button(Button.CROSS, loop); + } + + /** + * Read the value of the Circle button on the controller. + * + * @return The state of the button. + */ + public boolean getCircleButton() { + return getButton(Button.CIRCLE); + } + + /** + * Whether the Circle button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getCircleButtonPressed() { + return getButtonPressed(Button.CIRCLE); + } + + /** + * Whether the Circle button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getCircleButtonReleased() { + return getButtonReleased(Button.CIRCLE); + } + + /** + * Constructs an event instance around the Circle button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Circle button's digital signal + * attached to the given loop. + */ + public BooleanEvent circle(EventLoop loop) { + return button(Button.CIRCLE, loop); + } + + /** + * Read the value of the Square button on the controller. + * + * @return The state of the button. + */ + public boolean getSquareButton() { + return getButton(Button.SQUARE); + } + + /** + * Whether the Square button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getSquareButtonPressed() { + return getButtonPressed(Button.SQUARE); + } + + /** + * Whether the Square button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getSquareButtonReleased() { + return getButtonReleased(Button.SQUARE); + } + + /** + * Constructs an event instance around the Square button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Square button's digital signal + * attached to the given loop. + */ + public BooleanEvent square(EventLoop loop) { + return button(Button.SQUARE, loop); + } + + /** + * Read the value of the Triangle button on the controller. + * + * @return The state of the button. + */ + public boolean getTriangleButton() { + return getButton(Button.TRIANGLE); + } + + /** + * Whether the Triangle button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getTriangleButtonPressed() { + return getButtonPressed(Button.TRIANGLE); + } + + /** + * Whether the Triangle button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getTriangleButtonReleased() { + return getButtonReleased(Button.TRIANGLE); + } + + /** + * Constructs an event instance around the Triangle button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Triangle button's digital signal + * attached to the given loop. + */ + public BooleanEvent triangle(EventLoop loop) { + return button(Button.TRIANGLE, loop); + } + + /** + * Read the value of the Create button on the controller. + * + * @return The state of the button. + */ + public boolean getCreateButton() { + return getButton(Button.CREATE); + } + + /** + * Whether the Create button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getCreateButtonPressed() { + return getButtonPressed(Button.CREATE); + } + + /** + * Whether the Create button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getCreateButtonReleased() { + return getButtonReleased(Button.CREATE); + } + + /** + * Constructs an event instance around the Create button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Create button's digital signal + * attached to the given loop. + */ + public BooleanEvent create(EventLoop loop) { + return button(Button.CREATE, loop); + } + + /** + * Read the value of the PS button on the controller. + * + * @return The state of the button. + */ + public boolean getPSButton() { + return getButton(Button.PS); + } + + /** + * Whether the PS button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getPSButtonPressed() { + return getButtonPressed(Button.PS); + } + + /** + * Whether the PS button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getPSButtonReleased() { + return getButtonReleased(Button.PS); + } + + /** + * Constructs an event instance around the PS button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the PS button's digital signal + * attached to the given loop. + */ + public BooleanEvent PS(EventLoop loop) { + return button(Button.PS, loop); + } + + /** + * Read the value of the Options button on the controller. + * + * @return The state of the button. + */ + public boolean getOptionsButton() { + return getButton(Button.OPTIONS); + } + + /** + * Whether the Options button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getOptionsButtonPressed() { + return getButtonPressed(Button.OPTIONS); + } + + /** + * Whether the Options button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getOptionsButtonReleased() { + return getButtonReleased(Button.OPTIONS); + } + + /** + * Constructs an event instance around the Options button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Options button's digital signal + * attached to the given loop. + */ + public BooleanEvent options(EventLoop loop) { + return button(Button.OPTIONS, loop); + } + + /** + * Read the value of the L 3 button on the controller. + * + * @return The state of the button. + */ + public boolean getL3Button() { + return getButton(Button.L3); + } + + /** + * Whether the L 3 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getL3ButtonPressed() { + return getButtonPressed(Button.L3); + } + + /** + * Whether the L 3 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getL3ButtonReleased() { + return getButtonReleased(Button.L3); + } + + /** + * Constructs an event instance around the L 3 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L 3 button's digital signal + * attached to the given loop. + */ + public BooleanEvent L3(EventLoop loop) { + return button(Button.L3, loop); + } + + /** + * Read the value of the R 3 button on the controller. + * + * @return The state of the button. + */ + public boolean getR3Button() { + return getButton(Button.R3); + } + + /** + * Whether the R 3 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getR3ButtonPressed() { + return getButtonPressed(Button.R3); + } + + /** + * Whether the R 3 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getR3ButtonReleased() { + return getButtonReleased(Button.R3); + } + + /** + * Constructs an event instance around the R 3 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R 3 button's digital signal + * attached to the given loop. + */ + public BooleanEvent R3(EventLoop loop) { + return button(Button.R3, loop); + } + + /** + * Read the value of the L 1 button on the controller. + * + * @return The state of the button. + */ + public boolean getL1Button() { + return getButton(Button.L1); + } + + /** + * Whether the L 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getL1ButtonPressed() { + return getButtonPressed(Button.L1); + } + + /** + * Whether the L 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getL1ButtonReleased() { + return getButtonReleased(Button.L1); + } + + /** + * Constructs an event instance around the L 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L 1 button's digital signal + * attached to the given loop. + */ + public BooleanEvent L1(EventLoop loop) { + return button(Button.L1, loop); + } + + /** + * Read the value of the R 1 button on the controller. + * + * @return The state of the button. + */ + public boolean getR1Button() { + return getButton(Button.R1); + } + + /** + * Whether the R 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getR1ButtonPressed() { + return getButtonPressed(Button.R1); + } + + /** + * Whether the R 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getR1ButtonReleased() { + return getButtonReleased(Button.R1); + } + + /** + * Constructs an event instance around the R 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R 1 button's digital signal + * attached to the given loop. + */ + public BooleanEvent R1(EventLoop loop) { + return button(Button.R1, loop); + } + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadUpButton() { + return getButton(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadUpButtonPressed() { + return getButtonPressed(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadUpButtonReleased() { + return getButtonReleased(Button.DPAD_UP); + } + + /** + * Constructs an event instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadUp(EventLoop loop) { + return button(Button.DPAD_UP, loop); + } + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadDownButton() { + return getButton(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadDownButtonPressed() { + return getButtonPressed(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadDownButtonReleased() { + return getButtonReleased(Button.DPAD_DOWN); + } + + /** + * Constructs an event instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadDown(EventLoop loop) { + return button(Button.DPAD_DOWN, loop); + } + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadLeftButton() { + return getButton(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadLeftButtonPressed() { + return getButtonPressed(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadLeftButtonReleased() { + return getButtonReleased(Button.DPAD_LEFT); + } + + /** + * Constructs an event instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadLeft(EventLoop loop) { + return button(Button.DPAD_LEFT, loop); + } + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadRightButton() { + return getButton(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadRightButtonPressed() { + return getButtonPressed(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadRightButtonReleased() { + return getButtonReleased(Button.DPAD_RIGHT); + } + + /** + * Constructs an event instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadRight(EventLoop loop) { + return button(Button.DPAD_RIGHT, loop); + } + + /** + * Read the value of the Microphone button on the controller. + * + * @return The state of the button. + */ + public boolean getMicrophoneButton() { + return getButton(Button.MICROPHONE); + } + + /** + * Whether the Microphone button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getMicrophoneButtonPressed() { + return getButtonPressed(Button.MICROPHONE); + } + + /** + * Whether the Microphone button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getMicrophoneButtonReleased() { + return getButtonReleased(Button.MICROPHONE); + } + + /** + * Constructs an event instance around the Microphone button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Microphone button's digital signal + * attached to the given loop. + */ + public BooleanEvent microphone(EventLoop loop) { + return button(Button.MICROPHONE, loop); + } + + /** + * Read the value of the Right Paddle 1 button on the controller. + * + * @return The state of the button. + */ + public boolean getRightPaddle1Button() { + return getButton(Button.RIGHT_PADDLE_1); + } + + /** + * Whether the Right Paddle 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightPaddle1ButtonPressed() { + return getButtonPressed(Button.RIGHT_PADDLE_1); + } + + /** + * Whether the Right Paddle 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightPaddle1ButtonReleased() { + return getButtonReleased(Button.RIGHT_PADDLE_1); + } + + /** + * Constructs an event instance around the Right Paddle 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Paddle 1 button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightPaddle1(EventLoop loop) { + return button(Button.RIGHT_PADDLE_1, loop); + } + + /** + * Read the value of the Left Paddle 1 button on the controller. + * + * @return The state of the button. + */ + public boolean getLeftPaddle1Button() { + return getButton(Button.LEFT_PADDLE_1); + } + + /** + * Whether the Left Paddle 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLeftPaddle1ButtonPressed() { + return getButtonPressed(Button.LEFT_PADDLE_1); + } + + /** + * Whether the Left Paddle 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLeftPaddle1ButtonReleased() { + return getButtonReleased(Button.LEFT_PADDLE_1); + } + + /** + * Constructs an event instance around the Left Paddle 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Paddle 1 button's digital signal + * attached to the given loop. + */ + public BooleanEvent leftPaddle1(EventLoop loop) { + return button(Button.LEFT_PADDLE_1, loop); + } + + /** + * Read the value of the Touchpad button on the controller. + * + * @return The state of the button. + */ + public boolean getTouchpadButton() { + return getButton(Button.TOUCHPAD); + } + + /** + * Whether the Touchpad button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getTouchpadButtonPressed() { + return getButtonPressed(Button.TOUCHPAD); + } + + /** + * Whether the Touchpad button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getTouchpadButtonReleased() { + return getButtonReleased(Button.TOUCHPAD); + } + + /** + * Constructs an event instance around the Touchpad button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Touchpad button's digital signal + * attached to the given loop. + */ + public BooleanEvent touchpad(EventLoop loop) { + return button(Button.TOUCHPAD, loop); + } + + /** + * Read the value of the Left Function button on the controller. + * + * @return The state of the button. + */ + public boolean getLeftFunctionButton() { + return getButton(Button.LEFT_FUNCTION); + } + + /** + * Whether the Left Function button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLeftFunctionButtonPressed() { + return getButtonPressed(Button.LEFT_FUNCTION); + } + + /** + * Whether the Left Function button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLeftFunctionButtonReleased() { + return getButtonReleased(Button.LEFT_FUNCTION); + } + + /** + * Constructs an event instance around the Left Function button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Function button's digital signal + * attached to the given loop. + */ + public BooleanEvent leftFunction(EventLoop loop) { + return button(Button.LEFT_FUNCTION, loop); + } + + /** + * Read the value of the Right Function button on the controller. + * + * @return The state of the button. + */ + public boolean getRightFunctionButton() { + return getButton(Button.RIGHT_FUNCTION); + } + + /** + * Whether the Right Function button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightFunctionButtonPressed() { + return getButtonPressed(Button.RIGHT_FUNCTION); + } + + /** + * Whether the Right Function button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightFunctionButtonReleased() { + return getButtonReleased(Button.RIGHT_FUNCTION); + } + + /** + * Constructs an event instance around the Right Function button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Function button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightFunction(EventLoop loop) { + return button(Button.RIGHT_FUNCTION, loop); + } + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + public boolean getButton(Button button) { + return m_hid.getRawButton(button.value); + } + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + public boolean getButtonPressed(Button button) { + return m_hid.getRawButtonPressed(button.value); + } + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + public boolean getButtonReleased(Button button) { + return m_hid.getRawButtonReleased(button.value); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public BooleanEvent button(Button button, EventLoop loop) { + return m_hid.button(button.value, loop); + } + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + public void setLeds(int r, int g, int b) { + m_hid.setLeds(r, g, b); + } + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + public void setRumble(GenericHID.RumbleType type, double value) { + m_hid.setRumble(type, value); + } + + + /** + * Check if a touchpad finger is available. + * + * @param finger The finger to check. + * @return true if the touchpad finger is available. + */ + public boolean getTouchpadFingerAvailable(int finger) { + return m_hid.getTouchpadFingerAvailable(0, finger); + } + + /** + * Get the touchpad finger data. + * + * @param finger The finger to read. + * @return The touchpad finger data. + */ + public TouchpadFinger getTouchpadFinger(int finger) { + return m_hid.getTouchpadFinger(0, finger); + } + + + @Override + public void initSendable(SendableBuilder builder) { + builder.setSmartDashboardType("HID"); + builder.publishConstString("ControllerType", "DualSenseEdge"); + builder.addDoubleProperty("LeftX", this::getLeftX, null); + builder.addDoubleProperty("LeftY", this::getLeftY, null); + builder.addDoubleProperty("RightX", this::getRightX, null); + builder.addDoubleProperty("RightY", this::getRightY, null); + builder.addDoubleProperty("L2", this::getL2, null); + builder.addDoubleProperty("R2", this::getR2, null); + builder.addBooleanProperty("Cross", this::getCrossButton, null); + builder.addBooleanProperty("Circle", this::getCircleButton, null); + builder.addBooleanProperty("Square", this::getSquareButton, null); + builder.addBooleanProperty("Triangle", this::getTriangleButton, null); + builder.addBooleanProperty("Create", this::getCreateButton, null); + builder.addBooleanProperty("PS", this::getPSButton, null); + builder.addBooleanProperty("Options", this::getOptionsButton, null); + builder.addBooleanProperty("L3", this::getL3Button, null); + builder.addBooleanProperty("R3", this::getR3Button, null); + builder.addBooleanProperty("L1", this::getL1Button, null); + builder.addBooleanProperty("R1", this::getR1Button, null); + builder.addBooleanProperty("DpadUp", this::getDpadUpButton, null); + builder.addBooleanProperty("DpadDown", this::getDpadDownButton, null); + builder.addBooleanProperty("DpadLeft", this::getDpadLeftButton, null); + builder.addBooleanProperty("DpadRight", this::getDpadRightButton, null); + builder.addBooleanProperty("Microphone", this::getMicrophoneButton, null); + builder.addBooleanProperty("RightPaddle1", this::getRightPaddle1Button, null); + builder.addBooleanProperty("LeftPaddle1", this::getLeftPaddle1Button, null); + builder.addBooleanProperty("Touchpad", this::getTouchpadButton, null); + builder.addBooleanProperty("LeftFunction", this::getLeftFunctionButton, null); + builder.addBooleanProperty("RightFunction", this::getRightFunctionButton, null); + } +} diff --git a/wpilibj/src/generated/main/java/org/wpilib/driverstation/DualShock4Controller.java b/wpilibj/src/generated/main/java/org/wpilib/driverstation/DualShock4Controller.java new file mode 100644 index 0000000000..b5243f6438 --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/driverstation/DualShock4Controller.java @@ -0,0 +1,992 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import java.util.EnumSet; +import java.util.Objects; +import org.wpilib.event.BooleanEvent; +import org.wpilib.event.EventLoop; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.util.sendable.Sendable; +import org.wpilib.util.sendable.SendableBuilder; + +/** + * Handle input from DualShock4 controllers connected to the Driver Station. + * + *

This class handles DualShock4 input that comes from the Driver Station. Each time a value + * is requested the most recent value is returned. + */ +public class DualShock4Controller implements HIDDevice, Sendable { + /** The number of touchpads supported by this controller. */ + public static final int TOUCHPAD_COUNT = 1; + + /** Whether this controller supports main rumble motors. */ + public static final boolean SUPPORTS_RUMBLE = true; + + /** Whether this controller supports trigger rumble motors. */ + public static final boolean SUPPORTS_TRIGGER_RUMBLE = false; + + /** Whether this controller supports mono LED output. */ + public static final boolean SUPPORTS_MONO_LED = false; + + /** Whether this controller supports RGB LED output. */ + public static final boolean SUPPORTS_RGB_LED = true; + + /** Represents a digital button on a DualShock4Controller. */ + public enum Button { + /** Cross button. */ + CROSS(0, "CrossButton"), + /** Circle button. */ + CIRCLE(1, "CircleButton"), + /** Square button. */ + SQUARE(2, "SquareButton"), + /** Triangle button. */ + TRIANGLE(3, "TriangleButton"), + /** Share button. */ + SHARE(4, "ShareButton"), + /** PS button. */ + PS(5, "PSButton"), + /** Options button. */ + OPTIONS(6, "OptionsButton"), + /** L 3 button. */ + L3(7, "L3Button"), + /** R 3 button. */ + R3(8, "R3Button"), + /** L 1 button. */ + L1(9, "L1Button"), + /** R 1 button. */ + R1(10, "R1Button"), + /** Dpad Up button. */ + DPAD_UP(11, "DpadUpButton"), + /** Dpad Down button. */ + DPAD_DOWN(12, "DpadDownButton"), + /** Dpad Left button. */ + DPAD_LEFT(13, "DpadLeftButton"), + /** Dpad Right button. */ + DPAD_RIGHT(14, "DpadRightButton"), + /** Touchpad button. */ + TOUCHPAD(20, "TouchpadButton"); + + /** Button value. */ + public final int value; + + private final String m_name; + + Button(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + /** Represents an axis on a DualShock4Controller. */ + public enum Axis { + /** Left X. */ + LEFT_X(0, "LeftX"), + /** Left Y. */ + LEFT_Y(1, "LeftY"), + /** Right X. */ + RIGHT_X(2, "RightX"), + /** Right Y. */ + RIGHT_Y(3, "RightY"), + /** L 2. */ + L2(4, "L2"), + /** R 2. */ + R2(5, "R2"); + + /** Axis value. */ + public final int value; + + private final String m_name; + + Axis(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + private final GenericHID m_hid; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public DualShock4Controller(final int port) { + this(DriverStation.getGenericHID(port)); + } + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + public DualShock4Controller(final GenericHID hid) { + m_hid = Objects.requireNonNull(hid, "Provided HID object cannot be null"); + HAL.reportUsage("HID", hid.getPort(), "DualShock4Controller"); + } + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + @Override + public GenericHID getHID() { + return m_hid; + } + + /** + * Get the supported outputs expected for this controller type. + * + * @return the expected supported outputs + */ + public static EnumSet getSupportedOutputCapabilities() { + return EnumSet.of( + GenericHID.SupportedOutput.RGB_LED, + GenericHID.SupportedOutput.RUMBLE + ); + } + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + public int getPort() { + return m_hid.getPort(); + } + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + public boolean isConnected() { + return m_hid.isConnected(); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return getAxis(Axis.LEFT_X); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return getAxis(Axis.LEFT_Y); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return getAxis(Axis.RIGHT_X); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return getAxis(Axis.RIGHT_Y); + } + + /** + * Get the L 2 value of the controller. + * + * @return The axis value. + */ + public double getL2() { + return getAxis(Axis.L2); + } + + /** + * Get the R 2 value of the controller. + * + * @return The axis value. + */ + public double getR2() { + return getAxis(Axis.R2); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The axis value. + */ + public double getAxis(Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + /** + * Constructs an event instance that is true when the axis value is less than {@code threshold}. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the provided + * threshold. + */ + public BooleanEvent axisLessThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs an event instance that is true when the axis value is greater than {@code + * threshold}. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than the provided + * threshold. + */ + public BooleanEvent axisGreaterThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Read the value of the Cross button on the controller. + * + * @return The state of the button. + */ + public boolean getCrossButton() { + return getButton(Button.CROSS); + } + + /** + * Whether the Cross button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getCrossButtonPressed() { + return getButtonPressed(Button.CROSS); + } + + /** + * Whether the Cross button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getCrossButtonReleased() { + return getButtonReleased(Button.CROSS); + } + + /** + * Constructs an event instance around the Cross button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Cross button's digital signal + * attached to the given loop. + */ + public BooleanEvent cross(EventLoop loop) { + return button(Button.CROSS, loop); + } + + /** + * Read the value of the Circle button on the controller. + * + * @return The state of the button. + */ + public boolean getCircleButton() { + return getButton(Button.CIRCLE); + } + + /** + * Whether the Circle button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getCircleButtonPressed() { + return getButtonPressed(Button.CIRCLE); + } + + /** + * Whether the Circle button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getCircleButtonReleased() { + return getButtonReleased(Button.CIRCLE); + } + + /** + * Constructs an event instance around the Circle button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Circle button's digital signal + * attached to the given loop. + */ + public BooleanEvent circle(EventLoop loop) { + return button(Button.CIRCLE, loop); + } + + /** + * Read the value of the Square button on the controller. + * + * @return The state of the button. + */ + public boolean getSquareButton() { + return getButton(Button.SQUARE); + } + + /** + * Whether the Square button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getSquareButtonPressed() { + return getButtonPressed(Button.SQUARE); + } + + /** + * Whether the Square button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getSquareButtonReleased() { + return getButtonReleased(Button.SQUARE); + } + + /** + * Constructs an event instance around the Square button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Square button's digital signal + * attached to the given loop. + */ + public BooleanEvent square(EventLoop loop) { + return button(Button.SQUARE, loop); + } + + /** + * Read the value of the Triangle button on the controller. + * + * @return The state of the button. + */ + public boolean getTriangleButton() { + return getButton(Button.TRIANGLE); + } + + /** + * Whether the Triangle button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getTriangleButtonPressed() { + return getButtonPressed(Button.TRIANGLE); + } + + /** + * Whether the Triangle button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getTriangleButtonReleased() { + return getButtonReleased(Button.TRIANGLE); + } + + /** + * Constructs an event instance around the Triangle button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Triangle button's digital signal + * attached to the given loop. + */ + public BooleanEvent triangle(EventLoop loop) { + return button(Button.TRIANGLE, loop); + } + + /** + * Read the value of the Share button on the controller. + * + * @return The state of the button. + */ + public boolean getShareButton() { + return getButton(Button.SHARE); + } + + /** + * Whether the Share button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getShareButtonPressed() { + return getButtonPressed(Button.SHARE); + } + + /** + * Whether the Share button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getShareButtonReleased() { + return getButtonReleased(Button.SHARE); + } + + /** + * Constructs an event instance around the Share button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Share button's digital signal + * attached to the given loop. + */ + public BooleanEvent share(EventLoop loop) { + return button(Button.SHARE, loop); + } + + /** + * Read the value of the PS button on the controller. + * + * @return The state of the button. + */ + public boolean getPSButton() { + return getButton(Button.PS); + } + + /** + * Whether the PS button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getPSButtonPressed() { + return getButtonPressed(Button.PS); + } + + /** + * Whether the PS button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getPSButtonReleased() { + return getButtonReleased(Button.PS); + } + + /** + * Constructs an event instance around the PS button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the PS button's digital signal + * attached to the given loop. + */ + public BooleanEvent PS(EventLoop loop) { + return button(Button.PS, loop); + } + + /** + * Read the value of the Options button on the controller. + * + * @return The state of the button. + */ + public boolean getOptionsButton() { + return getButton(Button.OPTIONS); + } + + /** + * Whether the Options button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getOptionsButtonPressed() { + return getButtonPressed(Button.OPTIONS); + } + + /** + * Whether the Options button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getOptionsButtonReleased() { + return getButtonReleased(Button.OPTIONS); + } + + /** + * Constructs an event instance around the Options button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Options button's digital signal + * attached to the given loop. + */ + public BooleanEvent options(EventLoop loop) { + return button(Button.OPTIONS, loop); + } + + /** + * Read the value of the L 3 button on the controller. + * + * @return The state of the button. + */ + public boolean getL3Button() { + return getButton(Button.L3); + } + + /** + * Whether the L 3 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getL3ButtonPressed() { + return getButtonPressed(Button.L3); + } + + /** + * Whether the L 3 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getL3ButtonReleased() { + return getButtonReleased(Button.L3); + } + + /** + * Constructs an event instance around the L 3 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L 3 button's digital signal + * attached to the given loop. + */ + public BooleanEvent L3(EventLoop loop) { + return button(Button.L3, loop); + } + + /** + * Read the value of the R 3 button on the controller. + * + * @return The state of the button. + */ + public boolean getR3Button() { + return getButton(Button.R3); + } + + /** + * Whether the R 3 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getR3ButtonPressed() { + return getButtonPressed(Button.R3); + } + + /** + * Whether the R 3 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getR3ButtonReleased() { + return getButtonReleased(Button.R3); + } + + /** + * Constructs an event instance around the R 3 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R 3 button's digital signal + * attached to the given loop. + */ + public BooleanEvent R3(EventLoop loop) { + return button(Button.R3, loop); + } + + /** + * Read the value of the L 1 button on the controller. + * + * @return The state of the button. + */ + public boolean getL1Button() { + return getButton(Button.L1); + } + + /** + * Whether the L 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getL1ButtonPressed() { + return getButtonPressed(Button.L1); + } + + /** + * Whether the L 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getL1ButtonReleased() { + return getButtonReleased(Button.L1); + } + + /** + * Constructs an event instance around the L 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L 1 button's digital signal + * attached to the given loop. + */ + public BooleanEvent L1(EventLoop loop) { + return button(Button.L1, loop); + } + + /** + * Read the value of the R 1 button on the controller. + * + * @return The state of the button. + */ + public boolean getR1Button() { + return getButton(Button.R1); + } + + /** + * Whether the R 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getR1ButtonPressed() { + return getButtonPressed(Button.R1); + } + + /** + * Whether the R 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getR1ButtonReleased() { + return getButtonReleased(Button.R1); + } + + /** + * Constructs an event instance around the R 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R 1 button's digital signal + * attached to the given loop. + */ + public BooleanEvent R1(EventLoop loop) { + return button(Button.R1, loop); + } + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadUpButton() { + return getButton(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadUpButtonPressed() { + return getButtonPressed(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadUpButtonReleased() { + return getButtonReleased(Button.DPAD_UP); + } + + /** + * Constructs an event instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadUp(EventLoop loop) { + return button(Button.DPAD_UP, loop); + } + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadDownButton() { + return getButton(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadDownButtonPressed() { + return getButtonPressed(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadDownButtonReleased() { + return getButtonReleased(Button.DPAD_DOWN); + } + + /** + * Constructs an event instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadDown(EventLoop loop) { + return button(Button.DPAD_DOWN, loop); + } + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadLeftButton() { + return getButton(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadLeftButtonPressed() { + return getButtonPressed(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadLeftButtonReleased() { + return getButtonReleased(Button.DPAD_LEFT); + } + + /** + * Constructs an event instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadLeft(EventLoop loop) { + return button(Button.DPAD_LEFT, loop); + } + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadRightButton() { + return getButton(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadRightButtonPressed() { + return getButtonPressed(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadRightButtonReleased() { + return getButtonReleased(Button.DPAD_RIGHT); + } + + /** + * Constructs an event instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadRight(EventLoop loop) { + return button(Button.DPAD_RIGHT, loop); + } + + /** + * Read the value of the Touchpad button on the controller. + * + * @return The state of the button. + */ + public boolean getTouchpadButton() { + return getButton(Button.TOUCHPAD); + } + + /** + * Whether the Touchpad button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getTouchpadButtonPressed() { + return getButtonPressed(Button.TOUCHPAD); + } + + /** + * Whether the Touchpad button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getTouchpadButtonReleased() { + return getButtonReleased(Button.TOUCHPAD); + } + + /** + * Constructs an event instance around the Touchpad button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Touchpad button's digital signal + * attached to the given loop. + */ + public BooleanEvent touchpad(EventLoop loop) { + return button(Button.TOUCHPAD, loop); + } + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + public boolean getButton(Button button) { + return m_hid.getRawButton(button.value); + } + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + public boolean getButtonPressed(Button button) { + return m_hid.getRawButtonPressed(button.value); + } + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + public boolean getButtonReleased(Button button) { + return m_hid.getRawButtonReleased(button.value); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public BooleanEvent button(Button button, EventLoop loop) { + return m_hid.button(button.value, loop); + } + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + public void setLeds(int r, int g, int b) { + m_hid.setLeds(r, g, b); + } + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + public void setRumble(GenericHID.RumbleType type, double value) { + m_hid.setRumble(type, value); + } + + + /** + * Check if a touchpad finger is available. + * + * @param finger The finger to check. + * @return true if the touchpad finger is available. + */ + public boolean getTouchpadFingerAvailable(int finger) { + return m_hid.getTouchpadFingerAvailable(0, finger); + } + + /** + * Get the touchpad finger data. + * + * @param finger The finger to read. + * @return The touchpad finger data. + */ + public TouchpadFinger getTouchpadFinger(int finger) { + return m_hid.getTouchpadFinger(0, finger); + } + + + @Override + public void initSendable(SendableBuilder builder) { + builder.setSmartDashboardType("HID"); + builder.publishConstString("ControllerType", "DualShock4"); + builder.addDoubleProperty("LeftX", this::getLeftX, null); + builder.addDoubleProperty("LeftY", this::getLeftY, null); + builder.addDoubleProperty("RightX", this::getRightX, null); + builder.addDoubleProperty("RightY", this::getRightY, null); + builder.addDoubleProperty("L2", this::getL2, null); + builder.addDoubleProperty("R2", this::getR2, null); + builder.addBooleanProperty("Cross", this::getCrossButton, null); + builder.addBooleanProperty("Circle", this::getCircleButton, null); + builder.addBooleanProperty("Square", this::getSquareButton, null); + builder.addBooleanProperty("Triangle", this::getTriangleButton, null); + builder.addBooleanProperty("Share", this::getShareButton, null); + builder.addBooleanProperty("PS", this::getPSButton, null); + builder.addBooleanProperty("Options", this::getOptionsButton, null); + builder.addBooleanProperty("L3", this::getL3Button, null); + builder.addBooleanProperty("R3", this::getR3Button, null); + builder.addBooleanProperty("L1", this::getL1Button, null); + builder.addBooleanProperty("R1", this::getR1Button, null); + builder.addBooleanProperty("DpadUp", this::getDpadUpButton, null); + builder.addBooleanProperty("DpadDown", this::getDpadDownButton, null); + builder.addBooleanProperty("DpadLeft", this::getDpadLeftButton, null); + builder.addBooleanProperty("DpadRight", this::getDpadRightButton, null); + builder.addBooleanProperty("Touchpad", this::getTouchpadButton, null); + } +} diff --git a/wpilibj/src/generated/main/java/org/wpilib/driverstation/GameCubeController.java b/wpilibj/src/generated/main/java/org/wpilib/driverstation/GameCubeController.java new file mode 100644 index 0000000000..02e4361b4a --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/driverstation/GameCubeController.java @@ -0,0 +1,805 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import java.util.EnumSet; +import java.util.Objects; +import org.wpilib.event.BooleanEvent; +import org.wpilib.event.EventLoop; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.util.sendable.Sendable; +import org.wpilib.util.sendable.SendableBuilder; + +/** + * Handle input from GameCube controllers connected to the Driver Station. + * + *

This class handles GameCube input that comes from the Driver Station. Each time a value + * is requested the most recent value is returned. + */ +public class GameCubeController implements HIDDevice, Sendable { + /** The number of touchpads supported by this controller. */ + public static final int TOUCHPAD_COUNT = 0; + + /** Whether this controller supports main rumble motors. */ + public static final boolean SUPPORTS_RUMBLE = false; + + /** Whether this controller supports trigger rumble motors. */ + public static final boolean SUPPORTS_TRIGGER_RUMBLE = false; + + /** Whether this controller supports mono LED output. */ + public static final boolean SUPPORTS_MONO_LED = false; + + /** Whether this controller supports RGB LED output. */ + public static final boolean SUPPORTS_RGB_LED = false; + + /** Represents a digital button on a GameCubeController. */ + public enum Button { + /** A button. */ + A(0, "AButton"), + /** X button. */ + X(1, "XButton"), + /** B button. */ + B(2, "BButton"), + /** Y button. */ + Y(3, "YButton"), + /** Start button. */ + START(6, "StartButton"), + /** Z button. */ + Z(10, "ZButton"), + /** Dpad Up button. */ + DPAD_UP(11, "DpadUpButton"), + /** Dpad Down button. */ + DPAD_DOWN(12, "DpadDownButton"), + /** Dpad Left button. */ + DPAD_LEFT(13, "DpadLeftButton"), + /** Dpad Right button. */ + DPAD_RIGHT(14, "DpadRightButton"), + /** L button. */ + L(22, "LButton"), + /** R button. */ + R(23, "RButton"); + + /** Button value. */ + public final int value; + + private final String m_name; + + Button(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + /** Represents an axis on a GameCubeController. */ + public enum Axis { + /** Left X. */ + LEFT_X(0, "LeftX"), + /** Left Y. */ + LEFT_Y(1, "LeftY"), + /** C Stick X. */ + C_STICK_X(2, "CStickX"), + /** C Stick Y. */ + C_STICK_Y(3, "CStickY"), + /** L Trigger. */ + L_TRIGGER(4, "LTrigger"), + /** R Trigger. */ + R_TRIGGER(5, "RTrigger"); + + /** Axis value. */ + public final int value; + + private final String m_name; + + Axis(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + private final GenericHID m_hid; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public GameCubeController(final int port) { + this(DriverStation.getGenericHID(port)); + } + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + public GameCubeController(final GenericHID hid) { + m_hid = Objects.requireNonNull(hid, "Provided HID object cannot be null"); + HAL.reportUsage("HID", hid.getPort(), "GameCubeController"); + } + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + @Override + public GenericHID getHID() { + return m_hid; + } + + /** + * Get the supported outputs expected for this controller type. + * + * @return the expected supported outputs + */ + public static EnumSet getSupportedOutputCapabilities() { + return EnumSet.noneOf(GenericHID.SupportedOutput.class); + } + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + public int getPort() { + return m_hid.getPort(); + } + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + public boolean isConnected() { + return m_hid.isConnected(); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return getAxis(Axis.LEFT_X); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return getAxis(Axis.LEFT_Y); + } + + /** + * Get the C Stick X value of the controller. + * + * @return The axis value. + */ + public double getCStickX() { + return getAxis(Axis.C_STICK_X); + } + + /** + * Get the C Stick Y value of the controller. + * + * @return The axis value. + */ + public double getCStickY() { + return getAxis(Axis.C_STICK_Y); + } + + /** + * Get the L Trigger value of the controller. + * + * @return The axis value. + */ + public double getLTrigger() { + return getAxis(Axis.L_TRIGGER); + } + + /** + * Get the R Trigger value of the controller. + * + * @return The axis value. + */ + public double getRTrigger() { + return getAxis(Axis.R_TRIGGER); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The axis value. + */ + public double getAxis(Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + /** + * Constructs an event instance that is true when the axis value is less than {@code threshold}. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the provided + * threshold. + */ + public BooleanEvent axisLessThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs an event instance that is true when the axis value is greater than {@code + * threshold}. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than the provided + * threshold. + */ + public BooleanEvent axisGreaterThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Read the value of the A button on the controller. + * + * @return The state of the button. + */ + public boolean getAButton() { + return getButton(Button.A); + } + + /** + * Whether the A button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getAButtonPressed() { + return getButtonPressed(Button.A); + } + + /** + * Whether the A button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getAButtonReleased() { + return getButtonReleased(Button.A); + } + + /** + * Constructs an event instance around the A button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the A button's digital signal + * attached to the given loop. + */ + public BooleanEvent a(EventLoop loop) { + return button(Button.A, loop); + } + + /** + * Read the value of the X button on the controller. + * + * @return The state of the button. + */ + public boolean getXButton() { + return getButton(Button.X); + } + + /** + * Whether the X button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getXButtonPressed() { + return getButtonPressed(Button.X); + } + + /** + * Whether the X button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getXButtonReleased() { + return getButtonReleased(Button.X); + } + + /** + * Constructs an event instance around the X button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the X button's digital signal + * attached to the given loop. + */ + public BooleanEvent x(EventLoop loop) { + return button(Button.X, loop); + } + + /** + * Read the value of the B button on the controller. + * + * @return The state of the button. + */ + public boolean getBButton() { + return getButton(Button.B); + } + + /** + * Whether the B button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getBButtonPressed() { + return getButtonPressed(Button.B); + } + + /** + * Whether the B button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getBButtonReleased() { + return getButtonReleased(Button.B); + } + + /** + * Constructs an event instance around the B button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the B button's digital signal + * attached to the given loop. + */ + public BooleanEvent b(EventLoop loop) { + return button(Button.B, loop); + } + + /** + * Read the value of the Y button on the controller. + * + * @return The state of the button. + */ + public boolean getYButton() { + return getButton(Button.Y); + } + + /** + * Whether the Y button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getYButtonPressed() { + return getButtonPressed(Button.Y); + } + + /** + * Whether the Y button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getYButtonReleased() { + return getButtonReleased(Button.Y); + } + + /** + * Constructs an event instance around the Y button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Y button's digital signal + * attached to the given loop. + */ + public BooleanEvent y(EventLoop loop) { + return button(Button.Y, loop); + } + + /** + * Read the value of the Start button on the controller. + * + * @return The state of the button. + */ + public boolean getStartButton() { + return getButton(Button.START); + } + + /** + * Whether the Start button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getStartButtonPressed() { + return getButtonPressed(Button.START); + } + + /** + * Whether the Start button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getStartButtonReleased() { + return getButtonReleased(Button.START); + } + + /** + * Constructs an event instance around the Start button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Start button's digital signal + * attached to the given loop. + */ + public BooleanEvent start(EventLoop loop) { + return button(Button.START, loop); + } + + /** + * Read the value of the Z button on the controller. + * + * @return The state of the button. + */ + public boolean getZButton() { + return getButton(Button.Z); + } + + /** + * Whether the Z button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getZButtonPressed() { + return getButtonPressed(Button.Z); + } + + /** + * Whether the Z button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getZButtonReleased() { + return getButtonReleased(Button.Z); + } + + /** + * Constructs an event instance around the Z button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Z button's digital signal + * attached to the given loop. + */ + public BooleanEvent Z(EventLoop loop) { + return button(Button.Z, loop); + } + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadUpButton() { + return getButton(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadUpButtonPressed() { + return getButtonPressed(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadUpButtonReleased() { + return getButtonReleased(Button.DPAD_UP); + } + + /** + * Constructs an event instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadUp(EventLoop loop) { + return button(Button.DPAD_UP, loop); + } + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadDownButton() { + return getButton(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadDownButtonPressed() { + return getButtonPressed(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadDownButtonReleased() { + return getButtonReleased(Button.DPAD_DOWN); + } + + /** + * Constructs an event instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadDown(EventLoop loop) { + return button(Button.DPAD_DOWN, loop); + } + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadLeftButton() { + return getButton(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadLeftButtonPressed() { + return getButtonPressed(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadLeftButtonReleased() { + return getButtonReleased(Button.DPAD_LEFT); + } + + /** + * Constructs an event instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadLeft(EventLoop loop) { + return button(Button.DPAD_LEFT, loop); + } + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadRightButton() { + return getButton(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadRightButtonPressed() { + return getButtonPressed(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadRightButtonReleased() { + return getButtonReleased(Button.DPAD_RIGHT); + } + + /** + * Constructs an event instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadRight(EventLoop loop) { + return button(Button.DPAD_RIGHT, loop); + } + + /** + * Read the value of the L button on the controller. + * + * @return The state of the button. + */ + public boolean getLButton() { + return getButton(Button.L); + } + + /** + * Whether the L button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLButtonPressed() { + return getButtonPressed(Button.L); + } + + /** + * Whether the L button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLButtonReleased() { + return getButtonReleased(Button.L); + } + + /** + * Constructs an event instance around the L button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L button's digital signal + * attached to the given loop. + */ + public BooleanEvent L(EventLoop loop) { + return button(Button.L, loop); + } + + /** + * Read the value of the R button on the controller. + * + * @return The state of the button. + */ + public boolean getRButton() { + return getButton(Button.R); + } + + /** + * Whether the R button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRButtonPressed() { + return getButtonPressed(Button.R); + } + + /** + * Whether the R button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRButtonReleased() { + return getButtonReleased(Button.R); + } + + /** + * Constructs an event instance around the R button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R button's digital signal + * attached to the given loop. + */ + public BooleanEvent R(EventLoop loop) { + return button(Button.R, loop); + } + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + public boolean getButton(Button button) { + return m_hid.getRawButton(button.value); + } + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + public boolean getButtonPressed(Button button) { + return m_hid.getRawButtonPressed(button.value); + } + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + public boolean getButtonReleased(Button button) { + return m_hid.getRawButtonReleased(button.value); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public BooleanEvent button(Button button, EventLoop loop) { + return m_hid.button(button.value, loop); + } + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + public void setLeds(int r, int g, int b) { + m_hid.setLeds(r, g, b); + } + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + public void setRumble(GenericHID.RumbleType type, double value) { + m_hid.setRumble(type, value); + } + + + + @Override + public void initSendable(SendableBuilder builder) { + builder.setSmartDashboardType("HID"); + builder.publishConstString("ControllerType", "GameCube"); + builder.addDoubleProperty("LeftX", this::getLeftX, null); + builder.addDoubleProperty("LeftY", this::getLeftY, null); + builder.addDoubleProperty("CStickX", this::getCStickX, null); + builder.addDoubleProperty("CStickY", this::getCStickY, null); + builder.addDoubleProperty("LTrigger", this::getLTrigger, null); + builder.addDoubleProperty("RTrigger", this::getRTrigger, null); + builder.addBooleanProperty("A", this::getAButton, null); + builder.addBooleanProperty("X", this::getXButton, null); + builder.addBooleanProperty("B", this::getBButton, null); + builder.addBooleanProperty("Y", this::getYButton, null); + builder.addBooleanProperty("Start", this::getStartButton, null); + builder.addBooleanProperty("Z", this::getZButton, null); + builder.addBooleanProperty("DpadUp", this::getDpadUpButton, null); + builder.addBooleanProperty("DpadDown", this::getDpadDownButton, null); + builder.addBooleanProperty("DpadLeft", this::getDpadLeftButton, null); + builder.addBooleanProperty("DpadRight", this::getDpadRightButton, null); + builder.addBooleanProperty("L", this::getLButton, null); + builder.addBooleanProperty("R", this::getRButton, null); + } +} diff --git a/wpilibj/src/generated/main/java/org/wpilib/driverstation/LogitechF310Controller.java b/wpilibj/src/generated/main/java/org/wpilib/driverstation/LogitechF310Controller.java new file mode 100644 index 0000000000..7320ac9327 --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/driverstation/LogitechF310Controller.java @@ -0,0 +1,928 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import java.util.EnumSet; +import java.util.Objects; +import org.wpilib.event.BooleanEvent; +import org.wpilib.event.EventLoop; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.util.sendable.Sendable; +import org.wpilib.util.sendable.SendableBuilder; + +/** + * Handle input from LogitechF310 controllers connected to the Driver Station. + * + *

This class handles LogitechF310 input that comes from the Driver Station. Each time a value + * is requested the most recent value is returned. + */ +public class LogitechF310Controller implements HIDDevice, Sendable { + /** The number of touchpads supported by this controller. */ + public static final int TOUCHPAD_COUNT = 0; + + /** Whether this controller supports main rumble motors. */ + public static final boolean SUPPORTS_RUMBLE = false; + + /** Whether this controller supports trigger rumble motors. */ + public static final boolean SUPPORTS_TRIGGER_RUMBLE = false; + + /** Whether this controller supports mono LED output. */ + public static final boolean SUPPORTS_MONO_LED = false; + + /** Whether this controller supports RGB LED output. */ + public static final boolean SUPPORTS_RGB_LED = false; + + /** Represents a digital button on a LogitechF310Controller. */ + public enum Button { + /** A button. */ + A(0, "AButton"), + /** B button. */ + B(1, "BButton"), + /** X button. */ + X(2, "XButton"), + /** Y button. */ + Y(3, "YButton"), + /** Back button. */ + BACK(4, "BackButton"), + /** Logitech button. */ + LOGITECH(5, "LogitechButton"), + /** Start button. */ + START(6, "StartButton"), + /** Left Stick button. */ + LEFT_STICK(7, "LeftStickButton"), + /** Right Stick button. */ + RIGHT_STICK(8, "RightStickButton"), + /** Left Bumper button. */ + LEFT_BUMPER(9, "LeftBumperButton"), + /** Right Bumper button. */ + RIGHT_BUMPER(10, "RightBumperButton"), + /** Dpad Up button. */ + DPAD_UP(11, "DpadUpButton"), + /** Dpad Down button. */ + DPAD_DOWN(12, "DpadDownButton"), + /** Dpad Left button. */ + DPAD_LEFT(13, "DpadLeftButton"), + /** Dpad Right button. */ + DPAD_RIGHT(14, "DpadRightButton"); + + /** Button value. */ + public final int value; + + private final String m_name; + + Button(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + /** Represents an axis on a LogitechF310Controller. */ + public enum Axis { + /** Left X. */ + LEFT_X(0, "LeftX"), + /** Left Y. */ + LEFT_Y(1, "LeftY"), + /** Right X. */ + RIGHT_X(2, "RightX"), + /** Right Y. */ + RIGHT_Y(3, "RightY"), + /** Left Trigger. */ + LEFT_TRIGGER(4, "LeftTrigger"), + /** Right Trigger. */ + RIGHT_TRIGGER(5, "RightTrigger"); + + /** Axis value. */ + public final int value; + + private final String m_name; + + Axis(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + private final GenericHID m_hid; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public LogitechF310Controller(final int port) { + this(DriverStation.getGenericHID(port)); + } + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + public LogitechF310Controller(final GenericHID hid) { + m_hid = Objects.requireNonNull(hid, "Provided HID object cannot be null"); + HAL.reportUsage("HID", hid.getPort(), "LogitechF310Controller"); + } + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + @Override + public GenericHID getHID() { + return m_hid; + } + + /** + * Get the supported outputs expected for this controller type. + * + * @return the expected supported outputs + */ + public static EnumSet getSupportedOutputCapabilities() { + return EnumSet.noneOf(GenericHID.SupportedOutput.class); + } + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + public int getPort() { + return m_hid.getPort(); + } + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + public boolean isConnected() { + return m_hid.isConnected(); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return getAxis(Axis.LEFT_X); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return getAxis(Axis.LEFT_Y); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return getAxis(Axis.RIGHT_X); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return getAxis(Axis.RIGHT_Y); + } + + /** + * Get the Left Trigger value of the controller. + * + * @return The axis value. + */ + public double getLeftTrigger() { + return getAxis(Axis.LEFT_TRIGGER); + } + + /** + * Get the Right Trigger value of the controller. + * + * @return The axis value. + */ + public double getRightTrigger() { + return getAxis(Axis.RIGHT_TRIGGER); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The axis value. + */ + public double getAxis(Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + /** + * Constructs an event instance that is true when the axis value is less than {@code threshold}. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the provided + * threshold. + */ + public BooleanEvent axisLessThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs an event instance that is true when the axis value is greater than {@code + * threshold}. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than the provided + * threshold. + */ + public BooleanEvent axisGreaterThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Read the value of the A button on the controller. + * + * @return The state of the button. + */ + public boolean getAButton() { + return getButton(Button.A); + } + + /** + * Whether the A button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getAButtonPressed() { + return getButtonPressed(Button.A); + } + + /** + * Whether the A button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getAButtonReleased() { + return getButtonReleased(Button.A); + } + + /** + * Constructs an event instance around the A button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the A button's digital signal + * attached to the given loop. + */ + public BooleanEvent a(EventLoop loop) { + return button(Button.A, loop); + } + + /** + * Read the value of the B button on the controller. + * + * @return The state of the button. + */ + public boolean getBButton() { + return getButton(Button.B); + } + + /** + * Whether the B button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getBButtonPressed() { + return getButtonPressed(Button.B); + } + + /** + * Whether the B button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getBButtonReleased() { + return getButtonReleased(Button.B); + } + + /** + * Constructs an event instance around the B button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the B button's digital signal + * attached to the given loop. + */ + public BooleanEvent b(EventLoop loop) { + return button(Button.B, loop); + } + + /** + * Read the value of the X button on the controller. + * + * @return The state of the button. + */ + public boolean getXButton() { + return getButton(Button.X); + } + + /** + * Whether the X button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getXButtonPressed() { + return getButtonPressed(Button.X); + } + + /** + * Whether the X button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getXButtonReleased() { + return getButtonReleased(Button.X); + } + + /** + * Constructs an event instance around the X button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the X button's digital signal + * attached to the given loop. + */ + public BooleanEvent x(EventLoop loop) { + return button(Button.X, loop); + } + + /** + * Read the value of the Y button on the controller. + * + * @return The state of the button. + */ + public boolean getYButton() { + return getButton(Button.Y); + } + + /** + * Whether the Y button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getYButtonPressed() { + return getButtonPressed(Button.Y); + } + + /** + * Whether the Y button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getYButtonReleased() { + return getButtonReleased(Button.Y); + } + + /** + * Constructs an event instance around the Y button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Y button's digital signal + * attached to the given loop. + */ + public BooleanEvent y(EventLoop loop) { + return button(Button.Y, loop); + } + + /** + * Read the value of the Back button on the controller. + * + * @return The state of the button. + */ + public boolean getBackButton() { + return getButton(Button.BACK); + } + + /** + * Whether the Back button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getBackButtonPressed() { + return getButtonPressed(Button.BACK); + } + + /** + * Whether the Back button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getBackButtonReleased() { + return getButtonReleased(Button.BACK); + } + + /** + * Constructs an event instance around the Back button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Back button's digital signal + * attached to the given loop. + */ + public BooleanEvent back(EventLoop loop) { + return button(Button.BACK, loop); + } + + /** + * Read the value of the Logitech button on the controller. + * + * @return The state of the button. + */ + public boolean getLogitechButton() { + return getButton(Button.LOGITECH); + } + + /** + * Whether the Logitech button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLogitechButtonPressed() { + return getButtonPressed(Button.LOGITECH); + } + + /** + * Whether the Logitech button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLogitechButtonReleased() { + return getButtonReleased(Button.LOGITECH); + } + + /** + * Constructs an event instance around the Logitech button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Logitech button's digital signal + * attached to the given loop. + */ + public BooleanEvent logitech(EventLoop loop) { + return button(Button.LOGITECH, loop); + } + + /** + * Read the value of the Start button on the controller. + * + * @return The state of the button. + */ + public boolean getStartButton() { + return getButton(Button.START); + } + + /** + * Whether the Start button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getStartButtonPressed() { + return getButtonPressed(Button.START); + } + + /** + * Whether the Start button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getStartButtonReleased() { + return getButtonReleased(Button.START); + } + + /** + * Constructs an event instance around the Start button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Start button's digital signal + * attached to the given loop. + */ + public BooleanEvent start(EventLoop loop) { + return button(Button.START, loop); + } + + /** + * Read the value of the Left Stick button on the controller. + * + * @return The state of the button. + */ + public boolean getLeftStickButton() { + return getButton(Button.LEFT_STICK); + } + + /** + * Whether the Left Stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLeftStickButtonPressed() { + return getButtonPressed(Button.LEFT_STICK); + } + + /** + * Whether the Left Stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLeftStickButtonReleased() { + return getButtonReleased(Button.LEFT_STICK); + } + + /** + * Constructs an event instance around the Left Stick button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Stick button's digital signal + * attached to the given loop. + */ + public BooleanEvent leftStick(EventLoop loop) { + return button(Button.LEFT_STICK, loop); + } + + /** + * Read the value of the Right Stick button on the controller. + * + * @return The state of the button. + */ + public boolean getRightStickButton() { + return getButton(Button.RIGHT_STICK); + } + + /** + * Whether the Right Stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightStickButtonPressed() { + return getButtonPressed(Button.RIGHT_STICK); + } + + /** + * Whether the Right Stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightStickButtonReleased() { + return getButtonReleased(Button.RIGHT_STICK); + } + + /** + * Constructs an event instance around the Right Stick button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Stick button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightStick(EventLoop loop) { + return button(Button.RIGHT_STICK, loop); + } + + /** + * Read the value of the Left Bumper button on the controller. + * + * @return The state of the button. + */ + public boolean getLeftBumperButton() { + return getButton(Button.LEFT_BUMPER); + } + + /** + * Whether the Left Bumper button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLeftBumperButtonPressed() { + return getButtonPressed(Button.LEFT_BUMPER); + } + + /** + * Whether the Left Bumper button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLeftBumperButtonReleased() { + return getButtonReleased(Button.LEFT_BUMPER); + } + + /** + * Constructs an event instance around the Left Bumper button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Bumper button's digital signal + * attached to the given loop. + */ + public BooleanEvent leftBumper(EventLoop loop) { + return button(Button.LEFT_BUMPER, loop); + } + + /** + * Read the value of the Right Bumper button on the controller. + * + * @return The state of the button. + */ + public boolean getRightBumperButton() { + return getButton(Button.RIGHT_BUMPER); + } + + /** + * Whether the Right Bumper button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightBumperButtonPressed() { + return getButtonPressed(Button.RIGHT_BUMPER); + } + + /** + * Whether the Right Bumper button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightBumperButtonReleased() { + return getButtonReleased(Button.RIGHT_BUMPER); + } + + /** + * Constructs an event instance around the Right Bumper button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Bumper button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightBumper(EventLoop loop) { + return button(Button.RIGHT_BUMPER, loop); + } + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadUpButton() { + return getButton(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadUpButtonPressed() { + return getButtonPressed(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadUpButtonReleased() { + return getButtonReleased(Button.DPAD_UP); + } + + /** + * Constructs an event instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadUp(EventLoop loop) { + return button(Button.DPAD_UP, loop); + } + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadDownButton() { + return getButton(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadDownButtonPressed() { + return getButtonPressed(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadDownButtonReleased() { + return getButtonReleased(Button.DPAD_DOWN); + } + + /** + * Constructs an event instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadDown(EventLoop loop) { + return button(Button.DPAD_DOWN, loop); + } + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadLeftButton() { + return getButton(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadLeftButtonPressed() { + return getButtonPressed(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadLeftButtonReleased() { + return getButtonReleased(Button.DPAD_LEFT); + } + + /** + * Constructs an event instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadLeft(EventLoop loop) { + return button(Button.DPAD_LEFT, loop); + } + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadRightButton() { + return getButton(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadRightButtonPressed() { + return getButtonPressed(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadRightButtonReleased() { + return getButtonReleased(Button.DPAD_RIGHT); + } + + /** + * Constructs an event instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadRight(EventLoop loop) { + return button(Button.DPAD_RIGHT, loop); + } + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + public boolean getButton(Button button) { + return m_hid.getRawButton(button.value); + } + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + public boolean getButtonPressed(Button button) { + return m_hid.getRawButtonPressed(button.value); + } + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + public boolean getButtonReleased(Button button) { + return m_hid.getRawButtonReleased(button.value); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public BooleanEvent button(Button button, EventLoop loop) { + return m_hid.button(button.value, loop); + } + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + public void setLeds(int r, int g, int b) { + m_hid.setLeds(r, g, b); + } + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + public void setRumble(GenericHID.RumbleType type, double value) { + m_hid.setRumble(type, value); + } + + + + @Override + public void initSendable(SendableBuilder builder) { + builder.setSmartDashboardType("HID"); + builder.publishConstString("ControllerType", "LogitechF310"); + builder.addDoubleProperty("LeftX", this::getLeftX, null); + builder.addDoubleProperty("LeftY", this::getLeftY, null); + builder.addDoubleProperty("RightX", this::getRightX, null); + builder.addDoubleProperty("RightY", this::getRightY, null); + builder.addDoubleProperty("LeftTrigger", this::getLeftTrigger, null); + builder.addDoubleProperty("RightTrigger", this::getRightTrigger, null); + builder.addBooleanProperty("A", this::getAButton, null); + builder.addBooleanProperty("B", this::getBButton, null); + builder.addBooleanProperty("X", this::getXButton, null); + builder.addBooleanProperty("Y", this::getYButton, null); + builder.addBooleanProperty("Back", this::getBackButton, null); + builder.addBooleanProperty("Logitech", this::getLogitechButton, null); + builder.addBooleanProperty("Start", this::getStartButton, null); + builder.addBooleanProperty("LeftStick", this::getLeftStickButton, null); + builder.addBooleanProperty("RightStick", this::getRightStickButton, null); + builder.addBooleanProperty("LeftBumper", this::getLeftBumperButton, null); + builder.addBooleanProperty("RightBumper", this::getRightBumperButton, null); + builder.addBooleanProperty("DpadUp", this::getDpadUpButton, null); + builder.addBooleanProperty("DpadDown", this::getDpadDownButton, null); + builder.addBooleanProperty("DpadLeft", this::getDpadLeftButton, null); + builder.addBooleanProperty("DpadRight", this::getDpadRightButton, null); + } +} diff --git a/wpilibj/src/generated/main/java/org/wpilib/driverstation/SteamController.java b/wpilibj/src/generated/main/java/org/wpilib/driverstation/SteamController.java new file mode 100644 index 0000000000..4f6b11861f --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/driverstation/SteamController.java @@ -0,0 +1,1403 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import java.util.EnumSet; +import java.util.Objects; +import org.wpilib.event.BooleanEvent; +import org.wpilib.event.EventLoop; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.util.sendable.Sendable; +import org.wpilib.util.sendable.SendableBuilder; + +/** + * Handle input from Steam controllers connected to the Driver Station. + * + *

This class handles Steam input that comes from the Driver Station. Each time a value + * is requested the most recent value is returned. + */ +public class SteamController implements HIDDevice, Sendable { + /** The number of touchpads supported by this controller. */ + public static final int TOUCHPAD_COUNT = 2; + + /** Whether this controller supports main rumble motors. */ + public static final boolean SUPPORTS_RUMBLE = true; + + /** Whether this controller supports trigger rumble motors. */ + public static final boolean SUPPORTS_TRIGGER_RUMBLE = false; + + /** Whether this controller supports mono LED output. */ + public static final boolean SUPPORTS_MONO_LED = false; + + /** Whether this controller supports RGB LED output. */ + public static final boolean SUPPORTS_RGB_LED = false; + + /** Represents a digital button on a SteamController. */ + public enum Button { + /** A button. */ + A(0, "AButton"), + /** B button. */ + B(1, "BButton"), + /** X button. */ + X(2, "XButton"), + /** Y button. */ + Y(3, "YButton"), + /** Menu button. */ + MENU(4, "MenuButton"), + /** Steam button. */ + STEAM(5, "SteamButton"), + /** View button. */ + VIEW(6, "ViewButton"), + /** Left Stick button. */ + LEFT_STICK(7, "LeftStickButton"), + /** Right Stick button. */ + RIGHT_STICK(8, "RightStickButton"), + /** Left Bumper button. */ + LEFT_BUMPER(9, "LeftBumperButton"), + /** Right Bumper button. */ + RIGHT_BUMPER(10, "RightBumperButton"), + /** Dpad Up button. */ + DPAD_UP(11, "DpadUpButton"), + /** Dpad Down button. */ + DPAD_DOWN(12, "DpadDownButton"), + /** Dpad Left button. */ + DPAD_LEFT(13, "DpadLeftButton"), + /** Dpad Right button. */ + DPAD_RIGHT(14, "DpadRightButton"), + /** QAM button. */ + QAM(15, "QAMButton"), + /** Right Paddle 1 button. */ + RIGHT_PADDLE_1(16, "RightPaddle1Button"), + /** Left Paddle 1 button. */ + LEFT_PADDLE_1(17, "LeftPaddle1Button"), + /** Right Paddle 2 button. */ + RIGHT_PADDLE_2(18, "RightPaddle2Button"), + /** Left Paddle 2 button. */ + LEFT_PADDLE_2(19, "LeftPaddle2Button"), + /** Left Touchpad button. */ + LEFT_TOUCHPAD(20, "LeftTouchpadButton"), + /** Right Touchpad button. */ + RIGHT_TOUCHPAD(21, "RightTouchpadButton"), + /** Left Stick Touch button. */ + LEFT_STICK_TOUCH(22, "LeftStickTouchButton"), + /** Right Stick Touch button. */ + RIGHT_STICK_TOUCH(23, "RightStickTouchButton"), + /** Left Grip Touch button. */ + LEFT_GRIP_TOUCH(24, "LeftGripTouchButton"), + /** Right Grip Touch button. */ + RIGHT_GRIP_TOUCH(25, "RightGripTouchButton"); + + /** Button value. */ + public final int value; + + private final String m_name; + + Button(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + /** Represents an axis on a SteamController. */ + public enum Axis { + /** Left X. */ + LEFT_X(0, "LeftX"), + /** Left Y. */ + LEFT_Y(1, "LeftY"), + /** Right X. */ + RIGHT_X(2, "RightX"), + /** Right Y. */ + RIGHT_Y(3, "RightY"), + /** Left Trigger. */ + LEFT_TRIGGER(4, "LeftTrigger"), + /** Right Trigger. */ + RIGHT_TRIGGER(5, "RightTrigger"); + + /** Axis value. */ + public final int value; + + private final String m_name; + + Axis(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + private final GenericHID m_hid; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public SteamController(final int port) { + this(DriverStation.getGenericHID(port)); + } + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + public SteamController(final GenericHID hid) { + m_hid = Objects.requireNonNull(hid, "Provided HID object cannot be null"); + HAL.reportUsage("HID", hid.getPort(), "SteamController"); + } + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + @Override + public GenericHID getHID() { + return m_hid; + } + + /** + * Get the supported outputs expected for this controller type. + * + * @return the expected supported outputs + */ + public static EnumSet getSupportedOutputCapabilities() { + return EnumSet.of( + GenericHID.SupportedOutput.RUMBLE + ); + } + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + public int getPort() { + return m_hid.getPort(); + } + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + public boolean isConnected() { + return m_hid.isConnected(); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return getAxis(Axis.LEFT_X); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return getAxis(Axis.LEFT_Y); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return getAxis(Axis.RIGHT_X); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return getAxis(Axis.RIGHT_Y); + } + + /** + * Get the Left Trigger value of the controller. + * + * @return The axis value. + */ + public double getLeftTrigger() { + return getAxis(Axis.LEFT_TRIGGER); + } + + /** + * Get the Right Trigger value of the controller. + * + * @return The axis value. + */ + public double getRightTrigger() { + return getAxis(Axis.RIGHT_TRIGGER); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The axis value. + */ + public double getAxis(Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + /** + * Constructs an event instance that is true when the axis value is less than {@code threshold}. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the provided + * threshold. + */ + public BooleanEvent axisLessThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs an event instance that is true when the axis value is greater than {@code + * threshold}. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than the provided + * threshold. + */ + public BooleanEvent axisGreaterThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Read the value of the A button on the controller. + * + * @return The state of the button. + */ + public boolean getAButton() { + return getButton(Button.A); + } + + /** + * Whether the A button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getAButtonPressed() { + return getButtonPressed(Button.A); + } + + /** + * Whether the A button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getAButtonReleased() { + return getButtonReleased(Button.A); + } + + /** + * Constructs an event instance around the A button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the A button's digital signal + * attached to the given loop. + */ + public BooleanEvent a(EventLoop loop) { + return button(Button.A, loop); + } + + /** + * Read the value of the B button on the controller. + * + * @return The state of the button. + */ + public boolean getBButton() { + return getButton(Button.B); + } + + /** + * Whether the B button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getBButtonPressed() { + return getButtonPressed(Button.B); + } + + /** + * Whether the B button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getBButtonReleased() { + return getButtonReleased(Button.B); + } + + /** + * Constructs an event instance around the B button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the B button's digital signal + * attached to the given loop. + */ + public BooleanEvent b(EventLoop loop) { + return button(Button.B, loop); + } + + /** + * Read the value of the X button on the controller. + * + * @return The state of the button. + */ + public boolean getXButton() { + return getButton(Button.X); + } + + /** + * Whether the X button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getXButtonPressed() { + return getButtonPressed(Button.X); + } + + /** + * Whether the X button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getXButtonReleased() { + return getButtonReleased(Button.X); + } + + /** + * Constructs an event instance around the X button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the X button's digital signal + * attached to the given loop. + */ + public BooleanEvent x(EventLoop loop) { + return button(Button.X, loop); + } + + /** + * Read the value of the Y button on the controller. + * + * @return The state of the button. + */ + public boolean getYButton() { + return getButton(Button.Y); + } + + /** + * Whether the Y button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getYButtonPressed() { + return getButtonPressed(Button.Y); + } + + /** + * Whether the Y button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getYButtonReleased() { + return getButtonReleased(Button.Y); + } + + /** + * Constructs an event instance around the Y button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Y button's digital signal + * attached to the given loop. + */ + public BooleanEvent y(EventLoop loop) { + return button(Button.Y, loop); + } + + /** + * Read the value of the Menu button on the controller. + * + * @return The state of the button. + */ + public boolean getMenuButton() { + return getButton(Button.MENU); + } + + /** + * Whether the Menu button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getMenuButtonPressed() { + return getButtonPressed(Button.MENU); + } + + /** + * Whether the Menu button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getMenuButtonReleased() { + return getButtonReleased(Button.MENU); + } + + /** + * Constructs an event instance around the Menu button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Menu button's digital signal + * attached to the given loop. + */ + public BooleanEvent menu(EventLoop loop) { + return button(Button.MENU, loop); + } + + /** + * Read the value of the Steam button on the controller. + * + * @return The state of the button. + */ + public boolean getSteamButton() { + return getButton(Button.STEAM); + } + + /** + * Whether the Steam button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getSteamButtonPressed() { + return getButtonPressed(Button.STEAM); + } + + /** + * Whether the Steam button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getSteamButtonReleased() { + return getButtonReleased(Button.STEAM); + } + + /** + * Constructs an event instance around the Steam button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Steam button's digital signal + * attached to the given loop. + */ + public BooleanEvent steam(EventLoop loop) { + return button(Button.STEAM, loop); + } + + /** + * Read the value of the View button on the controller. + * + * @return The state of the button. + */ + public boolean getViewButton() { + return getButton(Button.VIEW); + } + + /** + * Whether the View button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getViewButtonPressed() { + return getButtonPressed(Button.VIEW); + } + + /** + * Whether the View button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getViewButtonReleased() { + return getButtonReleased(Button.VIEW); + } + + /** + * Constructs an event instance around the View button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the View button's digital signal + * attached to the given loop. + */ + public BooleanEvent view(EventLoop loop) { + return button(Button.VIEW, loop); + } + + /** + * Read the value of the Left Stick button on the controller. + * + * @return The state of the button. + */ + public boolean getLeftStickButton() { + return getButton(Button.LEFT_STICK); + } + + /** + * Whether the Left Stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLeftStickButtonPressed() { + return getButtonPressed(Button.LEFT_STICK); + } + + /** + * Whether the Left Stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLeftStickButtonReleased() { + return getButtonReleased(Button.LEFT_STICK); + } + + /** + * Constructs an event instance around the Left Stick button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Stick button's digital signal + * attached to the given loop. + */ + public BooleanEvent leftStick(EventLoop loop) { + return button(Button.LEFT_STICK, loop); + } + + /** + * Read the value of the Right Stick button on the controller. + * + * @return The state of the button. + */ + public boolean getRightStickButton() { + return getButton(Button.RIGHT_STICK); + } + + /** + * Whether the Right Stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightStickButtonPressed() { + return getButtonPressed(Button.RIGHT_STICK); + } + + /** + * Whether the Right Stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightStickButtonReleased() { + return getButtonReleased(Button.RIGHT_STICK); + } + + /** + * Constructs an event instance around the Right Stick button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Stick button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightStick(EventLoop loop) { + return button(Button.RIGHT_STICK, loop); + } + + /** + * Read the value of the Left Bumper button on the controller. + * + * @return The state of the button. + */ + public boolean getLeftBumperButton() { + return getButton(Button.LEFT_BUMPER); + } + + /** + * Whether the Left Bumper button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLeftBumperButtonPressed() { + return getButtonPressed(Button.LEFT_BUMPER); + } + + /** + * Whether the Left Bumper button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLeftBumperButtonReleased() { + return getButtonReleased(Button.LEFT_BUMPER); + } + + /** + * Constructs an event instance around the Left Bumper button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Bumper button's digital signal + * attached to the given loop. + */ + public BooleanEvent leftBumper(EventLoop loop) { + return button(Button.LEFT_BUMPER, loop); + } + + /** + * Read the value of the Right Bumper button on the controller. + * + * @return The state of the button. + */ + public boolean getRightBumperButton() { + return getButton(Button.RIGHT_BUMPER); + } + + /** + * Whether the Right Bumper button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightBumperButtonPressed() { + return getButtonPressed(Button.RIGHT_BUMPER); + } + + /** + * Whether the Right Bumper button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightBumperButtonReleased() { + return getButtonReleased(Button.RIGHT_BUMPER); + } + + /** + * Constructs an event instance around the Right Bumper button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Bumper button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightBumper(EventLoop loop) { + return button(Button.RIGHT_BUMPER, loop); + } + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadUpButton() { + return getButton(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadUpButtonPressed() { + return getButtonPressed(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadUpButtonReleased() { + return getButtonReleased(Button.DPAD_UP); + } + + /** + * Constructs an event instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadUp(EventLoop loop) { + return button(Button.DPAD_UP, loop); + } + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadDownButton() { + return getButton(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadDownButtonPressed() { + return getButtonPressed(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadDownButtonReleased() { + return getButtonReleased(Button.DPAD_DOWN); + } + + /** + * Constructs an event instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadDown(EventLoop loop) { + return button(Button.DPAD_DOWN, loop); + } + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadLeftButton() { + return getButton(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadLeftButtonPressed() { + return getButtonPressed(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadLeftButtonReleased() { + return getButtonReleased(Button.DPAD_LEFT); + } + + /** + * Constructs an event instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadLeft(EventLoop loop) { + return button(Button.DPAD_LEFT, loop); + } + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadRightButton() { + return getButton(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadRightButtonPressed() { + return getButtonPressed(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadRightButtonReleased() { + return getButtonReleased(Button.DPAD_RIGHT); + } + + /** + * Constructs an event instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadRight(EventLoop loop) { + return button(Button.DPAD_RIGHT, loop); + } + + /** + * Read the value of the QAM button on the controller. + * + * @return The state of the button. + */ + public boolean getQAMButton() { + return getButton(Button.QAM); + } + + /** + * Whether the QAM button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getQAMButtonPressed() { + return getButtonPressed(Button.QAM); + } + + /** + * Whether the QAM button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getQAMButtonReleased() { + return getButtonReleased(Button.QAM); + } + + /** + * Constructs an event instance around the QAM button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the QAM button's digital signal + * attached to the given loop. + */ + public BooleanEvent QAM(EventLoop loop) { + return button(Button.QAM, loop); + } + + /** + * Read the value of the Right Paddle 1 button on the controller. + * + * @return The state of the button. + */ + public boolean getRightPaddle1Button() { + return getButton(Button.RIGHT_PADDLE_1); + } + + /** + * Whether the Right Paddle 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightPaddle1ButtonPressed() { + return getButtonPressed(Button.RIGHT_PADDLE_1); + } + + /** + * Whether the Right Paddle 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightPaddle1ButtonReleased() { + return getButtonReleased(Button.RIGHT_PADDLE_1); + } + + /** + * Constructs an event instance around the Right Paddle 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Paddle 1 button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightPaddle1(EventLoop loop) { + return button(Button.RIGHT_PADDLE_1, loop); + } + + /** + * Read the value of the Left Paddle 1 button on the controller. + * + * @return The state of the button. + */ + public boolean getLeftPaddle1Button() { + return getButton(Button.LEFT_PADDLE_1); + } + + /** + * Whether the Left Paddle 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLeftPaddle1ButtonPressed() { + return getButtonPressed(Button.LEFT_PADDLE_1); + } + + /** + * Whether the Left Paddle 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLeftPaddle1ButtonReleased() { + return getButtonReleased(Button.LEFT_PADDLE_1); + } + + /** + * Constructs an event instance around the Left Paddle 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Paddle 1 button's digital signal + * attached to the given loop. + */ + public BooleanEvent leftPaddle1(EventLoop loop) { + return button(Button.LEFT_PADDLE_1, loop); + } + + /** + * Read the value of the Right Paddle 2 button on the controller. + * + * @return The state of the button. + */ + public boolean getRightPaddle2Button() { + return getButton(Button.RIGHT_PADDLE_2); + } + + /** + * Whether the Right Paddle 2 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightPaddle2ButtonPressed() { + return getButtonPressed(Button.RIGHT_PADDLE_2); + } + + /** + * Whether the Right Paddle 2 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightPaddle2ButtonReleased() { + return getButtonReleased(Button.RIGHT_PADDLE_2); + } + + /** + * Constructs an event instance around the Right Paddle 2 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Paddle 2 button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightPaddle2(EventLoop loop) { + return button(Button.RIGHT_PADDLE_2, loop); + } + + /** + * Read the value of the Left Paddle 2 button on the controller. + * + * @return The state of the button. + */ + public boolean getLeftPaddle2Button() { + return getButton(Button.LEFT_PADDLE_2); + } + + /** + * Whether the Left Paddle 2 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLeftPaddle2ButtonPressed() { + return getButtonPressed(Button.LEFT_PADDLE_2); + } + + /** + * Whether the Left Paddle 2 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLeftPaddle2ButtonReleased() { + return getButtonReleased(Button.LEFT_PADDLE_2); + } + + /** + * Constructs an event instance around the Left Paddle 2 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Paddle 2 button's digital signal + * attached to the given loop. + */ + public BooleanEvent leftPaddle2(EventLoop loop) { + return button(Button.LEFT_PADDLE_2, loop); + } + + /** + * Read the value of the Left Touchpad button on the controller. + * + * @return The state of the button. + */ + public boolean getLeftTouchpadButton() { + return getButton(Button.LEFT_TOUCHPAD); + } + + /** + * Whether the Left Touchpad button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLeftTouchpadButtonPressed() { + return getButtonPressed(Button.LEFT_TOUCHPAD); + } + + /** + * Whether the Left Touchpad button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLeftTouchpadButtonReleased() { + return getButtonReleased(Button.LEFT_TOUCHPAD); + } + + /** + * Constructs an event instance around the Left Touchpad button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Touchpad button's digital signal + * attached to the given loop. + */ + public BooleanEvent leftTouchpad(EventLoop loop) { + return button(Button.LEFT_TOUCHPAD, loop); + } + + /** + * Read the value of the Right Touchpad button on the controller. + * + * @return The state of the button. + */ + public boolean getRightTouchpadButton() { + return getButton(Button.RIGHT_TOUCHPAD); + } + + /** + * Whether the Right Touchpad button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightTouchpadButtonPressed() { + return getButtonPressed(Button.RIGHT_TOUCHPAD); + } + + /** + * Whether the Right Touchpad button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightTouchpadButtonReleased() { + return getButtonReleased(Button.RIGHT_TOUCHPAD); + } + + /** + * Constructs an event instance around the Right Touchpad button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Touchpad button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightTouchpad(EventLoop loop) { + return button(Button.RIGHT_TOUCHPAD, loop); + } + + /** + * Read the value of the Left Stick Touch button on the controller. + * + * @return The state of the button. + */ + public boolean getLeftStickTouchButton() { + return getButton(Button.LEFT_STICK_TOUCH); + } + + /** + * Whether the Left Stick Touch button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLeftStickTouchButtonPressed() { + return getButtonPressed(Button.LEFT_STICK_TOUCH); + } + + /** + * Whether the Left Stick Touch button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLeftStickTouchButtonReleased() { + return getButtonReleased(Button.LEFT_STICK_TOUCH); + } + + /** + * Constructs an event instance around the Left Stick Touch button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Stick Touch button's digital signal + * attached to the given loop. + */ + public BooleanEvent leftStickTouch(EventLoop loop) { + return button(Button.LEFT_STICK_TOUCH, loop); + } + + /** + * Read the value of the Right Stick Touch button on the controller. + * + * @return The state of the button. + */ + public boolean getRightStickTouchButton() { + return getButton(Button.RIGHT_STICK_TOUCH); + } + + /** + * Whether the Right Stick Touch button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightStickTouchButtonPressed() { + return getButtonPressed(Button.RIGHT_STICK_TOUCH); + } + + /** + * Whether the Right Stick Touch button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightStickTouchButtonReleased() { + return getButtonReleased(Button.RIGHT_STICK_TOUCH); + } + + /** + * Constructs an event instance around the Right Stick Touch button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Stick Touch button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightStickTouch(EventLoop loop) { + return button(Button.RIGHT_STICK_TOUCH, loop); + } + + /** + * Read the value of the Left Grip Touch button on the controller. + * + * @return The state of the button. + */ + public boolean getLeftGripTouchButton() { + return getButton(Button.LEFT_GRIP_TOUCH); + } + + /** + * Whether the Left Grip Touch button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLeftGripTouchButtonPressed() { + return getButtonPressed(Button.LEFT_GRIP_TOUCH); + } + + /** + * Whether the Left Grip Touch button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLeftGripTouchButtonReleased() { + return getButtonReleased(Button.LEFT_GRIP_TOUCH); + } + + /** + * Constructs an event instance around the Left Grip Touch button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Grip Touch button's digital signal + * attached to the given loop. + */ + public BooleanEvent leftGripTouch(EventLoop loop) { + return button(Button.LEFT_GRIP_TOUCH, loop); + } + + /** + * Read the value of the Right Grip Touch button on the controller. + * + * @return The state of the button. + */ + public boolean getRightGripTouchButton() { + return getButton(Button.RIGHT_GRIP_TOUCH); + } + + /** + * Whether the Right Grip Touch button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightGripTouchButtonPressed() { + return getButtonPressed(Button.RIGHT_GRIP_TOUCH); + } + + /** + * Whether the Right Grip Touch button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightGripTouchButtonReleased() { + return getButtonReleased(Button.RIGHT_GRIP_TOUCH); + } + + /** + * Constructs an event instance around the Right Grip Touch button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Grip Touch button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightGripTouch(EventLoop loop) { + return button(Button.RIGHT_GRIP_TOUCH, loop); + } + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + public boolean getButton(Button button) { + return m_hid.getRawButton(button.value); + } + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + public boolean getButtonPressed(Button button) { + return m_hid.getRawButtonPressed(button.value); + } + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + public boolean getButtonReleased(Button button) { + return m_hid.getRawButtonReleased(button.value); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public BooleanEvent button(Button button, EventLoop loop) { + return m_hid.button(button.value, loop); + } + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + public void setLeds(int r, int g, int b) { + m_hid.setLeds(r, g, b); + } + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + public void setRumble(GenericHID.RumbleType type, double value) { + m_hid.setRumble(type, value); + } + + + /** + * Check if a touchpad finger is available. + * + * @param touchpad The touchpad to check. + * @param finger The finger to check. + * @return true if the touchpad finger is available. + */ + public boolean getTouchpadFingerAvailable(int touchpad, int finger) { + return m_hid.getTouchpadFingerAvailable(touchpad, finger); + } + + /** + * Get the touchpad finger data. + * + * @param touchpad The touchpad to read. + * @param finger The finger to read. + * @return The touchpad finger data. + */ + public TouchpadFinger getTouchpadFinger(int touchpad, int finger) { + return m_hid.getTouchpadFinger(touchpad, finger); + } + + + @Override + public void initSendable(SendableBuilder builder) { + builder.setSmartDashboardType("HID"); + builder.publishConstString("ControllerType", "Steam"); + builder.addDoubleProperty("LeftX", this::getLeftX, null); + builder.addDoubleProperty("LeftY", this::getLeftY, null); + builder.addDoubleProperty("RightX", this::getRightX, null); + builder.addDoubleProperty("RightY", this::getRightY, null); + builder.addDoubleProperty("LeftTrigger", this::getLeftTrigger, null); + builder.addDoubleProperty("RightTrigger", this::getRightTrigger, null); + builder.addBooleanProperty("A", this::getAButton, null); + builder.addBooleanProperty("B", this::getBButton, null); + builder.addBooleanProperty("X", this::getXButton, null); + builder.addBooleanProperty("Y", this::getYButton, null); + builder.addBooleanProperty("Menu", this::getMenuButton, null); + builder.addBooleanProperty("Steam", this::getSteamButton, null); + builder.addBooleanProperty("View", this::getViewButton, null); + builder.addBooleanProperty("LeftStick", this::getLeftStickButton, null); + builder.addBooleanProperty("RightStick", this::getRightStickButton, null); + builder.addBooleanProperty("LeftBumper", this::getLeftBumperButton, null); + builder.addBooleanProperty("RightBumper", this::getRightBumperButton, null); + builder.addBooleanProperty("DpadUp", this::getDpadUpButton, null); + builder.addBooleanProperty("DpadDown", this::getDpadDownButton, null); + builder.addBooleanProperty("DpadLeft", this::getDpadLeftButton, null); + builder.addBooleanProperty("DpadRight", this::getDpadRightButton, null); + builder.addBooleanProperty("QAM", this::getQAMButton, null); + builder.addBooleanProperty("RightPaddle1", this::getRightPaddle1Button, null); + builder.addBooleanProperty("LeftPaddle1", this::getLeftPaddle1Button, null); + builder.addBooleanProperty("RightPaddle2", this::getRightPaddle2Button, null); + builder.addBooleanProperty("LeftPaddle2", this::getLeftPaddle2Button, null); + builder.addBooleanProperty("LeftTouchpad", this::getLeftTouchpadButton, null); + builder.addBooleanProperty("RightTouchpad", this::getRightTouchpadButton, null); + builder.addBooleanProperty("LeftStickTouch", this::getLeftStickTouchButton, null); + builder.addBooleanProperty("RightStickTouch", this::getRightStickTouchButton, null); + builder.addBooleanProperty("LeftGripTouch", this::getLeftGripTouchButton, null); + builder.addBooleanProperty("RightGripTouch", this::getRightGripTouchButton, null); + } +} diff --git a/wpilibj/src/generated/main/java/org/wpilib/driverstation/Switch2GCController.java b/wpilibj/src/generated/main/java/org/wpilib/driverstation/Switch2GCController.java new file mode 100644 index 0000000000..e374322bd4 --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/driverstation/Switch2GCController.java @@ -0,0 +1,971 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import java.util.EnumSet; +import java.util.Objects; +import org.wpilib.event.BooleanEvent; +import org.wpilib.event.EventLoop; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.util.sendable.Sendable; +import org.wpilib.util.sendable.SendableBuilder; + +/** + * Handle input from Switch2GC controllers connected to the Driver Station. + * + *

This class handles Switch2GC input that comes from the Driver Station. Each time a value + * is requested the most recent value is returned. + */ +public class Switch2GCController implements HIDDevice, Sendable { + /** The number of touchpads supported by this controller. */ + public static final int TOUCHPAD_COUNT = 0; + + /** Whether this controller supports main rumble motors. */ + public static final boolean SUPPORTS_RUMBLE = true; + + /** Whether this controller supports trigger rumble motors. */ + public static final boolean SUPPORTS_TRIGGER_RUMBLE = false; + + /** Whether this controller supports mono LED output. */ + public static final boolean SUPPORTS_MONO_LED = false; + + /** Whether this controller supports RGB LED output. */ + public static final boolean SUPPORTS_RGB_LED = false; + + /** Represents a digital button on a Switch2GCController. */ + public enum Button { + /** A button. */ + A(0, "AButton"), + /** X button. */ + X(1, "XButton"), + /** B button. */ + B(2, "BButton"), + /** Y button. */ + Y(3, "YButton"), + /** Home button. */ + HOME(5, "HomeButton"), + /** Start button. */ + START(6, "StartButton"), + /** ZL button. */ + ZL(9, "ZLButton"), + /** Z button. */ + Z(10, "ZButton"), + /** Dpad Up button. */ + DPAD_UP(11, "DpadUpButton"), + /** Dpad Down button. */ + DPAD_DOWN(12, "DpadDownButton"), + /** Dpad Left button. */ + DPAD_LEFT(13, "DpadLeftButton"), + /** Dpad Right button. */ + DPAD_RIGHT(14, "DpadRightButton"), + /** Capture button. */ + CAPTURE(15, "CaptureButton"), + /** C button. */ + C(21, "CButton"), + /** L button. */ + L(22, "LButton"), + /** R button. */ + R(23, "RButton"); + + /** Button value. */ + public final int value; + + private final String m_name; + + Button(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + /** Represents an axis on a Switch2GCController. */ + public enum Axis { + /** Left X. */ + LEFT_X(0, "LeftX"), + /** Left Y. */ + LEFT_Y(1, "LeftY"), + /** C Stick X. */ + C_STICK_X(2, "CStickX"), + /** C Stick Y. */ + C_STICK_Y(3, "CStickY"), + /** L Trigger. */ + L_TRIGGER(4, "LTrigger"), + /** R Trigger. */ + R_TRIGGER(5, "RTrigger"); + + /** Axis value. */ + public final int value; + + private final String m_name; + + Axis(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + private final GenericHID m_hid; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public Switch2GCController(final int port) { + this(DriverStation.getGenericHID(port)); + } + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + public Switch2GCController(final GenericHID hid) { + m_hid = Objects.requireNonNull(hid, "Provided HID object cannot be null"); + HAL.reportUsage("HID", hid.getPort(), "Switch2GCController"); + } + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + @Override + public GenericHID getHID() { + return m_hid; + } + + /** + * Get the supported outputs expected for this controller type. + * + * @return the expected supported outputs + */ + public static EnumSet getSupportedOutputCapabilities() { + return EnumSet.of( + GenericHID.SupportedOutput.RUMBLE + ); + } + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + public int getPort() { + return m_hid.getPort(); + } + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + public boolean isConnected() { + return m_hid.isConnected(); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return getAxis(Axis.LEFT_X); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return getAxis(Axis.LEFT_Y); + } + + /** + * Get the C Stick X value of the controller. + * + * @return The axis value. + */ + public double getCStickX() { + return getAxis(Axis.C_STICK_X); + } + + /** + * Get the C Stick Y value of the controller. + * + * @return The axis value. + */ + public double getCStickY() { + return getAxis(Axis.C_STICK_Y); + } + + /** + * Get the L Trigger value of the controller. + * + * @return The axis value. + */ + public double getLTrigger() { + return getAxis(Axis.L_TRIGGER); + } + + /** + * Get the R Trigger value of the controller. + * + * @return The axis value. + */ + public double getRTrigger() { + return getAxis(Axis.R_TRIGGER); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The axis value. + */ + public double getAxis(Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + /** + * Constructs an event instance that is true when the axis value is less than {@code threshold}. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the provided + * threshold. + */ + public BooleanEvent axisLessThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs an event instance that is true when the axis value is greater than {@code + * threshold}. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than the provided + * threshold. + */ + public BooleanEvent axisGreaterThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Read the value of the A button on the controller. + * + * @return The state of the button. + */ + public boolean getAButton() { + return getButton(Button.A); + } + + /** + * Whether the A button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getAButtonPressed() { + return getButtonPressed(Button.A); + } + + /** + * Whether the A button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getAButtonReleased() { + return getButtonReleased(Button.A); + } + + /** + * Constructs an event instance around the A button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the A button's digital signal + * attached to the given loop. + */ + public BooleanEvent a(EventLoop loop) { + return button(Button.A, loop); + } + + /** + * Read the value of the X button on the controller. + * + * @return The state of the button. + */ + public boolean getXButton() { + return getButton(Button.X); + } + + /** + * Whether the X button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getXButtonPressed() { + return getButtonPressed(Button.X); + } + + /** + * Whether the X button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getXButtonReleased() { + return getButtonReleased(Button.X); + } + + /** + * Constructs an event instance around the X button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the X button's digital signal + * attached to the given loop. + */ + public BooleanEvent x(EventLoop loop) { + return button(Button.X, loop); + } + + /** + * Read the value of the B button on the controller. + * + * @return The state of the button. + */ + public boolean getBButton() { + return getButton(Button.B); + } + + /** + * Whether the B button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getBButtonPressed() { + return getButtonPressed(Button.B); + } + + /** + * Whether the B button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getBButtonReleased() { + return getButtonReleased(Button.B); + } + + /** + * Constructs an event instance around the B button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the B button's digital signal + * attached to the given loop. + */ + public BooleanEvent b(EventLoop loop) { + return button(Button.B, loop); + } + + /** + * Read the value of the Y button on the controller. + * + * @return The state of the button. + */ + public boolean getYButton() { + return getButton(Button.Y); + } + + /** + * Whether the Y button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getYButtonPressed() { + return getButtonPressed(Button.Y); + } + + /** + * Whether the Y button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getYButtonReleased() { + return getButtonReleased(Button.Y); + } + + /** + * Constructs an event instance around the Y button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Y button's digital signal + * attached to the given loop. + */ + public BooleanEvent y(EventLoop loop) { + return button(Button.Y, loop); + } + + /** + * Read the value of the Home button on the controller. + * + * @return The state of the button. + */ + public boolean getHomeButton() { + return getButton(Button.HOME); + } + + /** + * Whether the Home button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getHomeButtonPressed() { + return getButtonPressed(Button.HOME); + } + + /** + * Whether the Home button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getHomeButtonReleased() { + return getButtonReleased(Button.HOME); + } + + /** + * Constructs an event instance around the Home button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Home button's digital signal + * attached to the given loop. + */ + public BooleanEvent home(EventLoop loop) { + return button(Button.HOME, loop); + } + + /** + * Read the value of the Start button on the controller. + * + * @return The state of the button. + */ + public boolean getStartButton() { + return getButton(Button.START); + } + + /** + * Whether the Start button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getStartButtonPressed() { + return getButtonPressed(Button.START); + } + + /** + * Whether the Start button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getStartButtonReleased() { + return getButtonReleased(Button.START); + } + + /** + * Constructs an event instance around the Start button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Start button's digital signal + * attached to the given loop. + */ + public BooleanEvent start(EventLoop loop) { + return button(Button.START, loop); + } + + /** + * Read the value of the ZL button on the controller. + * + * @return The state of the button. + */ + public boolean getZLButton() { + return getButton(Button.ZL); + } + + /** + * Whether the ZL button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getZLButtonPressed() { + return getButtonPressed(Button.ZL); + } + + /** + * Whether the ZL button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getZLButtonReleased() { + return getButtonReleased(Button.ZL); + } + + /** + * Constructs an event instance around the ZL button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the ZL button's digital signal + * attached to the given loop. + */ + public BooleanEvent ZL(EventLoop loop) { + return button(Button.ZL, loop); + } + + /** + * Read the value of the Z button on the controller. + * + * @return The state of the button. + */ + public boolean getZButton() { + return getButton(Button.Z); + } + + /** + * Whether the Z button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getZButtonPressed() { + return getButtonPressed(Button.Z); + } + + /** + * Whether the Z button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getZButtonReleased() { + return getButtonReleased(Button.Z); + } + + /** + * Constructs an event instance around the Z button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Z button's digital signal + * attached to the given loop. + */ + public BooleanEvent Z(EventLoop loop) { + return button(Button.Z, loop); + } + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadUpButton() { + return getButton(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadUpButtonPressed() { + return getButtonPressed(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadUpButtonReleased() { + return getButtonReleased(Button.DPAD_UP); + } + + /** + * Constructs an event instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadUp(EventLoop loop) { + return button(Button.DPAD_UP, loop); + } + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadDownButton() { + return getButton(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadDownButtonPressed() { + return getButtonPressed(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadDownButtonReleased() { + return getButtonReleased(Button.DPAD_DOWN); + } + + /** + * Constructs an event instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadDown(EventLoop loop) { + return button(Button.DPAD_DOWN, loop); + } + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadLeftButton() { + return getButton(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadLeftButtonPressed() { + return getButtonPressed(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadLeftButtonReleased() { + return getButtonReleased(Button.DPAD_LEFT); + } + + /** + * Constructs an event instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadLeft(EventLoop loop) { + return button(Button.DPAD_LEFT, loop); + } + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadRightButton() { + return getButton(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadRightButtonPressed() { + return getButtonPressed(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadRightButtonReleased() { + return getButtonReleased(Button.DPAD_RIGHT); + } + + /** + * Constructs an event instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadRight(EventLoop loop) { + return button(Button.DPAD_RIGHT, loop); + } + + /** + * Read the value of the Capture button on the controller. + * + * @return The state of the button. + */ + public boolean getCaptureButton() { + return getButton(Button.CAPTURE); + } + + /** + * Whether the Capture button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getCaptureButtonPressed() { + return getButtonPressed(Button.CAPTURE); + } + + /** + * Whether the Capture button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getCaptureButtonReleased() { + return getButtonReleased(Button.CAPTURE); + } + + /** + * Constructs an event instance around the Capture button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Capture button's digital signal + * attached to the given loop. + */ + public BooleanEvent capture(EventLoop loop) { + return button(Button.CAPTURE, loop); + } + + /** + * Read the value of the C button on the controller. + * + * @return The state of the button. + */ + public boolean getCButton() { + return getButton(Button.C); + } + + /** + * Whether the C button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getCButtonPressed() { + return getButtonPressed(Button.C); + } + + /** + * Whether the C button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getCButtonReleased() { + return getButtonReleased(Button.C); + } + + /** + * Constructs an event instance around the C button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the C button's digital signal + * attached to the given loop. + */ + public BooleanEvent C(EventLoop loop) { + return button(Button.C, loop); + } + + /** + * Read the value of the L button on the controller. + * + * @return The state of the button. + */ + public boolean getLButton() { + return getButton(Button.L); + } + + /** + * Whether the L button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLButtonPressed() { + return getButtonPressed(Button.L); + } + + /** + * Whether the L button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLButtonReleased() { + return getButtonReleased(Button.L); + } + + /** + * Constructs an event instance around the L button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L button's digital signal + * attached to the given loop. + */ + public BooleanEvent L(EventLoop loop) { + return button(Button.L, loop); + } + + /** + * Read the value of the R button on the controller. + * + * @return The state of the button. + */ + public boolean getRButton() { + return getButton(Button.R); + } + + /** + * Whether the R button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRButtonPressed() { + return getButtonPressed(Button.R); + } + + /** + * Whether the R button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRButtonReleased() { + return getButtonReleased(Button.R); + } + + /** + * Constructs an event instance around the R button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R button's digital signal + * attached to the given loop. + */ + public BooleanEvent R(EventLoop loop) { + return button(Button.R, loop); + } + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + public boolean getButton(Button button) { + return m_hid.getRawButton(button.value); + } + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + public boolean getButtonPressed(Button button) { + return m_hid.getRawButtonPressed(button.value); + } + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + public boolean getButtonReleased(Button button) { + return m_hid.getRawButtonReleased(button.value); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public BooleanEvent button(Button button, EventLoop loop) { + return m_hid.button(button.value, loop); + } + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + public void setLeds(int r, int g, int b) { + m_hid.setLeds(r, g, b); + } + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + public void setRumble(GenericHID.RumbleType type, double value) { + m_hid.setRumble(type, value); + } + + + + @Override + public void initSendable(SendableBuilder builder) { + builder.setSmartDashboardType("HID"); + builder.publishConstString("ControllerType", "Switch2GC"); + builder.addDoubleProperty("LeftX", this::getLeftX, null); + builder.addDoubleProperty("LeftY", this::getLeftY, null); + builder.addDoubleProperty("CStickX", this::getCStickX, null); + builder.addDoubleProperty("CStickY", this::getCStickY, null); + builder.addDoubleProperty("LTrigger", this::getLTrigger, null); + builder.addDoubleProperty("RTrigger", this::getRTrigger, null); + builder.addBooleanProperty("A", this::getAButton, null); + builder.addBooleanProperty("X", this::getXButton, null); + builder.addBooleanProperty("B", this::getBButton, null); + builder.addBooleanProperty("Y", this::getYButton, null); + builder.addBooleanProperty("Home", this::getHomeButton, null); + builder.addBooleanProperty("Start", this::getStartButton, null); + builder.addBooleanProperty("ZL", this::getZLButton, null); + builder.addBooleanProperty("Z", this::getZButton, null); + builder.addBooleanProperty("DpadUp", this::getDpadUpButton, null); + builder.addBooleanProperty("DpadDown", this::getDpadDownButton, null); + builder.addBooleanProperty("DpadLeft", this::getDpadLeftButton, null); + builder.addBooleanProperty("DpadRight", this::getDpadRightButton, null); + builder.addBooleanProperty("Capture", this::getCaptureButton, null); + builder.addBooleanProperty("C", this::getCButton, null); + builder.addBooleanProperty("L", this::getLButton, null); + builder.addBooleanProperty("R", this::getRButton, null); + } +} diff --git a/wpilibj/src/generated/main/java/org/wpilib/driverstation/Switch2ProController.java b/wpilibj/src/generated/main/java/org/wpilib/driverstation/Switch2ProController.java new file mode 100644 index 0000000000..494f2d539a --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/driverstation/Switch2ProController.java @@ -0,0 +1,1094 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import java.util.EnumSet; +import java.util.Objects; +import org.wpilib.event.BooleanEvent; +import org.wpilib.event.EventLoop; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.util.sendable.Sendable; +import org.wpilib.util.sendable.SendableBuilder; + +/** + * Handle input from Switch2Pro controllers connected to the Driver Station. + * + *

This class handles Switch2Pro input that comes from the Driver Station. Each time a value + * is requested the most recent value is returned. + */ +public class Switch2ProController implements HIDDevice, Sendable { + /** The number of touchpads supported by this controller. */ + public static final int TOUCHPAD_COUNT = 0; + + /** Whether this controller supports main rumble motors. */ + public static final boolean SUPPORTS_RUMBLE = true; + + /** Whether this controller supports trigger rumble motors. */ + public static final boolean SUPPORTS_TRIGGER_RUMBLE = false; + + /** Whether this controller supports mono LED output. */ + public static final boolean SUPPORTS_MONO_LED = false; + + /** Whether this controller supports RGB LED output. */ + public static final boolean SUPPORTS_RGB_LED = false; + + /** Represents a digital button on a Switch2ProController. */ + public enum Button { + /** B button. */ + B(0, "BButton"), + /** A button. */ + A(1, "AButton"), + /** Y button. */ + Y(2, "YButton"), + /** X button. */ + X(3, "XButton"), + /** Minus button. */ + MINUS(4, "MinusButton"), + /** Home button. */ + HOME(5, "HomeButton"), + /** Plus button. */ + PLUS(6, "PlusButton"), + /** Left Stick button. */ + LEFT_STICK(7, "LeftStickButton"), + /** Right Stick button. */ + RIGHT_STICK(8, "RightStickButton"), + /** L button. */ + L(9, "LButton"), + /** R button. */ + R(10, "RButton"), + /** Dpad Up button. */ + DPAD_UP(11, "DpadUpButton"), + /** Dpad Down button. */ + DPAD_DOWN(12, "DpadDownButton"), + /** Dpad Left button. */ + DPAD_LEFT(13, "DpadLeftButton"), + /** Dpad Right button. */ + DPAD_RIGHT(14, "DpadRightButton"), + /** Capture button. */ + CAPTURE(15, "CaptureButton"), + /** GR button. */ + GR(16, "GRButton"), + /** GL button. */ + GL(17, "GLButton"), + /** C button. */ + C(21, "CButton"); + + /** Button value. */ + public final int value; + + private final String m_name; + + Button(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + /** Represents an axis on a Switch2ProController. */ + public enum Axis { + /** Left X. */ + LEFT_X(0, "LeftX"), + /** Left Y. */ + LEFT_Y(1, "LeftY"), + /** Right X. */ + RIGHT_X(2, "RightX"), + /** Right Y. */ + RIGHT_Y(3, "RightY"), + /** ZL. */ + ZL(4, "ZL"), + /** ZR. */ + ZR(5, "ZR"); + + /** Axis value. */ + public final int value; + + private final String m_name; + + Axis(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + private final GenericHID m_hid; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public Switch2ProController(final int port) { + this(DriverStation.getGenericHID(port)); + } + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + public Switch2ProController(final GenericHID hid) { + m_hid = Objects.requireNonNull(hid, "Provided HID object cannot be null"); + HAL.reportUsage("HID", hid.getPort(), "Switch2ProController"); + } + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + @Override + public GenericHID getHID() { + return m_hid; + } + + /** + * Get the supported outputs expected for this controller type. + * + * @return the expected supported outputs + */ + public static EnumSet getSupportedOutputCapabilities() { + return EnumSet.of( + GenericHID.SupportedOutput.RUMBLE + ); + } + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + public int getPort() { + return m_hid.getPort(); + } + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + public boolean isConnected() { + return m_hid.isConnected(); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return getAxis(Axis.LEFT_X); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return getAxis(Axis.LEFT_Y); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return getAxis(Axis.RIGHT_X); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return getAxis(Axis.RIGHT_Y); + } + + /** + * Get the ZL value of the controller. + * + * @return The axis value. + */ + public double getZL() { + return getAxis(Axis.ZL); + } + + /** + * Get the ZR value of the controller. + * + * @return The axis value. + */ + public double getZR() { + return getAxis(Axis.ZR); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The axis value. + */ + public double getAxis(Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + /** + * Constructs an event instance that is true when the axis value is less than {@code threshold}. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the provided + * threshold. + */ + public BooleanEvent axisLessThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs an event instance that is true when the axis value is greater than {@code + * threshold}. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than the provided + * threshold. + */ + public BooleanEvent axisGreaterThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Read the value of the B button on the controller. + * + * @return The state of the button. + */ + public boolean getBButton() { + return getButton(Button.B); + } + + /** + * Whether the B button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getBButtonPressed() { + return getButtonPressed(Button.B); + } + + /** + * Whether the B button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getBButtonReleased() { + return getButtonReleased(Button.B); + } + + /** + * Constructs an event instance around the B button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the B button's digital signal + * attached to the given loop. + */ + public BooleanEvent b(EventLoop loop) { + return button(Button.B, loop); + } + + /** + * Read the value of the A button on the controller. + * + * @return The state of the button. + */ + public boolean getAButton() { + return getButton(Button.A); + } + + /** + * Whether the A button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getAButtonPressed() { + return getButtonPressed(Button.A); + } + + /** + * Whether the A button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getAButtonReleased() { + return getButtonReleased(Button.A); + } + + /** + * Constructs an event instance around the A button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the A button's digital signal + * attached to the given loop. + */ + public BooleanEvent a(EventLoop loop) { + return button(Button.A, loop); + } + + /** + * Read the value of the Y button on the controller. + * + * @return The state of the button. + */ + public boolean getYButton() { + return getButton(Button.Y); + } + + /** + * Whether the Y button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getYButtonPressed() { + return getButtonPressed(Button.Y); + } + + /** + * Whether the Y button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getYButtonReleased() { + return getButtonReleased(Button.Y); + } + + /** + * Constructs an event instance around the Y button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Y button's digital signal + * attached to the given loop. + */ + public BooleanEvent y(EventLoop loop) { + return button(Button.Y, loop); + } + + /** + * Read the value of the X button on the controller. + * + * @return The state of the button. + */ + public boolean getXButton() { + return getButton(Button.X); + } + + /** + * Whether the X button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getXButtonPressed() { + return getButtonPressed(Button.X); + } + + /** + * Whether the X button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getXButtonReleased() { + return getButtonReleased(Button.X); + } + + /** + * Constructs an event instance around the X button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the X button's digital signal + * attached to the given loop. + */ + public BooleanEvent x(EventLoop loop) { + return button(Button.X, loop); + } + + /** + * Read the value of the Minus button on the controller. + * + * @return The state of the button. + */ + public boolean getMinusButton() { + return getButton(Button.MINUS); + } + + /** + * Whether the Minus button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getMinusButtonPressed() { + return getButtonPressed(Button.MINUS); + } + + /** + * Whether the Minus button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getMinusButtonReleased() { + return getButtonReleased(Button.MINUS); + } + + /** + * Constructs an event instance around the Minus button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Minus button's digital signal + * attached to the given loop. + */ + public BooleanEvent minus(EventLoop loop) { + return button(Button.MINUS, loop); + } + + /** + * Read the value of the Home button on the controller. + * + * @return The state of the button. + */ + public boolean getHomeButton() { + return getButton(Button.HOME); + } + + /** + * Whether the Home button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getHomeButtonPressed() { + return getButtonPressed(Button.HOME); + } + + /** + * Whether the Home button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getHomeButtonReleased() { + return getButtonReleased(Button.HOME); + } + + /** + * Constructs an event instance around the Home button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Home button's digital signal + * attached to the given loop. + */ + public BooleanEvent home(EventLoop loop) { + return button(Button.HOME, loop); + } + + /** + * Read the value of the Plus button on the controller. + * + * @return The state of the button. + */ + public boolean getPlusButton() { + return getButton(Button.PLUS); + } + + /** + * Whether the Plus button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getPlusButtonPressed() { + return getButtonPressed(Button.PLUS); + } + + /** + * Whether the Plus button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getPlusButtonReleased() { + return getButtonReleased(Button.PLUS); + } + + /** + * Constructs an event instance around the Plus button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Plus button's digital signal + * attached to the given loop. + */ + public BooleanEvent plus(EventLoop loop) { + return button(Button.PLUS, loop); + } + + /** + * Read the value of the Left Stick button on the controller. + * + * @return The state of the button. + */ + public boolean getLeftStickButton() { + return getButton(Button.LEFT_STICK); + } + + /** + * Whether the Left Stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLeftStickButtonPressed() { + return getButtonPressed(Button.LEFT_STICK); + } + + /** + * Whether the Left Stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLeftStickButtonReleased() { + return getButtonReleased(Button.LEFT_STICK); + } + + /** + * Constructs an event instance around the Left Stick button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Stick button's digital signal + * attached to the given loop. + */ + public BooleanEvent leftStick(EventLoop loop) { + return button(Button.LEFT_STICK, loop); + } + + /** + * Read the value of the Right Stick button on the controller. + * + * @return The state of the button. + */ + public boolean getRightStickButton() { + return getButton(Button.RIGHT_STICK); + } + + /** + * Whether the Right Stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightStickButtonPressed() { + return getButtonPressed(Button.RIGHT_STICK); + } + + /** + * Whether the Right Stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightStickButtonReleased() { + return getButtonReleased(Button.RIGHT_STICK); + } + + /** + * Constructs an event instance around the Right Stick button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Stick button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightStick(EventLoop loop) { + return button(Button.RIGHT_STICK, loop); + } + + /** + * Read the value of the L button on the controller. + * + * @return The state of the button. + */ + public boolean getLButton() { + return getButton(Button.L); + } + + /** + * Whether the L button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLButtonPressed() { + return getButtonPressed(Button.L); + } + + /** + * Whether the L button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLButtonReleased() { + return getButtonReleased(Button.L); + } + + /** + * Constructs an event instance around the L button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L button's digital signal + * attached to the given loop. + */ + public BooleanEvent L(EventLoop loop) { + return button(Button.L, loop); + } + + /** + * Read the value of the R button on the controller. + * + * @return The state of the button. + */ + public boolean getRButton() { + return getButton(Button.R); + } + + /** + * Whether the R button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRButtonPressed() { + return getButtonPressed(Button.R); + } + + /** + * Whether the R button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRButtonReleased() { + return getButtonReleased(Button.R); + } + + /** + * Constructs an event instance around the R button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R button's digital signal + * attached to the given loop. + */ + public BooleanEvent R(EventLoop loop) { + return button(Button.R, loop); + } + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadUpButton() { + return getButton(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadUpButtonPressed() { + return getButtonPressed(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadUpButtonReleased() { + return getButtonReleased(Button.DPAD_UP); + } + + /** + * Constructs an event instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadUp(EventLoop loop) { + return button(Button.DPAD_UP, loop); + } + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadDownButton() { + return getButton(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadDownButtonPressed() { + return getButtonPressed(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadDownButtonReleased() { + return getButtonReleased(Button.DPAD_DOWN); + } + + /** + * Constructs an event instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadDown(EventLoop loop) { + return button(Button.DPAD_DOWN, loop); + } + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadLeftButton() { + return getButton(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadLeftButtonPressed() { + return getButtonPressed(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadLeftButtonReleased() { + return getButtonReleased(Button.DPAD_LEFT); + } + + /** + * Constructs an event instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadLeft(EventLoop loop) { + return button(Button.DPAD_LEFT, loop); + } + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadRightButton() { + return getButton(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadRightButtonPressed() { + return getButtonPressed(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadRightButtonReleased() { + return getButtonReleased(Button.DPAD_RIGHT); + } + + /** + * Constructs an event instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadRight(EventLoop loop) { + return button(Button.DPAD_RIGHT, loop); + } + + /** + * Read the value of the Capture button on the controller. + * + * @return The state of the button. + */ + public boolean getCaptureButton() { + return getButton(Button.CAPTURE); + } + + /** + * Whether the Capture button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getCaptureButtonPressed() { + return getButtonPressed(Button.CAPTURE); + } + + /** + * Whether the Capture button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getCaptureButtonReleased() { + return getButtonReleased(Button.CAPTURE); + } + + /** + * Constructs an event instance around the Capture button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Capture button's digital signal + * attached to the given loop. + */ + public BooleanEvent capture(EventLoop loop) { + return button(Button.CAPTURE, loop); + } + + /** + * Read the value of the GR button on the controller. + * + * @return The state of the button. + */ + public boolean getGRButton() { + return getButton(Button.GR); + } + + /** + * Whether the GR button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getGRButtonPressed() { + return getButtonPressed(Button.GR); + } + + /** + * Whether the GR button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getGRButtonReleased() { + return getButtonReleased(Button.GR); + } + + /** + * Constructs an event instance around the GR button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the GR button's digital signal + * attached to the given loop. + */ + public BooleanEvent GR(EventLoop loop) { + return button(Button.GR, loop); + } + + /** + * Read the value of the GL button on the controller. + * + * @return The state of the button. + */ + public boolean getGLButton() { + return getButton(Button.GL); + } + + /** + * Whether the GL button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getGLButtonPressed() { + return getButtonPressed(Button.GL); + } + + /** + * Whether the GL button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getGLButtonReleased() { + return getButtonReleased(Button.GL); + } + + /** + * Constructs an event instance around the GL button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the GL button's digital signal + * attached to the given loop. + */ + public BooleanEvent GL(EventLoop loop) { + return button(Button.GL, loop); + } + + /** + * Read the value of the C button on the controller. + * + * @return The state of the button. + */ + public boolean getCButton() { + return getButton(Button.C); + } + + /** + * Whether the C button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getCButtonPressed() { + return getButtonPressed(Button.C); + } + + /** + * Whether the C button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getCButtonReleased() { + return getButtonReleased(Button.C); + } + + /** + * Constructs an event instance around the C button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the C button's digital signal + * attached to the given loop. + */ + public BooleanEvent C(EventLoop loop) { + return button(Button.C, loop); + } + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + public boolean getButton(Button button) { + return m_hid.getRawButton(button.value); + } + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + public boolean getButtonPressed(Button button) { + return m_hid.getRawButtonPressed(button.value); + } + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + public boolean getButtonReleased(Button button) { + return m_hid.getRawButtonReleased(button.value); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public BooleanEvent button(Button button, EventLoop loop) { + return m_hid.button(button.value, loop); + } + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + public void setLeds(int r, int g, int b) { + m_hid.setLeds(r, g, b); + } + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + public void setRumble(GenericHID.RumbleType type, double value) { + m_hid.setRumble(type, value); + } + + + + @Override + public void initSendable(SendableBuilder builder) { + builder.setSmartDashboardType("HID"); + builder.publishConstString("ControllerType", "Switch2Pro"); + builder.addDoubleProperty("LeftX", this::getLeftX, null); + builder.addDoubleProperty("LeftY", this::getLeftY, null); + builder.addDoubleProperty("RightX", this::getRightX, null); + builder.addDoubleProperty("RightY", this::getRightY, null); + builder.addDoubleProperty("ZL", this::getZL, null); + builder.addDoubleProperty("ZR", this::getZR, null); + builder.addBooleanProperty("B", this::getBButton, null); + builder.addBooleanProperty("A", this::getAButton, null); + builder.addBooleanProperty("Y", this::getYButton, null); + builder.addBooleanProperty("X", this::getXButton, null); + builder.addBooleanProperty("Minus", this::getMinusButton, null); + builder.addBooleanProperty("Home", this::getHomeButton, null); + builder.addBooleanProperty("Plus", this::getPlusButton, null); + builder.addBooleanProperty("LeftStick", this::getLeftStickButton, null); + builder.addBooleanProperty("RightStick", this::getRightStickButton, null); + builder.addBooleanProperty("L", this::getLButton, null); + builder.addBooleanProperty("R", this::getRButton, null); + builder.addBooleanProperty("DpadUp", this::getDpadUpButton, null); + builder.addBooleanProperty("DpadDown", this::getDpadDownButton, null); + builder.addBooleanProperty("DpadLeft", this::getDpadLeftButton, null); + builder.addBooleanProperty("DpadRight", this::getDpadRightButton, null); + builder.addBooleanProperty("Capture", this::getCaptureButton, null); + builder.addBooleanProperty("GR", this::getGRButton, null); + builder.addBooleanProperty("GL", this::getGLButton, null); + builder.addBooleanProperty("C", this::getCButton, null); + } +} diff --git a/wpilibj/src/generated/main/java/org/wpilib/driverstation/SwitchN64Controller.java b/wpilibj/src/generated/main/java/org/wpilib/driverstation/SwitchN64Controller.java new file mode 100644 index 0000000000..3e8d2ff324 --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/driverstation/SwitchN64Controller.java @@ -0,0 +1,904 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import java.util.EnumSet; +import java.util.Objects; +import org.wpilib.event.BooleanEvent; +import org.wpilib.event.EventLoop; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.util.sendable.Sendable; +import org.wpilib.util.sendable.SendableBuilder; + +/** + * Handle input from SwitchN64 controllers connected to the Driver Station. + * + *

This class handles SwitchN64 input that comes from the Driver Station. Each time a value + * is requested the most recent value is returned. + */ +public class SwitchN64Controller implements HIDDevice, Sendable { + /** The number of touchpads supported by this controller. */ + public static final int TOUCHPAD_COUNT = 0; + + /** Whether this controller supports main rumble motors. */ + public static final boolean SUPPORTS_RUMBLE = false; + + /** Whether this controller supports trigger rumble motors. */ + public static final boolean SUPPORTS_TRIGGER_RUMBLE = false; + + /** Whether this controller supports mono LED output. */ + public static final boolean SUPPORTS_MONO_LED = false; + + /** Whether this controller supports RGB LED output. */ + public static final boolean SUPPORTS_RGB_LED = false; + + /** Represents a digital button on a SwitchN64Controller. */ + public enum Button { + /** A button. */ + A(0, "AButton"), + /** B button. */ + B(1, "BButton"), + /** C Left button. */ + C_LEFT(3, "CLeftButton"), + /** C Up button. */ + C_UP(4, "CUpButton"), + /** Capture button. */ + CAPTURE(15, "CaptureButton"), + /** Home button. */ + HOME(5, "HomeButton"), + /** Start button. */ + START(6, "StartButton"), + /** C Down button. */ + C_DOWN(2, "CDownButton"), + /** L button. */ + L(9, "LButton"), + /** R button. */ + R(10, "RButton"), + /** Dpad Up button. */ + DPAD_UP(11, "DpadUpButton"), + /** Dpad Down button. */ + DPAD_DOWN(12, "DpadDownButton"), + /** Dpad Left button. */ + DPAD_LEFT(13, "DpadLeftButton"), + /** Dpad Right button. */ + DPAD_RIGHT(14, "DpadRightButton"), + /** C Right button. */ + C_RIGHT(21, "CRightButton"); + + /** Button value. */ + public final int value; + + private final String m_name; + + Button(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + /** Represents an axis on a SwitchN64Controller. */ + public enum Axis { + /** Left X. */ + LEFT_X(0, "LeftX"), + /** Left Y. */ + LEFT_Y(1, "LeftY"), + /** Z Axis. */ + Z_AXIS(4, "ZAxis"), + /** ZR. */ + ZR(5, "ZR"); + + /** Axis value. */ + public final int value; + + private final String m_name; + + Axis(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + private final GenericHID m_hid; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public SwitchN64Controller(final int port) { + this(DriverStation.getGenericHID(port)); + } + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + public SwitchN64Controller(final GenericHID hid) { + m_hid = Objects.requireNonNull(hid, "Provided HID object cannot be null"); + HAL.reportUsage("HID", hid.getPort(), "SwitchN64Controller"); + } + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + @Override + public GenericHID getHID() { + return m_hid; + } + + /** + * Get the supported outputs expected for this controller type. + * + * @return the expected supported outputs + */ + public static EnumSet getSupportedOutputCapabilities() { + return EnumSet.noneOf(GenericHID.SupportedOutput.class); + } + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + public int getPort() { + return m_hid.getPort(); + } + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + public boolean isConnected() { + return m_hid.isConnected(); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return getAxis(Axis.LEFT_X); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return getAxis(Axis.LEFT_Y); + } + + /** + * Get the Z Axis value of the controller. + * + * @return The axis value. + */ + public double getZAxis() { + return getAxis(Axis.Z_AXIS); + } + + /** + * Get the ZR value of the controller. + * + * @return The axis value. + */ + public double getZR() { + return getAxis(Axis.ZR); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The axis value. + */ + public double getAxis(Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + /** + * Constructs an event instance that is true when the axis value is less than {@code threshold}. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the provided + * threshold. + */ + public BooleanEvent axisLessThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs an event instance that is true when the axis value is greater than {@code + * threshold}. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than the provided + * threshold. + */ + public BooleanEvent axisGreaterThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Read the value of the A button on the controller. + * + * @return The state of the button. + */ + public boolean getAButton() { + return getButton(Button.A); + } + + /** + * Whether the A button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getAButtonPressed() { + return getButtonPressed(Button.A); + } + + /** + * Whether the A button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getAButtonReleased() { + return getButtonReleased(Button.A); + } + + /** + * Constructs an event instance around the A button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the A button's digital signal + * attached to the given loop. + */ + public BooleanEvent a(EventLoop loop) { + return button(Button.A, loop); + } + + /** + * Read the value of the B button on the controller. + * + * @return The state of the button. + */ + public boolean getBButton() { + return getButton(Button.B); + } + + /** + * Whether the B button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getBButtonPressed() { + return getButtonPressed(Button.B); + } + + /** + * Whether the B button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getBButtonReleased() { + return getButtonReleased(Button.B); + } + + /** + * Constructs an event instance around the B button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the B button's digital signal + * attached to the given loop. + */ + public BooleanEvent b(EventLoop loop) { + return button(Button.B, loop); + } + + /** + * Read the value of the C Left button on the controller. + * + * @return The state of the button. + */ + public boolean getCLeftButton() { + return getButton(Button.C_LEFT); + } + + /** + * Whether the C Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getCLeftButtonPressed() { + return getButtonPressed(Button.C_LEFT); + } + + /** + * Whether the C Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getCLeftButtonReleased() { + return getButtonReleased(Button.C_LEFT); + } + + /** + * Constructs an event instance around the C Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the C Left button's digital signal + * attached to the given loop. + */ + public BooleanEvent CLeft(EventLoop loop) { + return button(Button.C_LEFT, loop); + } + + /** + * Read the value of the C Up button on the controller. + * + * @return The state of the button. + */ + public boolean getCUpButton() { + return getButton(Button.C_UP); + } + + /** + * Whether the C Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getCUpButtonPressed() { + return getButtonPressed(Button.C_UP); + } + + /** + * Whether the C Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getCUpButtonReleased() { + return getButtonReleased(Button.C_UP); + } + + /** + * Constructs an event instance around the C Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the C Up button's digital signal + * attached to the given loop. + */ + public BooleanEvent CUp(EventLoop loop) { + return button(Button.C_UP, loop); + } + + /** + * Read the value of the Capture button on the controller. + * + * @return The state of the button. + */ + public boolean getCaptureButton() { + return getButton(Button.CAPTURE); + } + + /** + * Whether the Capture button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getCaptureButtonPressed() { + return getButtonPressed(Button.CAPTURE); + } + + /** + * Whether the Capture button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getCaptureButtonReleased() { + return getButtonReleased(Button.CAPTURE); + } + + /** + * Constructs an event instance around the Capture button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Capture button's digital signal + * attached to the given loop. + */ + public BooleanEvent capture(EventLoop loop) { + return button(Button.CAPTURE, loop); + } + + /** + * Read the value of the Home button on the controller. + * + * @return The state of the button. + */ + public boolean getHomeButton() { + return getButton(Button.HOME); + } + + /** + * Whether the Home button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getHomeButtonPressed() { + return getButtonPressed(Button.HOME); + } + + /** + * Whether the Home button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getHomeButtonReleased() { + return getButtonReleased(Button.HOME); + } + + /** + * Constructs an event instance around the Home button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Home button's digital signal + * attached to the given loop. + */ + public BooleanEvent home(EventLoop loop) { + return button(Button.HOME, loop); + } + + /** + * Read the value of the Start button on the controller. + * + * @return The state of the button. + */ + public boolean getStartButton() { + return getButton(Button.START); + } + + /** + * Whether the Start button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getStartButtonPressed() { + return getButtonPressed(Button.START); + } + + /** + * Whether the Start button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getStartButtonReleased() { + return getButtonReleased(Button.START); + } + + /** + * Constructs an event instance around the Start button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Start button's digital signal + * attached to the given loop. + */ + public BooleanEvent start(EventLoop loop) { + return button(Button.START, loop); + } + + /** + * Read the value of the C Down button on the controller. + * + * @return The state of the button. + */ + public boolean getCDownButton() { + return getButton(Button.C_DOWN); + } + + /** + * Whether the C Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getCDownButtonPressed() { + return getButtonPressed(Button.C_DOWN); + } + + /** + * Whether the C Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getCDownButtonReleased() { + return getButtonReleased(Button.C_DOWN); + } + + /** + * Constructs an event instance around the C Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the C Down button's digital signal + * attached to the given loop. + */ + public BooleanEvent CDown(EventLoop loop) { + return button(Button.C_DOWN, loop); + } + + /** + * Read the value of the L button on the controller. + * + * @return The state of the button. + */ + public boolean getLButton() { + return getButton(Button.L); + } + + /** + * Whether the L button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLButtonPressed() { + return getButtonPressed(Button.L); + } + + /** + * Whether the L button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLButtonReleased() { + return getButtonReleased(Button.L); + } + + /** + * Constructs an event instance around the L button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L button's digital signal + * attached to the given loop. + */ + public BooleanEvent L(EventLoop loop) { + return button(Button.L, loop); + } + + /** + * Read the value of the R button on the controller. + * + * @return The state of the button. + */ + public boolean getRButton() { + return getButton(Button.R); + } + + /** + * Whether the R button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRButtonPressed() { + return getButtonPressed(Button.R); + } + + /** + * Whether the R button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRButtonReleased() { + return getButtonReleased(Button.R); + } + + /** + * Constructs an event instance around the R button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R button's digital signal + * attached to the given loop. + */ + public BooleanEvent R(EventLoop loop) { + return button(Button.R, loop); + } + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadUpButton() { + return getButton(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadUpButtonPressed() { + return getButtonPressed(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadUpButtonReleased() { + return getButtonReleased(Button.DPAD_UP); + } + + /** + * Constructs an event instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadUp(EventLoop loop) { + return button(Button.DPAD_UP, loop); + } + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadDownButton() { + return getButton(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadDownButtonPressed() { + return getButtonPressed(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadDownButtonReleased() { + return getButtonReleased(Button.DPAD_DOWN); + } + + /** + * Constructs an event instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadDown(EventLoop loop) { + return button(Button.DPAD_DOWN, loop); + } + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadLeftButton() { + return getButton(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadLeftButtonPressed() { + return getButtonPressed(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadLeftButtonReleased() { + return getButtonReleased(Button.DPAD_LEFT); + } + + /** + * Constructs an event instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadLeft(EventLoop loop) { + return button(Button.DPAD_LEFT, loop); + } + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadRightButton() { + return getButton(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadRightButtonPressed() { + return getButtonPressed(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadRightButtonReleased() { + return getButtonReleased(Button.DPAD_RIGHT); + } + + /** + * Constructs an event instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadRight(EventLoop loop) { + return button(Button.DPAD_RIGHT, loop); + } + + /** + * Read the value of the C Right button on the controller. + * + * @return The state of the button. + */ + public boolean getCRightButton() { + return getButton(Button.C_RIGHT); + } + + /** + * Whether the C Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getCRightButtonPressed() { + return getButtonPressed(Button.C_RIGHT); + } + + /** + * Whether the C Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getCRightButtonReleased() { + return getButtonReleased(Button.C_RIGHT); + } + + /** + * Constructs an event instance around the C Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the C Right button's digital signal + * attached to the given loop. + */ + public BooleanEvent CRight(EventLoop loop) { + return button(Button.C_RIGHT, loop); + } + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + public boolean getButton(Button button) { + return m_hid.getRawButton(button.value); + } + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + public boolean getButtonPressed(Button button) { + return m_hid.getRawButtonPressed(button.value); + } + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + public boolean getButtonReleased(Button button) { + return m_hid.getRawButtonReleased(button.value); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public BooleanEvent button(Button button, EventLoop loop) { + return m_hid.button(button.value, loop); + } + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + public void setLeds(int r, int g, int b) { + m_hid.setLeds(r, g, b); + } + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + public void setRumble(GenericHID.RumbleType type, double value) { + m_hid.setRumble(type, value); + } + + + + @Override + public void initSendable(SendableBuilder builder) { + builder.setSmartDashboardType("HID"); + builder.publishConstString("ControllerType", "SwitchN64"); + builder.addDoubleProperty("LeftX", this::getLeftX, null); + builder.addDoubleProperty("LeftY", this::getLeftY, null); + builder.addDoubleProperty("ZAxis", this::getZAxis, null); + builder.addDoubleProperty("ZR", this::getZR, null); + builder.addBooleanProperty("A", this::getAButton, null); + builder.addBooleanProperty("B", this::getBButton, null); + builder.addBooleanProperty("CLeft", this::getCLeftButton, null); + builder.addBooleanProperty("CUp", this::getCUpButton, null); + builder.addBooleanProperty("Capture", this::getCaptureButton, null); + builder.addBooleanProperty("Home", this::getHomeButton, null); + builder.addBooleanProperty("Start", this::getStartButton, null); + builder.addBooleanProperty("CDown", this::getCDownButton, null); + builder.addBooleanProperty("L", this::getLButton, null); + builder.addBooleanProperty("R", this::getRButton, null); + builder.addBooleanProperty("DpadUp", this::getDpadUpButton, null); + builder.addBooleanProperty("DpadDown", this::getDpadDownButton, null); + builder.addBooleanProperty("DpadLeft", this::getDpadLeftButton, null); + builder.addBooleanProperty("DpadRight", this::getDpadRightButton, null); + builder.addBooleanProperty("CRight", this::getCRightButton, null); + } +} diff --git a/wpilibj/src/generated/main/java/org/wpilib/driverstation/SwitchProController.java b/wpilibj/src/generated/main/java/org/wpilib/driverstation/SwitchProController.java new file mode 100644 index 0000000000..c4ebf6c6da --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/driverstation/SwitchProController.java @@ -0,0 +1,972 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import java.util.EnumSet; +import java.util.Objects; +import org.wpilib.event.BooleanEvent; +import org.wpilib.event.EventLoop; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.util.sendable.Sendable; +import org.wpilib.util.sendable.SendableBuilder; + +/** + * Handle input from SwitchPro controllers connected to the Driver Station. + * + *

This class handles SwitchPro input that comes from the Driver Station. Each time a value + * is requested the most recent value is returned. + */ +public class SwitchProController implements HIDDevice, Sendable { + /** The number of touchpads supported by this controller. */ + public static final int TOUCHPAD_COUNT = 0; + + /** Whether this controller supports main rumble motors. */ + public static final boolean SUPPORTS_RUMBLE = true; + + /** Whether this controller supports trigger rumble motors. */ + public static final boolean SUPPORTS_TRIGGER_RUMBLE = false; + + /** Whether this controller supports mono LED output. */ + public static final boolean SUPPORTS_MONO_LED = true; + + /** Whether this controller supports RGB LED output. */ + public static final boolean SUPPORTS_RGB_LED = false; + + /** Represents a digital button on a SwitchProController. */ + public enum Button { + /** B button. */ + B(0, "BButton"), + /** A button. */ + A(1, "AButton"), + /** Y button. */ + Y(2, "YButton"), + /** X button. */ + X(3, "XButton"), + /** Minus button. */ + MINUS(4, "MinusButton"), + /** Home button. */ + HOME(5, "HomeButton"), + /** Plus button. */ + PLUS(6, "PlusButton"), + /** Left Stick button. */ + LEFT_STICK(7, "LeftStickButton"), + /** Right Stick button. */ + RIGHT_STICK(8, "RightStickButton"), + /** L button. */ + L(9, "LButton"), + /** R button. */ + R(10, "RButton"), + /** Dpad Up button. */ + DPAD_UP(11, "DpadUpButton"), + /** Dpad Down button. */ + DPAD_DOWN(12, "DpadDownButton"), + /** Dpad Left button. */ + DPAD_LEFT(13, "DpadLeftButton"), + /** Dpad Right button. */ + DPAD_RIGHT(14, "DpadRightButton"), + /** Capture button. */ + CAPTURE(15, "CaptureButton"); + + /** Button value. */ + public final int value; + + private final String m_name; + + Button(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + /** Represents an axis on a SwitchProController. */ + public enum Axis { + /** Left X. */ + LEFT_X(0, "LeftX"), + /** Left Y. */ + LEFT_Y(1, "LeftY"), + /** Right X. */ + RIGHT_X(2, "RightX"), + /** Right Y. */ + RIGHT_Y(3, "RightY"), + /** ZL. */ + ZL(4, "ZL"), + /** ZR. */ + ZR(5, "ZR"); + + /** Axis value. */ + public final int value; + + private final String m_name; + + Axis(int value, String name) { + this.value = value; + m_name = name; + } + + @Override + public String toString() { + return m_name; + } + } + + private final GenericHID m_hid; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public SwitchProController(final int port) { + this(DriverStation.getGenericHID(port)); + } + + /** + * Construct an instance of a controller with a GenericHID object. + * + * @param hid The GenericHID object to use for this controller. + */ + public SwitchProController(final GenericHID hid) { + m_hid = Objects.requireNonNull(hid, "Provided HID object cannot be null"); + HAL.reportUsage("HID", hid.getPort(), "SwitchProController"); + } + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + @Override + public GenericHID getHID() { + return m_hid; + } + + /** + * Get the supported outputs expected for this controller type. + * + * @return the expected supported outputs + */ + public static EnumSet getSupportedOutputCapabilities() { + return EnumSet.of( + GenericHID.SupportedOutput.MONO_LED, + GenericHID.SupportedOutput.RUMBLE + ); + } + + /** + * Get the port number of the HID. + * + * @return The port number of the HID. + */ + public int getPort() { + return m_hid.getPort(); + } + + /** + * Get if the HID is connected. + * + * @return true if the HID is connected + */ + public boolean isConnected() { + return m_hid.isConnected(); + } + + /** + * Get the Left X value of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return getAxis(Axis.LEFT_X); + } + + /** + * Get the Left Y value of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return getAxis(Axis.LEFT_Y); + } + + /** + * Get the Right X value of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return getAxis(Axis.RIGHT_X); + } + + /** + * Get the Right Y value of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return getAxis(Axis.RIGHT_Y); + } + + /** + * Get the ZL value of the controller. + * + * @return The axis value. + */ + public double getZL() { + return getAxis(Axis.ZL); + } + + /** + * Get the ZR value of the controller. + * + * @return The axis value. + */ + public double getZR() { + return getAxis(Axis.ZR); + } + + /** + * Get the value of the axis. + * + * @param axis The axis to read + * @return The axis value. + */ + public double getAxis(Axis axis) { + return m_hid.getRawAxis(axis.value); + } + + /** + * Constructs an event instance that is true when the axis value is less than {@code threshold}. + * + * @param axis The axis to read. + * @param threshold The value below which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is less than the provided + * threshold. + */ + public BooleanEvent axisLessThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisLessThan(axis.value, threshold, loop); + } + + /** + * Constructs an event instance that is true when the axis value is greater than {@code + * threshold}. + * + * @param axis The axis to read. + * @param threshold The value above which this event should return true. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the axis value is greater than the provided + * threshold. + */ + public BooleanEvent axisGreaterThan(Axis axis, double threshold, EventLoop loop) { + return m_hid.axisGreaterThan(axis.value, threshold, loop); + } + + /** + * Read the value of the B button on the controller. + * + * @return The state of the button. + */ + public boolean getBButton() { + return getButton(Button.B); + } + + /** + * Whether the B button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getBButtonPressed() { + return getButtonPressed(Button.B); + } + + /** + * Whether the B button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getBButtonReleased() { + return getButtonReleased(Button.B); + } + + /** + * Constructs an event instance around the B button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the B button's digital signal + * attached to the given loop. + */ + public BooleanEvent b(EventLoop loop) { + return button(Button.B, loop); + } + + /** + * Read the value of the A button on the controller. + * + * @return The state of the button. + */ + public boolean getAButton() { + return getButton(Button.A); + } + + /** + * Whether the A button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getAButtonPressed() { + return getButtonPressed(Button.A); + } + + /** + * Whether the A button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getAButtonReleased() { + return getButtonReleased(Button.A); + } + + /** + * Constructs an event instance around the A button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the A button's digital signal + * attached to the given loop. + */ + public BooleanEvent a(EventLoop loop) { + return button(Button.A, loop); + } + + /** + * Read the value of the Y button on the controller. + * + * @return The state of the button. + */ + public boolean getYButton() { + return getButton(Button.Y); + } + + /** + * Whether the Y button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getYButtonPressed() { + return getButtonPressed(Button.Y); + } + + /** + * Whether the Y button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getYButtonReleased() { + return getButtonReleased(Button.Y); + } + + /** + * Constructs an event instance around the Y button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Y button's digital signal + * attached to the given loop. + */ + public BooleanEvent y(EventLoop loop) { + return button(Button.Y, loop); + } + + /** + * Read the value of the X button on the controller. + * + * @return The state of the button. + */ + public boolean getXButton() { + return getButton(Button.X); + } + + /** + * Whether the X button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getXButtonPressed() { + return getButtonPressed(Button.X); + } + + /** + * Whether the X button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getXButtonReleased() { + return getButtonReleased(Button.X); + } + + /** + * Constructs an event instance around the X button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the X button's digital signal + * attached to the given loop. + */ + public BooleanEvent x(EventLoop loop) { + return button(Button.X, loop); + } + + /** + * Read the value of the Minus button on the controller. + * + * @return The state of the button. + */ + public boolean getMinusButton() { + return getButton(Button.MINUS); + } + + /** + * Whether the Minus button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getMinusButtonPressed() { + return getButtonPressed(Button.MINUS); + } + + /** + * Whether the Minus button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getMinusButtonReleased() { + return getButtonReleased(Button.MINUS); + } + + /** + * Constructs an event instance around the Minus button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Minus button's digital signal + * attached to the given loop. + */ + public BooleanEvent minus(EventLoop loop) { + return button(Button.MINUS, loop); + } + + /** + * Read the value of the Home button on the controller. + * + * @return The state of the button. + */ + public boolean getHomeButton() { + return getButton(Button.HOME); + } + + /** + * Whether the Home button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getHomeButtonPressed() { + return getButtonPressed(Button.HOME); + } + + /** + * Whether the Home button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getHomeButtonReleased() { + return getButtonReleased(Button.HOME); + } + + /** + * Constructs an event instance around the Home button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Home button's digital signal + * attached to the given loop. + */ + public BooleanEvent home(EventLoop loop) { + return button(Button.HOME, loop); + } + + /** + * Read the value of the Plus button on the controller. + * + * @return The state of the button. + */ + public boolean getPlusButton() { + return getButton(Button.PLUS); + } + + /** + * Whether the Plus button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getPlusButtonPressed() { + return getButtonPressed(Button.PLUS); + } + + /** + * Whether the Plus button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getPlusButtonReleased() { + return getButtonReleased(Button.PLUS); + } + + /** + * Constructs an event instance around the Plus button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Plus button's digital signal + * attached to the given loop. + */ + public BooleanEvent plus(EventLoop loop) { + return button(Button.PLUS, loop); + } + + /** + * Read the value of the Left Stick button on the controller. + * + * @return The state of the button. + */ + public boolean getLeftStickButton() { + return getButton(Button.LEFT_STICK); + } + + /** + * Whether the Left Stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLeftStickButtonPressed() { + return getButtonPressed(Button.LEFT_STICK); + } + + /** + * Whether the Left Stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLeftStickButtonReleased() { + return getButtonReleased(Button.LEFT_STICK); + } + + /** + * Constructs an event instance around the Left Stick button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Left Stick button's digital signal + * attached to the given loop. + */ + public BooleanEvent leftStick(EventLoop loop) { + return button(Button.LEFT_STICK, loop); + } + + /** + * Read the value of the Right Stick button on the controller. + * + * @return The state of the button. + */ + public boolean getRightStickButton() { + return getButton(Button.RIGHT_STICK); + } + + /** + * Whether the Right Stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightStickButtonPressed() { + return getButtonPressed(Button.RIGHT_STICK); + } + + /** + * Whether the Right Stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightStickButtonReleased() { + return getButtonReleased(Button.RIGHT_STICK); + } + + /** + * Constructs an event instance around the Right Stick button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Right Stick button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightStick(EventLoop loop) { + return button(Button.RIGHT_STICK, loop); + } + + /** + * Read the value of the L button on the controller. + * + * @return The state of the button. + */ + public boolean getLButton() { + return getButton(Button.L); + } + + /** + * Whether the L button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLButtonPressed() { + return getButtonPressed(Button.L); + } + + /** + * Whether the L button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLButtonReleased() { + return getButtonReleased(Button.L); + } + + /** + * Constructs an event instance around the L button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the L button's digital signal + * attached to the given loop. + */ + public BooleanEvent L(EventLoop loop) { + return button(Button.L, loop); + } + + /** + * Read the value of the R button on the controller. + * + * @return The state of the button. + */ + public boolean getRButton() { + return getButton(Button.R); + } + + /** + * Whether the R button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRButtonPressed() { + return getButtonPressed(Button.R); + } + + /** + * Whether the R button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRButtonReleased() { + return getButtonReleased(Button.R); + } + + /** + * Constructs an event instance around the R button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the R button's digital signal + * attached to the given loop. + */ + public BooleanEvent R(EventLoop loop) { + return button(Button.R, loop); + } + + /** + * Read the value of the Dpad Up button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadUpButton() { + return getButton(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadUpButtonPressed() { + return getButtonPressed(Button.DPAD_UP); + } + + /** + * Whether the Dpad Up button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadUpButtonReleased() { + return getButtonReleased(Button.DPAD_UP); + } + + /** + * Constructs an event instance around the Dpad Up button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Up button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadUp(EventLoop loop) { + return button(Button.DPAD_UP, loop); + } + + /** + * Read the value of the Dpad Down button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadDownButton() { + return getButton(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadDownButtonPressed() { + return getButtonPressed(Button.DPAD_DOWN); + } + + /** + * Whether the Dpad Down button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadDownButtonReleased() { + return getButtonReleased(Button.DPAD_DOWN); + } + + /** + * Constructs an event instance around the Dpad Down button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Down button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadDown(EventLoop loop) { + return button(Button.DPAD_DOWN, loop); + } + + /** + * Read the value of the Dpad Left button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadLeftButton() { + return getButton(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadLeftButtonPressed() { + return getButtonPressed(Button.DPAD_LEFT); + } + + /** + * Whether the Dpad Left button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadLeftButtonReleased() { + return getButtonReleased(Button.DPAD_LEFT); + } + + /** + * Constructs an event instance around the Dpad Left button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Left button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadLeft(EventLoop loop) { + return button(Button.DPAD_LEFT, loop); + } + + /** + * Read the value of the Dpad Right button on the controller. + * + * @return The state of the button. + */ + public boolean getDpadRightButton() { + return getButton(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getDpadRightButtonPressed() { + return getButtonPressed(Button.DPAD_RIGHT); + } + + /** + * Whether the Dpad Right button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getDpadRightButtonReleased() { + return getButtonReleased(Button.DPAD_RIGHT); + } + + /** + * Constructs an event instance around the Dpad Right button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Dpad Right button's digital signal + * attached to the given loop. + */ + public BooleanEvent dpadRight(EventLoop loop) { + return button(Button.DPAD_RIGHT, loop); + } + + /** + * Read the value of the Capture button on the controller. + * + * @return The state of the button. + */ + public boolean getCaptureButton() { + return getButton(Button.CAPTURE); + } + + /** + * Whether the Capture button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getCaptureButtonPressed() { + return getButtonPressed(Button.CAPTURE); + } + + /** + * Whether the Capture button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getCaptureButtonReleased() { + return getButtonReleased(Button.CAPTURE); + } + + /** + * Constructs an event instance around the Capture button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the Capture button's digital signal + * attached to the given loop. + */ + public BooleanEvent capture(EventLoop loop) { + return button(Button.CAPTURE, loop); + } + + /** + * Get the button value. + * + * @param button The button to read + * @return The state of the button. + */ + public boolean getButton(Button button) { + return m_hid.getRawButton(button.value); + } + + /** + * Whether the button was pressed since the last check. + * + * @param button The button to read + * @return Whether the button was pressed since the last check. + */ + public boolean getButtonPressed(Button button) { + return m_hid.getRawButtonPressed(button.value); + } + + /** + * Whether the button was released since the last check. + * + * @param button The button to read + * @return Whether the button was released since the last check. + */ + public boolean getButtonReleased(Button button) { + return m_hid.getRawButtonReleased(button.value); + } + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the button's digital signal attached to the given loop. + */ + public BooleanEvent button(Button button, EventLoop loop) { + return m_hid.button(button.value, loop); + } + + /** + * Set leds on the controller. + * + * @param r Red value from 0-255 + * @param g Green value from 0-255 + * @param b Blue value from 0-255 + */ + public void setLeds(int r, int g, int b) { + m_hid.setLeds(r, g, b); + } + + /** + * Set the rumble output for the HID. + * + * @param type Which rumble value to set + * @param value The normalized value (0 to 1) to set the rumble to + */ + public void setRumble(GenericHID.RumbleType type, double value) { + m_hid.setRumble(type, value); + } + + + + @Override + public void initSendable(SendableBuilder builder) { + builder.setSmartDashboardType("HID"); + builder.publishConstString("ControllerType", "SwitchPro"); + builder.addDoubleProperty("LeftX", this::getLeftX, null); + builder.addDoubleProperty("LeftY", this::getLeftY, null); + builder.addDoubleProperty("RightX", this::getRightX, null); + builder.addDoubleProperty("RightY", this::getRightY, null); + builder.addDoubleProperty("ZL", this::getZL, null); + builder.addDoubleProperty("ZR", this::getZR, null); + builder.addBooleanProperty("B", this::getBButton, null); + builder.addBooleanProperty("A", this::getAButton, null); + builder.addBooleanProperty("Y", this::getYButton, null); + builder.addBooleanProperty("X", this::getXButton, null); + builder.addBooleanProperty("Minus", this::getMinusButton, null); + builder.addBooleanProperty("Home", this::getHomeButton, null); + builder.addBooleanProperty("Plus", this::getPlusButton, null); + builder.addBooleanProperty("LeftStick", this::getLeftStickButton, null); + builder.addBooleanProperty("RightStick", this::getRightStickButton, null); + builder.addBooleanProperty("L", this::getLButton, null); + builder.addBooleanProperty("R", this::getRButton, null); + builder.addBooleanProperty("DpadUp", this::getDpadUpButton, null); + builder.addBooleanProperty("DpadDown", this::getDpadDownButton, null); + builder.addBooleanProperty("DpadLeft", this::getDpadLeftButton, null); + builder.addBooleanProperty("DpadRight", this::getDpadRightButton, null); + builder.addBooleanProperty("Capture", this::getCaptureButton, null); + } +} diff --git a/wpilibj/src/generated/main/java/org/wpilib/simulation/DualSenseEdgeControllerSim.java b/wpilibj/src/generated/main/java/org/wpilib/simulation/DualSenseEdgeControllerSim.java new file mode 100644 index 0000000000..838f463afd --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/simulation/DualSenseEdgeControllerSim.java @@ -0,0 +1,287 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.simulation; + +import org.wpilib.driverstation.DualSenseEdgeController; +import org.wpilib.driverstation.GenericHID; + + +/** Class to control a simulated DualSenseEdge controller. */ +public class DualSenseEdgeControllerSim extends GenericHIDSim { + /** + * Constructs from a DualSenseEdgeController object. + * + * @param joystick controller to simulate + */ + @SuppressWarnings("this-escape") + public DualSenseEdgeControllerSim(DualSenseEdgeController joystick) { + super(joystick.getHID()); + configureDevice(); + } + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + @SuppressWarnings("this-escape") + public DualSenseEdgeControllerSim(int port) { + super(port); + configureDevice(); + } + + private void configureDevice() { + setAxesAvailable(0x3F); + setButtonsAvailable(0x73FFFFL); + setPOVsAvailable(0); + setGamepadType(GenericHID.HIDType.PS5); + setSupportedOutputs(DualSenseEdgeController.getSupportedOutputCapabilities()); + } + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + public void setLeftX(double value) { + setRawAxis(DualSenseEdgeController.Axis.LEFT_X.value, value); + } + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + public void setLeftY(double value) { + setRawAxis(DualSenseEdgeController.Axis.LEFT_Y.value, value); + } + + /** + * Change the Right X value of the controller. + * + * @param value the new value + */ + public void setRightX(double value) { + setRawAxis(DualSenseEdgeController.Axis.RIGHT_X.value, value); + } + + /** + * Change the Right Y value of the controller. + * + * @param value the new value + */ + public void setRightY(double value) { + setRawAxis(DualSenseEdgeController.Axis.RIGHT_Y.value, value); + } + + /** + * Change the L 2 value of the controller. + * + * @param value the new value + */ + public void setL2(double value) { + setRawAxis(DualSenseEdgeController.Axis.L2.value, value); + } + + /** + * Change the R 2 value of the controller. + * + * @param value the new value + */ + public void setR2(double value) { + setRawAxis(DualSenseEdgeController.Axis.R2.value, value); + } + + /** + * Change the value of the Cross button on the controller. + * + * @param value the new value + */ + public void setCrossButton(boolean value) { + setRawButton(DualSenseEdgeController.Button.CROSS.value, value); + } + + /** + * Change the value of the Circle button on the controller. + * + * @param value the new value + */ + public void setCircleButton(boolean value) { + setRawButton(DualSenseEdgeController.Button.CIRCLE.value, value); + } + + /** + * Change the value of the Square button on the controller. + * + * @param value the new value + */ + public void setSquareButton(boolean value) { + setRawButton(DualSenseEdgeController.Button.SQUARE.value, value); + } + + /** + * Change the value of the Triangle button on the controller. + * + * @param value the new value + */ + public void setTriangleButton(boolean value) { + setRawButton(DualSenseEdgeController.Button.TRIANGLE.value, value); + } + + /** + * Change the value of the Create button on the controller. + * + * @param value the new value + */ + public void setCreateButton(boolean value) { + setRawButton(DualSenseEdgeController.Button.CREATE.value, value); + } + + /** + * Change the value of the PS button on the controller. + * + * @param value the new value + */ + public void setPSButton(boolean value) { + setRawButton(DualSenseEdgeController.Button.PS.value, value); + } + + /** + * Change the value of the Options button on the controller. + * + * @param value the new value + */ + public void setOptionsButton(boolean value) { + setRawButton(DualSenseEdgeController.Button.OPTIONS.value, value); + } + + /** + * Change the value of the L 3 button on the controller. + * + * @param value the new value + */ + public void setL3Button(boolean value) { + setRawButton(DualSenseEdgeController.Button.L3.value, value); + } + + /** + * Change the value of the R 3 button on the controller. + * + * @param value the new value + */ + public void setR3Button(boolean value) { + setRawButton(DualSenseEdgeController.Button.R3.value, value); + } + + /** + * Change the value of the L 1 button on the controller. + * + * @param value the new value + */ + public void setL1Button(boolean value) { + setRawButton(DualSenseEdgeController.Button.L1.value, value); + } + + /** + * Change the value of the R 1 button on the controller. + * + * @param value the new value + */ + public void setR1Button(boolean value) { + setRawButton(DualSenseEdgeController.Button.R1.value, value); + } + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + public void setDpadUpButton(boolean value) { + setRawButton(DualSenseEdgeController.Button.DPAD_UP.value, value); + } + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + public void setDpadDownButton(boolean value) { + setRawButton(DualSenseEdgeController.Button.DPAD_DOWN.value, value); + } + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + public void setDpadLeftButton(boolean value) { + setRawButton(DualSenseEdgeController.Button.DPAD_LEFT.value, value); + } + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + public void setDpadRightButton(boolean value) { + setRawButton(DualSenseEdgeController.Button.DPAD_RIGHT.value, value); + } + + /** + * Change the value of the Microphone button on the controller. + * + * @param value the new value + */ + public void setMicrophoneButton(boolean value) { + setRawButton(DualSenseEdgeController.Button.MICROPHONE.value, value); + } + + /** + * Change the value of the Right Paddle 1 button on the controller. + * + * @param value the new value + */ + public void setRightPaddle1Button(boolean value) { + setRawButton(DualSenseEdgeController.Button.RIGHT_PADDLE_1.value, value); + } + + /** + * Change the value of the Left Paddle 1 button on the controller. + * + * @param value the new value + */ + public void setLeftPaddle1Button(boolean value) { + setRawButton(DualSenseEdgeController.Button.LEFT_PADDLE_1.value, value); + } + + /** + * Change the value of the Touchpad button on the controller. + * + * @param value the new value + */ + public void setTouchpadButton(boolean value) { + setRawButton(DualSenseEdgeController.Button.TOUCHPAD.value, value); + } + + /** + * Change the value of the Left Function button on the controller. + * + * @param value the new value + */ + public void setLeftFunctionButton(boolean value) { + setRawButton(DualSenseEdgeController.Button.LEFT_FUNCTION.value, value); + } + + /** + * Change the value of the Right Function button on the controller. + * + * @param value the new value + */ + public void setRightFunctionButton(boolean value) { + setRawButton(DualSenseEdgeController.Button.RIGHT_FUNCTION.value, value); + } +} diff --git a/wpilibj/src/generated/main/java/org/wpilib/simulation/DualShock4ControllerSim.java b/wpilibj/src/generated/main/java/org/wpilib/simulation/DualShock4ControllerSim.java new file mode 100644 index 0000000000..017cbfa4f8 --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/simulation/DualShock4ControllerSim.java @@ -0,0 +1,242 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.simulation; + +import org.wpilib.driverstation.DualShock4Controller; +import org.wpilib.driverstation.GenericHID; + + +/** Class to control a simulated DualShock4 controller. */ +public class DualShock4ControllerSim extends GenericHIDSim { + /** + * Constructs from a DualShock4Controller object. + * + * @param joystick controller to simulate + */ + @SuppressWarnings("this-escape") + public DualShock4ControllerSim(DualShock4Controller joystick) { + super(joystick.getHID()); + configureDevice(); + } + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + @SuppressWarnings("this-escape") + public DualShock4ControllerSim(int port) { + super(port); + configureDevice(); + } + + private void configureDevice() { + setAxesAvailable(0x3F); + setButtonsAvailable(0x107FFFL); + setPOVsAvailable(0); + setGamepadType(GenericHID.HIDType.PS4); + setSupportedOutputs(DualShock4Controller.getSupportedOutputCapabilities()); + } + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + public void setLeftX(double value) { + setRawAxis(DualShock4Controller.Axis.LEFT_X.value, value); + } + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + public void setLeftY(double value) { + setRawAxis(DualShock4Controller.Axis.LEFT_Y.value, value); + } + + /** + * Change the Right X value of the controller. + * + * @param value the new value + */ + public void setRightX(double value) { + setRawAxis(DualShock4Controller.Axis.RIGHT_X.value, value); + } + + /** + * Change the Right Y value of the controller. + * + * @param value the new value + */ + public void setRightY(double value) { + setRawAxis(DualShock4Controller.Axis.RIGHT_Y.value, value); + } + + /** + * Change the L 2 value of the controller. + * + * @param value the new value + */ + public void setL2(double value) { + setRawAxis(DualShock4Controller.Axis.L2.value, value); + } + + /** + * Change the R 2 value of the controller. + * + * @param value the new value + */ + public void setR2(double value) { + setRawAxis(DualShock4Controller.Axis.R2.value, value); + } + + /** + * Change the value of the Cross button on the controller. + * + * @param value the new value + */ + public void setCrossButton(boolean value) { + setRawButton(DualShock4Controller.Button.CROSS.value, value); + } + + /** + * Change the value of the Circle button on the controller. + * + * @param value the new value + */ + public void setCircleButton(boolean value) { + setRawButton(DualShock4Controller.Button.CIRCLE.value, value); + } + + /** + * Change the value of the Square button on the controller. + * + * @param value the new value + */ + public void setSquareButton(boolean value) { + setRawButton(DualShock4Controller.Button.SQUARE.value, value); + } + + /** + * Change the value of the Triangle button on the controller. + * + * @param value the new value + */ + public void setTriangleButton(boolean value) { + setRawButton(DualShock4Controller.Button.TRIANGLE.value, value); + } + + /** + * Change the value of the Share button on the controller. + * + * @param value the new value + */ + public void setShareButton(boolean value) { + setRawButton(DualShock4Controller.Button.SHARE.value, value); + } + + /** + * Change the value of the PS button on the controller. + * + * @param value the new value + */ + public void setPSButton(boolean value) { + setRawButton(DualShock4Controller.Button.PS.value, value); + } + + /** + * Change the value of the Options button on the controller. + * + * @param value the new value + */ + public void setOptionsButton(boolean value) { + setRawButton(DualShock4Controller.Button.OPTIONS.value, value); + } + + /** + * Change the value of the L 3 button on the controller. + * + * @param value the new value + */ + public void setL3Button(boolean value) { + setRawButton(DualShock4Controller.Button.L3.value, value); + } + + /** + * Change the value of the R 3 button on the controller. + * + * @param value the new value + */ + public void setR3Button(boolean value) { + setRawButton(DualShock4Controller.Button.R3.value, value); + } + + /** + * Change the value of the L 1 button on the controller. + * + * @param value the new value + */ + public void setL1Button(boolean value) { + setRawButton(DualShock4Controller.Button.L1.value, value); + } + + /** + * Change the value of the R 1 button on the controller. + * + * @param value the new value + */ + public void setR1Button(boolean value) { + setRawButton(DualShock4Controller.Button.R1.value, value); + } + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + public void setDpadUpButton(boolean value) { + setRawButton(DualShock4Controller.Button.DPAD_UP.value, value); + } + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + public void setDpadDownButton(boolean value) { + setRawButton(DualShock4Controller.Button.DPAD_DOWN.value, value); + } + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + public void setDpadLeftButton(boolean value) { + setRawButton(DualShock4Controller.Button.DPAD_LEFT.value, value); + } + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + public void setDpadRightButton(boolean value) { + setRawButton(DualShock4Controller.Button.DPAD_RIGHT.value, value); + } + + /** + * Change the value of the Touchpad button on the controller. + * + * @param value the new value + */ + public void setTouchpadButton(boolean value) { + setRawButton(DualShock4Controller.Button.TOUCHPAD.value, value); + } +} diff --git a/wpilibj/src/generated/main/java/org/wpilib/simulation/GameCubeControllerSim.java b/wpilibj/src/generated/main/java/org/wpilib/simulation/GameCubeControllerSim.java new file mode 100644 index 0000000000..20bb7f14cb --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/simulation/GameCubeControllerSim.java @@ -0,0 +1,206 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.simulation; + +import org.wpilib.driverstation.GameCubeController; +import org.wpilib.driverstation.GenericHID; + + +/** Class to control a simulated GameCube controller. */ +public class GameCubeControllerSim extends GenericHIDSim { + /** + * Constructs from a GameCubeController object. + * + * @param joystick controller to simulate + */ + @SuppressWarnings("this-escape") + public GameCubeControllerSim(GameCubeController joystick) { + super(joystick.getHID()); + configureDevice(); + } + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + @SuppressWarnings("this-escape") + public GameCubeControllerSim(int port) { + super(port); + configureDevice(); + } + + private void configureDevice() { + setAxesAvailable(0x3F); + setButtonsAvailable(0xC07C4FL); + setPOVsAvailable(0); + setGamepadType(GenericHID.HIDType.STANDARD); + setSupportedOutputs(GameCubeController.getSupportedOutputCapabilities()); + } + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + public void setLeftX(double value) { + setRawAxis(GameCubeController.Axis.LEFT_X.value, value); + } + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + public void setLeftY(double value) { + setRawAxis(GameCubeController.Axis.LEFT_Y.value, value); + } + + /** + * Change the C Stick X value of the controller. + * + * @param value the new value + */ + public void setCStickX(double value) { + setRawAxis(GameCubeController.Axis.C_STICK_X.value, value); + } + + /** + * Change the C Stick Y value of the controller. + * + * @param value the new value + */ + public void setCStickY(double value) { + setRawAxis(GameCubeController.Axis.C_STICK_Y.value, value); + } + + /** + * Change the L Trigger value of the controller. + * + * @param value the new value + */ + public void setLTrigger(double value) { + setRawAxis(GameCubeController.Axis.L_TRIGGER.value, value); + } + + /** + * Change the R Trigger value of the controller. + * + * @param value the new value + */ + public void setRTrigger(double value) { + setRawAxis(GameCubeController.Axis.R_TRIGGER.value, value); + } + + /** + * Change the value of the A button on the controller. + * + * @param value the new value + */ + public void setAButton(boolean value) { + setRawButton(GameCubeController.Button.A.value, value); + } + + /** + * Change the value of the X button on the controller. + * + * @param value the new value + */ + public void setXButton(boolean value) { + setRawButton(GameCubeController.Button.X.value, value); + } + + /** + * Change the value of the B button on the controller. + * + * @param value the new value + */ + public void setBButton(boolean value) { + setRawButton(GameCubeController.Button.B.value, value); + } + + /** + * Change the value of the Y button on the controller. + * + * @param value the new value + */ + public void setYButton(boolean value) { + setRawButton(GameCubeController.Button.Y.value, value); + } + + /** + * Change the value of the Start button on the controller. + * + * @param value the new value + */ + public void setStartButton(boolean value) { + setRawButton(GameCubeController.Button.START.value, value); + } + + /** + * Change the value of the Z button on the controller. + * + * @param value the new value + */ + public void setZButton(boolean value) { + setRawButton(GameCubeController.Button.Z.value, value); + } + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + public void setDpadUpButton(boolean value) { + setRawButton(GameCubeController.Button.DPAD_UP.value, value); + } + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + public void setDpadDownButton(boolean value) { + setRawButton(GameCubeController.Button.DPAD_DOWN.value, value); + } + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + public void setDpadLeftButton(boolean value) { + setRawButton(GameCubeController.Button.DPAD_LEFT.value, value); + } + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + public void setDpadRightButton(boolean value) { + setRawButton(GameCubeController.Button.DPAD_RIGHT.value, value); + } + + /** + * Change the value of the L button on the controller. + * + * @param value the new value + */ + public void setLButton(boolean value) { + setRawButton(GameCubeController.Button.L.value, value); + } + + /** + * Change the value of the R button on the controller. + * + * @param value the new value + */ + public void setRButton(boolean value) { + setRawButton(GameCubeController.Button.R.value, value); + } +} diff --git a/wpilibj/src/generated/main/java/org/wpilib/simulation/LogitechF310ControllerSim.java b/wpilibj/src/generated/main/java/org/wpilib/simulation/LogitechF310ControllerSim.java new file mode 100644 index 0000000000..af8997af76 --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/simulation/LogitechF310ControllerSim.java @@ -0,0 +1,233 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.simulation; + +import org.wpilib.driverstation.GenericHID; +import org.wpilib.driverstation.LogitechF310Controller; + + +/** Class to control a simulated LogitechF310 controller. */ +public class LogitechF310ControllerSim extends GenericHIDSim { + /** + * Constructs from a LogitechF310Controller object. + * + * @param joystick controller to simulate + */ + @SuppressWarnings("this-escape") + public LogitechF310ControllerSim(LogitechF310Controller joystick) { + super(joystick.getHID()); + configureDevice(); + } + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + @SuppressWarnings("this-escape") + public LogitechF310ControllerSim(int port) { + super(port); + configureDevice(); + } + + private void configureDevice() { + setAxesAvailable(0x3F); + setButtonsAvailable(0x7FFFL); + setPOVsAvailable(0); + setGamepadType(GenericHID.HIDType.XBOX_360); + setSupportedOutputs(LogitechF310Controller.getSupportedOutputCapabilities()); + } + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + public void setLeftX(double value) { + setRawAxis(LogitechF310Controller.Axis.LEFT_X.value, value); + } + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + public void setLeftY(double value) { + setRawAxis(LogitechF310Controller.Axis.LEFT_Y.value, value); + } + + /** + * Change the Right X value of the controller. + * + * @param value the new value + */ + public void setRightX(double value) { + setRawAxis(LogitechF310Controller.Axis.RIGHT_X.value, value); + } + + /** + * Change the Right Y value of the controller. + * + * @param value the new value + */ + public void setRightY(double value) { + setRawAxis(LogitechF310Controller.Axis.RIGHT_Y.value, value); + } + + /** + * Change the Left Trigger value of the controller. + * + * @param value the new value + */ + public void setLeftTrigger(double value) { + setRawAxis(LogitechF310Controller.Axis.LEFT_TRIGGER.value, value); + } + + /** + * Change the Right Trigger value of the controller. + * + * @param value the new value + */ + public void setRightTrigger(double value) { + setRawAxis(LogitechF310Controller.Axis.RIGHT_TRIGGER.value, value); + } + + /** + * Change the value of the A button on the controller. + * + * @param value the new value + */ + public void setAButton(boolean value) { + setRawButton(LogitechF310Controller.Button.A.value, value); + } + + /** + * Change the value of the B button on the controller. + * + * @param value the new value + */ + public void setBButton(boolean value) { + setRawButton(LogitechF310Controller.Button.B.value, value); + } + + /** + * Change the value of the X button on the controller. + * + * @param value the new value + */ + public void setXButton(boolean value) { + setRawButton(LogitechF310Controller.Button.X.value, value); + } + + /** + * Change the value of the Y button on the controller. + * + * @param value the new value + */ + public void setYButton(boolean value) { + setRawButton(LogitechF310Controller.Button.Y.value, value); + } + + /** + * Change the value of the Back button on the controller. + * + * @param value the new value + */ + public void setBackButton(boolean value) { + setRawButton(LogitechF310Controller.Button.BACK.value, value); + } + + /** + * Change the value of the Logitech button on the controller. + * + * @param value the new value + */ + public void setLogitechButton(boolean value) { + setRawButton(LogitechF310Controller.Button.LOGITECH.value, value); + } + + /** + * Change the value of the Start button on the controller. + * + * @param value the new value + */ + public void setStartButton(boolean value) { + setRawButton(LogitechF310Controller.Button.START.value, value); + } + + /** + * Change the value of the Left Stick button on the controller. + * + * @param value the new value + */ + public void setLeftStickButton(boolean value) { + setRawButton(LogitechF310Controller.Button.LEFT_STICK.value, value); + } + + /** + * Change the value of the Right Stick button on the controller. + * + * @param value the new value + */ + public void setRightStickButton(boolean value) { + setRawButton(LogitechF310Controller.Button.RIGHT_STICK.value, value); + } + + /** + * Change the value of the Left Bumper button on the controller. + * + * @param value the new value + */ + public void setLeftBumperButton(boolean value) { + setRawButton(LogitechF310Controller.Button.LEFT_BUMPER.value, value); + } + + /** + * Change the value of the Right Bumper button on the controller. + * + * @param value the new value + */ + public void setRightBumperButton(boolean value) { + setRawButton(LogitechF310Controller.Button.RIGHT_BUMPER.value, value); + } + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + public void setDpadUpButton(boolean value) { + setRawButton(LogitechF310Controller.Button.DPAD_UP.value, value); + } + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + public void setDpadDownButton(boolean value) { + setRawButton(LogitechF310Controller.Button.DPAD_DOWN.value, value); + } + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + public void setDpadLeftButton(boolean value) { + setRawButton(LogitechF310Controller.Button.DPAD_LEFT.value, value); + } + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + public void setDpadRightButton(boolean value) { + setRawButton(LogitechF310Controller.Button.DPAD_RIGHT.value, value); + } +} diff --git a/wpilibj/src/generated/main/java/org/wpilib/simulation/SteamControllerSim.java b/wpilibj/src/generated/main/java/org/wpilib/simulation/SteamControllerSim.java new file mode 100644 index 0000000000..c2557ced1c --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/simulation/SteamControllerSim.java @@ -0,0 +1,332 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.simulation; + +import org.wpilib.driverstation.GenericHID; +import org.wpilib.driverstation.SteamController; + + +/** Class to control a simulated Steam controller. */ +public class SteamControllerSim extends GenericHIDSim { + /** + * Constructs from a SteamController object. + * + * @param joystick controller to simulate + */ + @SuppressWarnings("this-escape") + public SteamControllerSim(SteamController joystick) { + super(joystick.getHID()); + configureDevice(); + } + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + @SuppressWarnings("this-escape") + public SteamControllerSim(int port) { + super(port); + configureDevice(); + } + + private void configureDevice() { + setAxesAvailable(0x3F); + setButtonsAvailable(0x3FFFFFFL); + setPOVsAvailable(0); + setGamepadType(GenericHID.HIDType.STANDARD); + setSupportedOutputs(SteamController.getSupportedOutputCapabilities()); + } + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + public void setLeftX(double value) { + setRawAxis(SteamController.Axis.LEFT_X.value, value); + } + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + public void setLeftY(double value) { + setRawAxis(SteamController.Axis.LEFT_Y.value, value); + } + + /** + * Change the Right X value of the controller. + * + * @param value the new value + */ + public void setRightX(double value) { + setRawAxis(SteamController.Axis.RIGHT_X.value, value); + } + + /** + * Change the Right Y value of the controller. + * + * @param value the new value + */ + public void setRightY(double value) { + setRawAxis(SteamController.Axis.RIGHT_Y.value, value); + } + + /** + * Change the Left Trigger value of the controller. + * + * @param value the new value + */ + public void setLeftTrigger(double value) { + setRawAxis(SteamController.Axis.LEFT_TRIGGER.value, value); + } + + /** + * Change the Right Trigger value of the controller. + * + * @param value the new value + */ + public void setRightTrigger(double value) { + setRawAxis(SteamController.Axis.RIGHT_TRIGGER.value, value); + } + + /** + * Change the value of the A button on the controller. + * + * @param value the new value + */ + public void setAButton(boolean value) { + setRawButton(SteamController.Button.A.value, value); + } + + /** + * Change the value of the B button on the controller. + * + * @param value the new value + */ + public void setBButton(boolean value) { + setRawButton(SteamController.Button.B.value, value); + } + + /** + * Change the value of the X button on the controller. + * + * @param value the new value + */ + public void setXButton(boolean value) { + setRawButton(SteamController.Button.X.value, value); + } + + /** + * Change the value of the Y button on the controller. + * + * @param value the new value + */ + public void setYButton(boolean value) { + setRawButton(SteamController.Button.Y.value, value); + } + + /** + * Change the value of the Menu button on the controller. + * + * @param value the new value + */ + public void setMenuButton(boolean value) { + setRawButton(SteamController.Button.MENU.value, value); + } + + /** + * Change the value of the Steam button on the controller. + * + * @param value the new value + */ + public void setSteamButton(boolean value) { + setRawButton(SteamController.Button.STEAM.value, value); + } + + /** + * Change the value of the View button on the controller. + * + * @param value the new value + */ + public void setViewButton(boolean value) { + setRawButton(SteamController.Button.VIEW.value, value); + } + + /** + * Change the value of the Left Stick button on the controller. + * + * @param value the new value + */ + public void setLeftStickButton(boolean value) { + setRawButton(SteamController.Button.LEFT_STICK.value, value); + } + + /** + * Change the value of the Right Stick button on the controller. + * + * @param value the new value + */ + public void setRightStickButton(boolean value) { + setRawButton(SteamController.Button.RIGHT_STICK.value, value); + } + + /** + * Change the value of the Left Bumper button on the controller. + * + * @param value the new value + */ + public void setLeftBumperButton(boolean value) { + setRawButton(SteamController.Button.LEFT_BUMPER.value, value); + } + + /** + * Change the value of the Right Bumper button on the controller. + * + * @param value the new value + */ + public void setRightBumperButton(boolean value) { + setRawButton(SteamController.Button.RIGHT_BUMPER.value, value); + } + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + public void setDpadUpButton(boolean value) { + setRawButton(SteamController.Button.DPAD_UP.value, value); + } + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + public void setDpadDownButton(boolean value) { + setRawButton(SteamController.Button.DPAD_DOWN.value, value); + } + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + public void setDpadLeftButton(boolean value) { + setRawButton(SteamController.Button.DPAD_LEFT.value, value); + } + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + public void setDpadRightButton(boolean value) { + setRawButton(SteamController.Button.DPAD_RIGHT.value, value); + } + + /** + * Change the value of the QAM button on the controller. + * + * @param value the new value + */ + public void setQAMButton(boolean value) { + setRawButton(SteamController.Button.QAM.value, value); + } + + /** + * Change the value of the Right Paddle 1 button on the controller. + * + * @param value the new value + */ + public void setRightPaddle1Button(boolean value) { + setRawButton(SteamController.Button.RIGHT_PADDLE_1.value, value); + } + + /** + * Change the value of the Left Paddle 1 button on the controller. + * + * @param value the new value + */ + public void setLeftPaddle1Button(boolean value) { + setRawButton(SteamController.Button.LEFT_PADDLE_1.value, value); + } + + /** + * Change the value of the Right Paddle 2 button on the controller. + * + * @param value the new value + */ + public void setRightPaddle2Button(boolean value) { + setRawButton(SteamController.Button.RIGHT_PADDLE_2.value, value); + } + + /** + * Change the value of the Left Paddle 2 button on the controller. + * + * @param value the new value + */ + public void setLeftPaddle2Button(boolean value) { + setRawButton(SteamController.Button.LEFT_PADDLE_2.value, value); + } + + /** + * Change the value of the Left Touchpad button on the controller. + * + * @param value the new value + */ + public void setLeftTouchpadButton(boolean value) { + setRawButton(SteamController.Button.LEFT_TOUCHPAD.value, value); + } + + /** + * Change the value of the Right Touchpad button on the controller. + * + * @param value the new value + */ + public void setRightTouchpadButton(boolean value) { + setRawButton(SteamController.Button.RIGHT_TOUCHPAD.value, value); + } + + /** + * Change the value of the Left Stick Touch button on the controller. + * + * @param value the new value + */ + public void setLeftStickTouchButton(boolean value) { + setRawButton(SteamController.Button.LEFT_STICK_TOUCH.value, value); + } + + /** + * Change the value of the Right Stick Touch button on the controller. + * + * @param value the new value + */ + public void setRightStickTouchButton(boolean value) { + setRawButton(SteamController.Button.RIGHT_STICK_TOUCH.value, value); + } + + /** + * Change the value of the Left Grip Touch button on the controller. + * + * @param value the new value + */ + public void setLeftGripTouchButton(boolean value) { + setRawButton(SteamController.Button.LEFT_GRIP_TOUCH.value, value); + } + + /** + * Change the value of the Right Grip Touch button on the controller. + * + * @param value the new value + */ + public void setRightGripTouchButton(boolean value) { + setRawButton(SteamController.Button.RIGHT_GRIP_TOUCH.value, value); + } +} diff --git a/wpilibj/src/generated/main/java/org/wpilib/simulation/Switch2GCControllerSim.java b/wpilibj/src/generated/main/java/org/wpilib/simulation/Switch2GCControllerSim.java new file mode 100644 index 0000000000..a99bfab561 --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/simulation/Switch2GCControllerSim.java @@ -0,0 +1,242 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.simulation; + +import org.wpilib.driverstation.GenericHID; +import org.wpilib.driverstation.Switch2GCController; + + +/** Class to control a simulated Switch2GC controller. */ +public class Switch2GCControllerSim extends GenericHIDSim { + /** + * Constructs from a Switch2GCController object. + * + * @param joystick controller to simulate + */ + @SuppressWarnings("this-escape") + public Switch2GCControllerSim(Switch2GCController joystick) { + super(joystick.getHID()); + configureDevice(); + } + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + @SuppressWarnings("this-escape") + public Switch2GCControllerSim(int port) { + super(port); + configureDevice(); + } + + private void configureDevice() { + setAxesAvailable(0x3F); + setButtonsAvailable(0xE0FE6FL); + setPOVsAvailable(0); + setGamepadType(GenericHID.HIDType.SWITCH_PRO); + setSupportedOutputs(Switch2GCController.getSupportedOutputCapabilities()); + } + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + public void setLeftX(double value) { + setRawAxis(Switch2GCController.Axis.LEFT_X.value, value); + } + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + public void setLeftY(double value) { + setRawAxis(Switch2GCController.Axis.LEFT_Y.value, value); + } + + /** + * Change the C Stick X value of the controller. + * + * @param value the new value + */ + public void setCStickX(double value) { + setRawAxis(Switch2GCController.Axis.C_STICK_X.value, value); + } + + /** + * Change the C Stick Y value of the controller. + * + * @param value the new value + */ + public void setCStickY(double value) { + setRawAxis(Switch2GCController.Axis.C_STICK_Y.value, value); + } + + /** + * Change the L Trigger value of the controller. + * + * @param value the new value + */ + public void setLTrigger(double value) { + setRawAxis(Switch2GCController.Axis.L_TRIGGER.value, value); + } + + /** + * Change the R Trigger value of the controller. + * + * @param value the new value + */ + public void setRTrigger(double value) { + setRawAxis(Switch2GCController.Axis.R_TRIGGER.value, value); + } + + /** + * Change the value of the A button on the controller. + * + * @param value the new value + */ + public void setAButton(boolean value) { + setRawButton(Switch2GCController.Button.A.value, value); + } + + /** + * Change the value of the X button on the controller. + * + * @param value the new value + */ + public void setXButton(boolean value) { + setRawButton(Switch2GCController.Button.X.value, value); + } + + /** + * Change the value of the B button on the controller. + * + * @param value the new value + */ + public void setBButton(boolean value) { + setRawButton(Switch2GCController.Button.B.value, value); + } + + /** + * Change the value of the Y button on the controller. + * + * @param value the new value + */ + public void setYButton(boolean value) { + setRawButton(Switch2GCController.Button.Y.value, value); + } + + /** + * Change the value of the Home button on the controller. + * + * @param value the new value + */ + public void setHomeButton(boolean value) { + setRawButton(Switch2GCController.Button.HOME.value, value); + } + + /** + * Change the value of the Start button on the controller. + * + * @param value the new value + */ + public void setStartButton(boolean value) { + setRawButton(Switch2GCController.Button.START.value, value); + } + + /** + * Change the value of the ZL button on the controller. + * + * @param value the new value + */ + public void setZLButton(boolean value) { + setRawButton(Switch2GCController.Button.ZL.value, value); + } + + /** + * Change the value of the Z button on the controller. + * + * @param value the new value + */ + public void setZButton(boolean value) { + setRawButton(Switch2GCController.Button.Z.value, value); + } + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + public void setDpadUpButton(boolean value) { + setRawButton(Switch2GCController.Button.DPAD_UP.value, value); + } + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + public void setDpadDownButton(boolean value) { + setRawButton(Switch2GCController.Button.DPAD_DOWN.value, value); + } + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + public void setDpadLeftButton(boolean value) { + setRawButton(Switch2GCController.Button.DPAD_LEFT.value, value); + } + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + public void setDpadRightButton(boolean value) { + setRawButton(Switch2GCController.Button.DPAD_RIGHT.value, value); + } + + /** + * Change the value of the Capture button on the controller. + * + * @param value the new value + */ + public void setCaptureButton(boolean value) { + setRawButton(Switch2GCController.Button.CAPTURE.value, value); + } + + /** + * Change the value of the C button on the controller. + * + * @param value the new value + */ + public void setCButton(boolean value) { + setRawButton(Switch2GCController.Button.C.value, value); + } + + /** + * Change the value of the L button on the controller. + * + * @param value the new value + */ + public void setLButton(boolean value) { + setRawButton(Switch2GCController.Button.L.value, value); + } + + /** + * Change the value of the R button on the controller. + * + * @param value the new value + */ + public void setRButton(boolean value) { + setRawButton(Switch2GCController.Button.R.value, value); + } +} diff --git a/wpilibj/src/generated/main/java/org/wpilib/simulation/Switch2ProControllerSim.java b/wpilibj/src/generated/main/java/org/wpilib/simulation/Switch2ProControllerSim.java new file mode 100644 index 0000000000..639c26273d --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/simulation/Switch2ProControllerSim.java @@ -0,0 +1,269 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.simulation; + +import org.wpilib.driverstation.GenericHID; +import org.wpilib.driverstation.Switch2ProController; + + +/** Class to control a simulated Switch2Pro controller. */ +public class Switch2ProControllerSim extends GenericHIDSim { + /** + * Constructs from a Switch2ProController object. + * + * @param joystick controller to simulate + */ + @SuppressWarnings("this-escape") + public Switch2ProControllerSim(Switch2ProController joystick) { + super(joystick.getHID()); + configureDevice(); + } + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + @SuppressWarnings("this-escape") + public Switch2ProControllerSim(int port) { + super(port); + configureDevice(); + } + + private void configureDevice() { + setAxesAvailable(0x3F); + setButtonsAvailable(0x23FFFFL); + setPOVsAvailable(0); + setGamepadType(GenericHID.HIDType.SWITCH_PRO); + setSupportedOutputs(Switch2ProController.getSupportedOutputCapabilities()); + } + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + public void setLeftX(double value) { + setRawAxis(Switch2ProController.Axis.LEFT_X.value, value); + } + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + public void setLeftY(double value) { + setRawAxis(Switch2ProController.Axis.LEFT_Y.value, value); + } + + /** + * Change the Right X value of the controller. + * + * @param value the new value + */ + public void setRightX(double value) { + setRawAxis(Switch2ProController.Axis.RIGHT_X.value, value); + } + + /** + * Change the Right Y value of the controller. + * + * @param value the new value + */ + public void setRightY(double value) { + setRawAxis(Switch2ProController.Axis.RIGHT_Y.value, value); + } + + /** + * Change the ZL value of the controller. + * + * @param value the new value + */ + public void setZL(double value) { + setRawAxis(Switch2ProController.Axis.ZL.value, value); + } + + /** + * Change the ZR value of the controller. + * + * @param value the new value + */ + public void setZR(double value) { + setRawAxis(Switch2ProController.Axis.ZR.value, value); + } + + /** + * Change the value of the B button on the controller. + * + * @param value the new value + */ + public void setBButton(boolean value) { + setRawButton(Switch2ProController.Button.B.value, value); + } + + /** + * Change the value of the A button on the controller. + * + * @param value the new value + */ + public void setAButton(boolean value) { + setRawButton(Switch2ProController.Button.A.value, value); + } + + /** + * Change the value of the Y button on the controller. + * + * @param value the new value + */ + public void setYButton(boolean value) { + setRawButton(Switch2ProController.Button.Y.value, value); + } + + /** + * Change the value of the X button on the controller. + * + * @param value the new value + */ + public void setXButton(boolean value) { + setRawButton(Switch2ProController.Button.X.value, value); + } + + /** + * Change the value of the Minus button on the controller. + * + * @param value the new value + */ + public void setMinusButton(boolean value) { + setRawButton(Switch2ProController.Button.MINUS.value, value); + } + + /** + * Change the value of the Home button on the controller. + * + * @param value the new value + */ + public void setHomeButton(boolean value) { + setRawButton(Switch2ProController.Button.HOME.value, value); + } + + /** + * Change the value of the Plus button on the controller. + * + * @param value the new value + */ + public void setPlusButton(boolean value) { + setRawButton(Switch2ProController.Button.PLUS.value, value); + } + + /** + * Change the value of the Left Stick button on the controller. + * + * @param value the new value + */ + public void setLeftStickButton(boolean value) { + setRawButton(Switch2ProController.Button.LEFT_STICK.value, value); + } + + /** + * Change the value of the Right Stick button on the controller. + * + * @param value the new value + */ + public void setRightStickButton(boolean value) { + setRawButton(Switch2ProController.Button.RIGHT_STICK.value, value); + } + + /** + * Change the value of the L button on the controller. + * + * @param value the new value + */ + public void setLButton(boolean value) { + setRawButton(Switch2ProController.Button.L.value, value); + } + + /** + * Change the value of the R button on the controller. + * + * @param value the new value + */ + public void setRButton(boolean value) { + setRawButton(Switch2ProController.Button.R.value, value); + } + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + public void setDpadUpButton(boolean value) { + setRawButton(Switch2ProController.Button.DPAD_UP.value, value); + } + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + public void setDpadDownButton(boolean value) { + setRawButton(Switch2ProController.Button.DPAD_DOWN.value, value); + } + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + public void setDpadLeftButton(boolean value) { + setRawButton(Switch2ProController.Button.DPAD_LEFT.value, value); + } + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + public void setDpadRightButton(boolean value) { + setRawButton(Switch2ProController.Button.DPAD_RIGHT.value, value); + } + + /** + * Change the value of the Capture button on the controller. + * + * @param value the new value + */ + public void setCaptureButton(boolean value) { + setRawButton(Switch2ProController.Button.CAPTURE.value, value); + } + + /** + * Change the value of the GR button on the controller. + * + * @param value the new value + */ + public void setGRButton(boolean value) { + setRawButton(Switch2ProController.Button.GR.value, value); + } + + /** + * Change the value of the GL button on the controller. + * + * @param value the new value + */ + public void setGLButton(boolean value) { + setRawButton(Switch2ProController.Button.GL.value, value); + } + + /** + * Change the value of the C button on the controller. + * + * @param value the new value + */ + public void setCButton(boolean value) { + setRawButton(Switch2ProController.Button.C.value, value); + } +} diff --git a/wpilibj/src/generated/main/java/org/wpilib/simulation/SwitchN64ControllerSim.java b/wpilibj/src/generated/main/java/org/wpilib/simulation/SwitchN64ControllerSim.java new file mode 100644 index 0000000000..8a2ac7f99b --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/simulation/SwitchN64ControllerSim.java @@ -0,0 +1,215 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.simulation; + +import org.wpilib.driverstation.GenericHID; +import org.wpilib.driverstation.SwitchN64Controller; + + +/** Class to control a simulated SwitchN64 controller. */ +public class SwitchN64ControllerSim extends GenericHIDSim { + /** + * Constructs from a SwitchN64Controller object. + * + * @param joystick controller to simulate + */ + @SuppressWarnings("this-escape") + public SwitchN64ControllerSim(SwitchN64Controller joystick) { + super(joystick.getHID()); + configureDevice(); + } + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + @SuppressWarnings("this-escape") + public SwitchN64ControllerSim(int port) { + super(port); + configureDevice(); + } + + private void configureDevice() { + setAxesAvailable(0x33); + setButtonsAvailable(0x20FE7FL); + setPOVsAvailable(0); + setGamepadType(GenericHID.HIDType.SWITCH_PRO); + setSupportedOutputs(SwitchN64Controller.getSupportedOutputCapabilities()); + } + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + public void setLeftX(double value) { + setRawAxis(SwitchN64Controller.Axis.LEFT_X.value, value); + } + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + public void setLeftY(double value) { + setRawAxis(SwitchN64Controller.Axis.LEFT_Y.value, value); + } + + /** + * Change the Z Axis value of the controller. + * + * @param value the new value + */ + public void setZAxis(double value) { + setRawAxis(SwitchN64Controller.Axis.Z_AXIS.value, value); + } + + /** + * Change the ZR value of the controller. + * + * @param value the new value + */ + public void setZR(double value) { + setRawAxis(SwitchN64Controller.Axis.ZR.value, value); + } + + /** + * Change the value of the A button on the controller. + * + * @param value the new value + */ + public void setAButton(boolean value) { + setRawButton(SwitchN64Controller.Button.A.value, value); + } + + /** + * Change the value of the B button on the controller. + * + * @param value the new value + */ + public void setBButton(boolean value) { + setRawButton(SwitchN64Controller.Button.B.value, value); + } + + /** + * Change the value of the C Left button on the controller. + * + * @param value the new value + */ + public void setCLeftButton(boolean value) { + setRawButton(SwitchN64Controller.Button.C_LEFT.value, value); + } + + /** + * Change the value of the C Up button on the controller. + * + * @param value the new value + */ + public void setCUpButton(boolean value) { + setRawButton(SwitchN64Controller.Button.C_UP.value, value); + } + + /** + * Change the value of the Capture button on the controller. + * + * @param value the new value + */ + public void setCaptureButton(boolean value) { + setRawButton(SwitchN64Controller.Button.CAPTURE.value, value); + } + + /** + * Change the value of the Home button on the controller. + * + * @param value the new value + */ + public void setHomeButton(boolean value) { + setRawButton(SwitchN64Controller.Button.HOME.value, value); + } + + /** + * Change the value of the Start button on the controller. + * + * @param value the new value + */ + public void setStartButton(boolean value) { + setRawButton(SwitchN64Controller.Button.START.value, value); + } + + /** + * Change the value of the C Down button on the controller. + * + * @param value the new value + */ + public void setCDownButton(boolean value) { + setRawButton(SwitchN64Controller.Button.C_DOWN.value, value); + } + + /** + * Change the value of the L button on the controller. + * + * @param value the new value + */ + public void setLButton(boolean value) { + setRawButton(SwitchN64Controller.Button.L.value, value); + } + + /** + * Change the value of the R button on the controller. + * + * @param value the new value + */ + public void setRButton(boolean value) { + setRawButton(SwitchN64Controller.Button.R.value, value); + } + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + public void setDpadUpButton(boolean value) { + setRawButton(SwitchN64Controller.Button.DPAD_UP.value, value); + } + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + public void setDpadDownButton(boolean value) { + setRawButton(SwitchN64Controller.Button.DPAD_DOWN.value, value); + } + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + public void setDpadLeftButton(boolean value) { + setRawButton(SwitchN64Controller.Button.DPAD_LEFT.value, value); + } + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + public void setDpadRightButton(boolean value) { + setRawButton(SwitchN64Controller.Button.DPAD_RIGHT.value, value); + } + + /** + * Change the value of the C Right button on the controller. + * + * @param value the new value + */ + public void setCRightButton(boolean value) { + setRawButton(SwitchN64Controller.Button.C_RIGHT.value, value); + } +} diff --git a/wpilibj/src/generated/main/java/org/wpilib/simulation/SwitchProControllerSim.java b/wpilibj/src/generated/main/java/org/wpilib/simulation/SwitchProControllerSim.java new file mode 100644 index 0000000000..d4d9ce5c66 --- /dev/null +++ b/wpilibj/src/generated/main/java/org/wpilib/simulation/SwitchProControllerSim.java @@ -0,0 +1,242 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.simulation; + +import org.wpilib.driverstation.GenericHID; +import org.wpilib.driverstation.SwitchProController; + + +/** Class to control a simulated SwitchPro controller. */ +public class SwitchProControllerSim extends GenericHIDSim { + /** + * Constructs from a SwitchProController object. + * + * @param joystick controller to simulate + */ + @SuppressWarnings("this-escape") + public SwitchProControllerSim(SwitchProController joystick) { + super(joystick.getHID()); + configureDevice(); + } + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + @SuppressWarnings("this-escape") + public SwitchProControllerSim(int port) { + super(port); + configureDevice(); + } + + private void configureDevice() { + setAxesAvailable(0x3F); + setButtonsAvailable(0xFFFFL); + setPOVsAvailable(0); + setGamepadType(GenericHID.HIDType.SWITCH_PRO); + setSupportedOutputs(SwitchProController.getSupportedOutputCapabilities()); + } + + /** + * Change the Left X value of the controller. + * + * @param value the new value + */ + public void setLeftX(double value) { + setRawAxis(SwitchProController.Axis.LEFT_X.value, value); + } + + /** + * Change the Left Y value of the controller. + * + * @param value the new value + */ + public void setLeftY(double value) { + setRawAxis(SwitchProController.Axis.LEFT_Y.value, value); + } + + /** + * Change the Right X value of the controller. + * + * @param value the new value + */ + public void setRightX(double value) { + setRawAxis(SwitchProController.Axis.RIGHT_X.value, value); + } + + /** + * Change the Right Y value of the controller. + * + * @param value the new value + */ + public void setRightY(double value) { + setRawAxis(SwitchProController.Axis.RIGHT_Y.value, value); + } + + /** + * Change the ZL value of the controller. + * + * @param value the new value + */ + public void setZL(double value) { + setRawAxis(SwitchProController.Axis.ZL.value, value); + } + + /** + * Change the ZR value of the controller. + * + * @param value the new value + */ + public void setZR(double value) { + setRawAxis(SwitchProController.Axis.ZR.value, value); + } + + /** + * Change the value of the B button on the controller. + * + * @param value the new value + */ + public void setBButton(boolean value) { + setRawButton(SwitchProController.Button.B.value, value); + } + + /** + * Change the value of the A button on the controller. + * + * @param value the new value + */ + public void setAButton(boolean value) { + setRawButton(SwitchProController.Button.A.value, value); + } + + /** + * Change the value of the Y button on the controller. + * + * @param value the new value + */ + public void setYButton(boolean value) { + setRawButton(SwitchProController.Button.Y.value, value); + } + + /** + * Change the value of the X button on the controller. + * + * @param value the new value + */ + public void setXButton(boolean value) { + setRawButton(SwitchProController.Button.X.value, value); + } + + /** + * Change the value of the Minus button on the controller. + * + * @param value the new value + */ + public void setMinusButton(boolean value) { + setRawButton(SwitchProController.Button.MINUS.value, value); + } + + /** + * Change the value of the Home button on the controller. + * + * @param value the new value + */ + public void setHomeButton(boolean value) { + setRawButton(SwitchProController.Button.HOME.value, value); + } + + /** + * Change the value of the Plus button on the controller. + * + * @param value the new value + */ + public void setPlusButton(boolean value) { + setRawButton(SwitchProController.Button.PLUS.value, value); + } + + /** + * Change the value of the Left Stick button on the controller. + * + * @param value the new value + */ + public void setLeftStickButton(boolean value) { + setRawButton(SwitchProController.Button.LEFT_STICK.value, value); + } + + /** + * Change the value of the Right Stick button on the controller. + * + * @param value the new value + */ + public void setRightStickButton(boolean value) { + setRawButton(SwitchProController.Button.RIGHT_STICK.value, value); + } + + /** + * Change the value of the L button on the controller. + * + * @param value the new value + */ + public void setLButton(boolean value) { + setRawButton(SwitchProController.Button.L.value, value); + } + + /** + * Change the value of the R button on the controller. + * + * @param value the new value + */ + public void setRButton(boolean value) { + setRawButton(SwitchProController.Button.R.value, value); + } + + /** + * Change the value of the Dpad Up button on the controller. + * + * @param value the new value + */ + public void setDpadUpButton(boolean value) { + setRawButton(SwitchProController.Button.DPAD_UP.value, value); + } + + /** + * Change the value of the Dpad Down button on the controller. + * + * @param value the new value + */ + public void setDpadDownButton(boolean value) { + setRawButton(SwitchProController.Button.DPAD_DOWN.value, value); + } + + /** + * Change the value of the Dpad Left button on the controller. + * + * @param value the new value + */ + public void setDpadLeftButton(boolean value) { + setRawButton(SwitchProController.Button.DPAD_LEFT.value, value); + } + + /** + * Change the value of the Dpad Right button on the controller. + * + * @param value the new value + */ + public void setDpadRightButton(boolean value) { + setRawButton(SwitchProController.Button.DPAD_RIGHT.value, value); + } + + /** + * Change the value of the Capture button on the controller. + * + * @param value the new value + */ + public void setCaptureButton(boolean value) { + setRawButton(SwitchProController.Button.CAPTURE.value, value); + } +} diff --git a/wpilibj/src/generated/test/java/org/wpilib/driverstation/DualSenseEdgeControllerTest.java b/wpilibj/src/generated/test/java/org/wpilib/driverstation/DualSenseEdgeControllerTest.java new file mode 100644 index 0000000000..0c7d1872e4 --- /dev/null +++ b/wpilibj/src/generated/test/java/org/wpilib/driverstation/DualSenseEdgeControllerTest.java @@ -0,0 +1,95 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.simulation.DualSenseEdgeControllerSim; + +class DualSenseEdgeControllerTest { + @Test + void testWrappedHID() { + HAL.initialize(500, 0); + DualSenseEdgeController controller = new DualSenseEdgeController(2); + DualSenseEdgeControllerSim sim = new DualSenseEdgeControllerSim(controller); + sim.notifyNewData(); + + assertEquals(2, controller.getPort()); + assertEquals(2, controller.getHID().getPort()); + assertEquals(0x3F, controller.getHID().getAxesAvailable()); + assertEquals(0x73FFFFL, controller.getHID().getButtonsAvailable()); + assertEquals(0, controller.getHID().getPOVsAvailable()); + } + + @ParameterizedTest + @EnumSource(value = DualSenseEdgeController.Button.class) + void testButtons(DualSenseEdgeController.Button button) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + DualSenseEdgeController joy = new DualSenseEdgeController(2); + DualSenseEdgeControllerSim joysim = new DualSenseEdgeControllerSim(joy); + + var buttonName = button.toString(); + + String simSetMethodName = "set" + buttonName; + String joyGetMethodName = "get" + buttonName; + String joyPressedMethodName = "get" + buttonName + "Pressed"; + String joyReleasedMethodName = "get" + buttonName + "Released"; + + final Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, boolean.class); + final Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + final Method joyPressedMethod = joy.getClass().getMethod(joyPressedMethodName); + final Method joyReleasedMethod = joy.getClass().getMethod(joyReleasedMethodName); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + joyPressedMethod.invoke(joy); + joyReleasedMethod.invoke(joy); + + simSetMethod.invoke(joysim, true); + joysim.notifyNewData(); + assertTrue((Boolean) joyGetMethod.invoke(joy)); + assertTrue((Boolean) joyPressedMethod.invoke(joy)); + assertFalse((Boolean) joyReleasedMethod.invoke(joy)); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + assertFalse((Boolean) joyPressedMethod.invoke(joy)); + assertTrue((Boolean) joyReleasedMethod.invoke(joy)); + } + + @ParameterizedTest + @EnumSource(value = DualSenseEdgeController.Axis.class) + void testAxes(DualSenseEdgeController.Axis axis) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + DualSenseEdgeController joy = new DualSenseEdgeController(2); + DualSenseEdgeControllerSim joysim = new DualSenseEdgeControllerSim(joy); + + var axisName = axis.toString(); + + String simSetMethodName = "set" + axisName; + String joyGetMethodName = "get" + axisName; + + Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, double.class); + Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + + simSetMethod.invoke(joysim, 0.35); + joysim.notifyNewData(); + assertEquals(0.35, (Double) joyGetMethod.invoke(joy), 0.001); + } +} diff --git a/wpilibj/src/generated/test/java/org/wpilib/driverstation/DualShock4ControllerTest.java b/wpilibj/src/generated/test/java/org/wpilib/driverstation/DualShock4ControllerTest.java new file mode 100644 index 0000000000..e70c2cc8ee --- /dev/null +++ b/wpilibj/src/generated/test/java/org/wpilib/driverstation/DualShock4ControllerTest.java @@ -0,0 +1,95 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.simulation.DualShock4ControllerSim; + +class DualShock4ControllerTest { + @Test + void testWrappedHID() { + HAL.initialize(500, 0); + DualShock4Controller controller = new DualShock4Controller(2); + DualShock4ControllerSim sim = new DualShock4ControllerSim(controller); + sim.notifyNewData(); + + assertEquals(2, controller.getPort()); + assertEquals(2, controller.getHID().getPort()); + assertEquals(0x3F, controller.getHID().getAxesAvailable()); + assertEquals(0x107FFFL, controller.getHID().getButtonsAvailable()); + assertEquals(0, controller.getHID().getPOVsAvailable()); + } + + @ParameterizedTest + @EnumSource(value = DualShock4Controller.Button.class) + void testButtons(DualShock4Controller.Button button) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + DualShock4Controller joy = new DualShock4Controller(2); + DualShock4ControllerSim joysim = new DualShock4ControllerSim(joy); + + var buttonName = button.toString(); + + String simSetMethodName = "set" + buttonName; + String joyGetMethodName = "get" + buttonName; + String joyPressedMethodName = "get" + buttonName + "Pressed"; + String joyReleasedMethodName = "get" + buttonName + "Released"; + + final Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, boolean.class); + final Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + final Method joyPressedMethod = joy.getClass().getMethod(joyPressedMethodName); + final Method joyReleasedMethod = joy.getClass().getMethod(joyReleasedMethodName); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + joyPressedMethod.invoke(joy); + joyReleasedMethod.invoke(joy); + + simSetMethod.invoke(joysim, true); + joysim.notifyNewData(); + assertTrue((Boolean) joyGetMethod.invoke(joy)); + assertTrue((Boolean) joyPressedMethod.invoke(joy)); + assertFalse((Boolean) joyReleasedMethod.invoke(joy)); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + assertFalse((Boolean) joyPressedMethod.invoke(joy)); + assertTrue((Boolean) joyReleasedMethod.invoke(joy)); + } + + @ParameterizedTest + @EnumSource(value = DualShock4Controller.Axis.class) + void testAxes(DualShock4Controller.Axis axis) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + DualShock4Controller joy = new DualShock4Controller(2); + DualShock4ControllerSim joysim = new DualShock4ControllerSim(joy); + + var axisName = axis.toString(); + + String simSetMethodName = "set" + axisName; + String joyGetMethodName = "get" + axisName; + + Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, double.class); + Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + + simSetMethod.invoke(joysim, 0.35); + joysim.notifyNewData(); + assertEquals(0.35, (Double) joyGetMethod.invoke(joy), 0.001); + } +} diff --git a/wpilibj/src/generated/test/java/org/wpilib/driverstation/GameCubeControllerTest.java b/wpilibj/src/generated/test/java/org/wpilib/driverstation/GameCubeControllerTest.java new file mode 100644 index 0000000000..d914a42044 --- /dev/null +++ b/wpilibj/src/generated/test/java/org/wpilib/driverstation/GameCubeControllerTest.java @@ -0,0 +1,95 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.simulation.GameCubeControllerSim; + +class GameCubeControllerTest { + @Test + void testWrappedHID() { + HAL.initialize(500, 0); + GameCubeController controller = new GameCubeController(2); + GameCubeControllerSim sim = new GameCubeControllerSim(controller); + sim.notifyNewData(); + + assertEquals(2, controller.getPort()); + assertEquals(2, controller.getHID().getPort()); + assertEquals(0x3F, controller.getHID().getAxesAvailable()); + assertEquals(0xC07C4FL, controller.getHID().getButtonsAvailable()); + assertEquals(0, controller.getHID().getPOVsAvailable()); + } + + @ParameterizedTest + @EnumSource(value = GameCubeController.Button.class) + void testButtons(GameCubeController.Button button) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + GameCubeController joy = new GameCubeController(2); + GameCubeControllerSim joysim = new GameCubeControllerSim(joy); + + var buttonName = button.toString(); + + String simSetMethodName = "set" + buttonName; + String joyGetMethodName = "get" + buttonName; + String joyPressedMethodName = "get" + buttonName + "Pressed"; + String joyReleasedMethodName = "get" + buttonName + "Released"; + + final Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, boolean.class); + final Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + final Method joyPressedMethod = joy.getClass().getMethod(joyPressedMethodName); + final Method joyReleasedMethod = joy.getClass().getMethod(joyReleasedMethodName); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + joyPressedMethod.invoke(joy); + joyReleasedMethod.invoke(joy); + + simSetMethod.invoke(joysim, true); + joysim.notifyNewData(); + assertTrue((Boolean) joyGetMethod.invoke(joy)); + assertTrue((Boolean) joyPressedMethod.invoke(joy)); + assertFalse((Boolean) joyReleasedMethod.invoke(joy)); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + assertFalse((Boolean) joyPressedMethod.invoke(joy)); + assertTrue((Boolean) joyReleasedMethod.invoke(joy)); + } + + @ParameterizedTest + @EnumSource(value = GameCubeController.Axis.class) + void testAxes(GameCubeController.Axis axis) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + GameCubeController joy = new GameCubeController(2); + GameCubeControllerSim joysim = new GameCubeControllerSim(joy); + + var axisName = axis.toString(); + + String simSetMethodName = "set" + axisName; + String joyGetMethodName = "get" + axisName; + + Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, double.class); + Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + + simSetMethod.invoke(joysim, 0.35); + joysim.notifyNewData(); + assertEquals(0.35, (Double) joyGetMethod.invoke(joy), 0.001); + } +} diff --git a/wpilibj/src/generated/test/java/org/wpilib/driverstation/LogitechF310ControllerTest.java b/wpilibj/src/generated/test/java/org/wpilib/driverstation/LogitechF310ControllerTest.java new file mode 100644 index 0000000000..cccd3f727f --- /dev/null +++ b/wpilibj/src/generated/test/java/org/wpilib/driverstation/LogitechF310ControllerTest.java @@ -0,0 +1,95 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.simulation.LogitechF310ControllerSim; + +class LogitechF310ControllerTest { + @Test + void testWrappedHID() { + HAL.initialize(500, 0); + LogitechF310Controller controller = new LogitechF310Controller(2); + LogitechF310ControllerSim sim = new LogitechF310ControllerSim(controller); + sim.notifyNewData(); + + assertEquals(2, controller.getPort()); + assertEquals(2, controller.getHID().getPort()); + assertEquals(0x3F, controller.getHID().getAxesAvailable()); + assertEquals(0x7FFFL, controller.getHID().getButtonsAvailable()); + assertEquals(0, controller.getHID().getPOVsAvailable()); + } + + @ParameterizedTest + @EnumSource(value = LogitechF310Controller.Button.class) + void testButtons(LogitechF310Controller.Button button) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + LogitechF310Controller joy = new LogitechF310Controller(2); + LogitechF310ControllerSim joysim = new LogitechF310ControllerSim(joy); + + var buttonName = button.toString(); + + String simSetMethodName = "set" + buttonName; + String joyGetMethodName = "get" + buttonName; + String joyPressedMethodName = "get" + buttonName + "Pressed"; + String joyReleasedMethodName = "get" + buttonName + "Released"; + + final Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, boolean.class); + final Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + final Method joyPressedMethod = joy.getClass().getMethod(joyPressedMethodName); + final Method joyReleasedMethod = joy.getClass().getMethod(joyReleasedMethodName); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + joyPressedMethod.invoke(joy); + joyReleasedMethod.invoke(joy); + + simSetMethod.invoke(joysim, true); + joysim.notifyNewData(); + assertTrue((Boolean) joyGetMethod.invoke(joy)); + assertTrue((Boolean) joyPressedMethod.invoke(joy)); + assertFalse((Boolean) joyReleasedMethod.invoke(joy)); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + assertFalse((Boolean) joyPressedMethod.invoke(joy)); + assertTrue((Boolean) joyReleasedMethod.invoke(joy)); + } + + @ParameterizedTest + @EnumSource(value = LogitechF310Controller.Axis.class) + void testAxes(LogitechF310Controller.Axis axis) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + LogitechF310Controller joy = new LogitechF310Controller(2); + LogitechF310ControllerSim joysim = new LogitechF310ControllerSim(joy); + + var axisName = axis.toString(); + + String simSetMethodName = "set" + axisName; + String joyGetMethodName = "get" + axisName; + + Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, double.class); + Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + + simSetMethod.invoke(joysim, 0.35); + joysim.notifyNewData(); + assertEquals(0.35, (Double) joyGetMethod.invoke(joy), 0.001); + } +} diff --git a/wpilibj/src/generated/test/java/org/wpilib/driverstation/SteamControllerTest.java b/wpilibj/src/generated/test/java/org/wpilib/driverstation/SteamControllerTest.java new file mode 100644 index 0000000000..9d618e0d5a --- /dev/null +++ b/wpilibj/src/generated/test/java/org/wpilib/driverstation/SteamControllerTest.java @@ -0,0 +1,95 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.simulation.SteamControllerSim; + +class SteamControllerTest { + @Test + void testWrappedHID() { + HAL.initialize(500, 0); + SteamController controller = new SteamController(2); + SteamControllerSim sim = new SteamControllerSim(controller); + sim.notifyNewData(); + + assertEquals(2, controller.getPort()); + assertEquals(2, controller.getHID().getPort()); + assertEquals(0x3F, controller.getHID().getAxesAvailable()); + assertEquals(0x3FFFFFFL, controller.getHID().getButtonsAvailable()); + assertEquals(0, controller.getHID().getPOVsAvailable()); + } + + @ParameterizedTest + @EnumSource(value = SteamController.Button.class) + void testButtons(SteamController.Button button) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + SteamController joy = new SteamController(2); + SteamControllerSim joysim = new SteamControllerSim(joy); + + var buttonName = button.toString(); + + String simSetMethodName = "set" + buttonName; + String joyGetMethodName = "get" + buttonName; + String joyPressedMethodName = "get" + buttonName + "Pressed"; + String joyReleasedMethodName = "get" + buttonName + "Released"; + + final Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, boolean.class); + final Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + final Method joyPressedMethod = joy.getClass().getMethod(joyPressedMethodName); + final Method joyReleasedMethod = joy.getClass().getMethod(joyReleasedMethodName); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + joyPressedMethod.invoke(joy); + joyReleasedMethod.invoke(joy); + + simSetMethod.invoke(joysim, true); + joysim.notifyNewData(); + assertTrue((Boolean) joyGetMethod.invoke(joy)); + assertTrue((Boolean) joyPressedMethod.invoke(joy)); + assertFalse((Boolean) joyReleasedMethod.invoke(joy)); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + assertFalse((Boolean) joyPressedMethod.invoke(joy)); + assertTrue((Boolean) joyReleasedMethod.invoke(joy)); + } + + @ParameterizedTest + @EnumSource(value = SteamController.Axis.class) + void testAxes(SteamController.Axis axis) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + SteamController joy = new SteamController(2); + SteamControllerSim joysim = new SteamControllerSim(joy); + + var axisName = axis.toString(); + + String simSetMethodName = "set" + axisName; + String joyGetMethodName = "get" + axisName; + + Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, double.class); + Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + + simSetMethod.invoke(joysim, 0.35); + joysim.notifyNewData(); + assertEquals(0.35, (Double) joyGetMethod.invoke(joy), 0.001); + } +} diff --git a/wpilibj/src/generated/test/java/org/wpilib/driverstation/Switch2GCControllerTest.java b/wpilibj/src/generated/test/java/org/wpilib/driverstation/Switch2GCControllerTest.java new file mode 100644 index 0000000000..4893b48064 --- /dev/null +++ b/wpilibj/src/generated/test/java/org/wpilib/driverstation/Switch2GCControllerTest.java @@ -0,0 +1,95 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.simulation.Switch2GCControllerSim; + +class Switch2GCControllerTest { + @Test + void testWrappedHID() { + HAL.initialize(500, 0); + Switch2GCController controller = new Switch2GCController(2); + Switch2GCControllerSim sim = new Switch2GCControllerSim(controller); + sim.notifyNewData(); + + assertEquals(2, controller.getPort()); + assertEquals(2, controller.getHID().getPort()); + assertEquals(0x3F, controller.getHID().getAxesAvailable()); + assertEquals(0xE0FE6FL, controller.getHID().getButtonsAvailable()); + assertEquals(0, controller.getHID().getPOVsAvailable()); + } + + @ParameterizedTest + @EnumSource(value = Switch2GCController.Button.class) + void testButtons(Switch2GCController.Button button) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + Switch2GCController joy = new Switch2GCController(2); + Switch2GCControllerSim joysim = new Switch2GCControllerSim(joy); + + var buttonName = button.toString(); + + String simSetMethodName = "set" + buttonName; + String joyGetMethodName = "get" + buttonName; + String joyPressedMethodName = "get" + buttonName + "Pressed"; + String joyReleasedMethodName = "get" + buttonName + "Released"; + + final Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, boolean.class); + final Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + final Method joyPressedMethod = joy.getClass().getMethod(joyPressedMethodName); + final Method joyReleasedMethod = joy.getClass().getMethod(joyReleasedMethodName); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + joyPressedMethod.invoke(joy); + joyReleasedMethod.invoke(joy); + + simSetMethod.invoke(joysim, true); + joysim.notifyNewData(); + assertTrue((Boolean) joyGetMethod.invoke(joy)); + assertTrue((Boolean) joyPressedMethod.invoke(joy)); + assertFalse((Boolean) joyReleasedMethod.invoke(joy)); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + assertFalse((Boolean) joyPressedMethod.invoke(joy)); + assertTrue((Boolean) joyReleasedMethod.invoke(joy)); + } + + @ParameterizedTest + @EnumSource(value = Switch2GCController.Axis.class) + void testAxes(Switch2GCController.Axis axis) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + Switch2GCController joy = new Switch2GCController(2); + Switch2GCControllerSim joysim = new Switch2GCControllerSim(joy); + + var axisName = axis.toString(); + + String simSetMethodName = "set" + axisName; + String joyGetMethodName = "get" + axisName; + + Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, double.class); + Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + + simSetMethod.invoke(joysim, 0.35); + joysim.notifyNewData(); + assertEquals(0.35, (Double) joyGetMethod.invoke(joy), 0.001); + } +} diff --git a/wpilibj/src/generated/test/java/org/wpilib/driverstation/Switch2ProControllerTest.java b/wpilibj/src/generated/test/java/org/wpilib/driverstation/Switch2ProControllerTest.java new file mode 100644 index 0000000000..4b7f433043 --- /dev/null +++ b/wpilibj/src/generated/test/java/org/wpilib/driverstation/Switch2ProControllerTest.java @@ -0,0 +1,95 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.simulation.Switch2ProControllerSim; + +class Switch2ProControllerTest { + @Test + void testWrappedHID() { + HAL.initialize(500, 0); + Switch2ProController controller = new Switch2ProController(2); + Switch2ProControllerSim sim = new Switch2ProControllerSim(controller); + sim.notifyNewData(); + + assertEquals(2, controller.getPort()); + assertEquals(2, controller.getHID().getPort()); + assertEquals(0x3F, controller.getHID().getAxesAvailable()); + assertEquals(0x23FFFFL, controller.getHID().getButtonsAvailable()); + assertEquals(0, controller.getHID().getPOVsAvailable()); + } + + @ParameterizedTest + @EnumSource(value = Switch2ProController.Button.class) + void testButtons(Switch2ProController.Button button) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + Switch2ProController joy = new Switch2ProController(2); + Switch2ProControllerSim joysim = new Switch2ProControllerSim(joy); + + var buttonName = button.toString(); + + String simSetMethodName = "set" + buttonName; + String joyGetMethodName = "get" + buttonName; + String joyPressedMethodName = "get" + buttonName + "Pressed"; + String joyReleasedMethodName = "get" + buttonName + "Released"; + + final Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, boolean.class); + final Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + final Method joyPressedMethod = joy.getClass().getMethod(joyPressedMethodName); + final Method joyReleasedMethod = joy.getClass().getMethod(joyReleasedMethodName); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + joyPressedMethod.invoke(joy); + joyReleasedMethod.invoke(joy); + + simSetMethod.invoke(joysim, true); + joysim.notifyNewData(); + assertTrue((Boolean) joyGetMethod.invoke(joy)); + assertTrue((Boolean) joyPressedMethod.invoke(joy)); + assertFalse((Boolean) joyReleasedMethod.invoke(joy)); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + assertFalse((Boolean) joyPressedMethod.invoke(joy)); + assertTrue((Boolean) joyReleasedMethod.invoke(joy)); + } + + @ParameterizedTest + @EnumSource(value = Switch2ProController.Axis.class) + void testAxes(Switch2ProController.Axis axis) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + Switch2ProController joy = new Switch2ProController(2); + Switch2ProControllerSim joysim = new Switch2ProControllerSim(joy); + + var axisName = axis.toString(); + + String simSetMethodName = "set" + axisName; + String joyGetMethodName = "get" + axisName; + + Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, double.class); + Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + + simSetMethod.invoke(joysim, 0.35); + joysim.notifyNewData(); + assertEquals(0.35, (Double) joyGetMethod.invoke(joy), 0.001); + } +} diff --git a/wpilibj/src/generated/test/java/org/wpilib/driverstation/SwitchN64ControllerTest.java b/wpilibj/src/generated/test/java/org/wpilib/driverstation/SwitchN64ControllerTest.java new file mode 100644 index 0000000000..04a3040c6d --- /dev/null +++ b/wpilibj/src/generated/test/java/org/wpilib/driverstation/SwitchN64ControllerTest.java @@ -0,0 +1,95 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.simulation.SwitchN64ControllerSim; + +class SwitchN64ControllerTest { + @Test + void testWrappedHID() { + HAL.initialize(500, 0); + SwitchN64Controller controller = new SwitchN64Controller(2); + SwitchN64ControllerSim sim = new SwitchN64ControllerSim(controller); + sim.notifyNewData(); + + assertEquals(2, controller.getPort()); + assertEquals(2, controller.getHID().getPort()); + assertEquals(0x33, controller.getHID().getAxesAvailable()); + assertEquals(0x20FE7FL, controller.getHID().getButtonsAvailable()); + assertEquals(0, controller.getHID().getPOVsAvailable()); + } + + @ParameterizedTest + @EnumSource(value = SwitchN64Controller.Button.class) + void testButtons(SwitchN64Controller.Button button) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + SwitchN64Controller joy = new SwitchN64Controller(2); + SwitchN64ControllerSim joysim = new SwitchN64ControllerSim(joy); + + var buttonName = button.toString(); + + String simSetMethodName = "set" + buttonName; + String joyGetMethodName = "get" + buttonName; + String joyPressedMethodName = "get" + buttonName + "Pressed"; + String joyReleasedMethodName = "get" + buttonName + "Released"; + + final Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, boolean.class); + final Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + final Method joyPressedMethod = joy.getClass().getMethod(joyPressedMethodName); + final Method joyReleasedMethod = joy.getClass().getMethod(joyReleasedMethodName); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + joyPressedMethod.invoke(joy); + joyReleasedMethod.invoke(joy); + + simSetMethod.invoke(joysim, true); + joysim.notifyNewData(); + assertTrue((Boolean) joyGetMethod.invoke(joy)); + assertTrue((Boolean) joyPressedMethod.invoke(joy)); + assertFalse((Boolean) joyReleasedMethod.invoke(joy)); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + assertFalse((Boolean) joyPressedMethod.invoke(joy)); + assertTrue((Boolean) joyReleasedMethod.invoke(joy)); + } + + @ParameterizedTest + @EnumSource(value = SwitchN64Controller.Axis.class) + void testAxes(SwitchN64Controller.Axis axis) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + SwitchN64Controller joy = new SwitchN64Controller(2); + SwitchN64ControllerSim joysim = new SwitchN64ControllerSim(joy); + + var axisName = axis.toString(); + + String simSetMethodName = "set" + axisName; + String joyGetMethodName = "get" + axisName; + + Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, double.class); + Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + + simSetMethod.invoke(joysim, 0.35); + joysim.notifyNewData(); + assertEquals(0.35, (Double) joyGetMethod.invoke(joy), 0.001); + } +} diff --git a/wpilibj/src/generated/test/java/org/wpilib/driverstation/SwitchProControllerTest.java b/wpilibj/src/generated/test/java/org/wpilib/driverstation/SwitchProControllerTest.java new file mode 100644 index 0000000000..fbbbcb2dc6 --- /dev/null +++ b/wpilibj/src/generated/test/java/org/wpilib/driverstation/SwitchProControllerTest.java @@ -0,0 +1,95 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_first_ds_hids.py. DO NOT MODIFY + +package org.wpilib.driverstation; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.wpilib.hardware.hal.HAL; +import org.wpilib.simulation.SwitchProControllerSim; + +class SwitchProControllerTest { + @Test + void testWrappedHID() { + HAL.initialize(500, 0); + SwitchProController controller = new SwitchProController(2); + SwitchProControllerSim sim = new SwitchProControllerSim(controller); + sim.notifyNewData(); + + assertEquals(2, controller.getPort()); + assertEquals(2, controller.getHID().getPort()); + assertEquals(0x3F, controller.getHID().getAxesAvailable()); + assertEquals(0xFFFFL, controller.getHID().getButtonsAvailable()); + assertEquals(0, controller.getHID().getPOVsAvailable()); + } + + @ParameterizedTest + @EnumSource(value = SwitchProController.Button.class) + void testButtons(SwitchProController.Button button) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + SwitchProController joy = new SwitchProController(2); + SwitchProControllerSim joysim = new SwitchProControllerSim(joy); + + var buttonName = button.toString(); + + String simSetMethodName = "set" + buttonName; + String joyGetMethodName = "get" + buttonName; + String joyPressedMethodName = "get" + buttonName + "Pressed"; + String joyReleasedMethodName = "get" + buttonName + "Released"; + + final Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, boolean.class); + final Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + final Method joyPressedMethod = joy.getClass().getMethod(joyPressedMethodName); + final Method joyReleasedMethod = joy.getClass().getMethod(joyReleasedMethodName); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + joyPressedMethod.invoke(joy); + joyReleasedMethod.invoke(joy); + + simSetMethod.invoke(joysim, true); + joysim.notifyNewData(); + assertTrue((Boolean) joyGetMethod.invoke(joy)); + assertTrue((Boolean) joyPressedMethod.invoke(joy)); + assertFalse((Boolean) joyReleasedMethod.invoke(joy)); + + simSetMethod.invoke(joysim, false); + joysim.notifyNewData(); + assertFalse((Boolean) joyGetMethod.invoke(joy)); + assertFalse((Boolean) joyPressedMethod.invoke(joy)); + assertTrue((Boolean) joyReleasedMethod.invoke(joy)); + } + + @ParameterizedTest + @EnumSource(value = SwitchProController.Axis.class) + void testAxes(SwitchProController.Axis axis) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + HAL.initialize(500, 0); + SwitchProController joy = new SwitchProController(2); + SwitchProControllerSim joysim = new SwitchProControllerSim(joy); + + var axisName = axis.toString(); + + String simSetMethodName = "set" + axisName; + String joyGetMethodName = "get" + axisName; + + Method simSetMethod = joysim.getClass().getMethod(simSetMethodName, double.class); + Method joyGetMethod = joy.getClass().getMethod(joyGetMethodName); + + simSetMethod.invoke(joysim, 0.35); + joysim.notifyNewData(); + assertEquals(0.35, (Double) joyGetMethod.invoke(joy), 0.001); + } +}