[wpilib,cmd] Add new generation for gamepads (#8957)

SDL makes these schemas much simpler, so its easier to support more
controllers.
This commit is contained in:
Thad House
2026-06-11 16:06:45 -07:00
committed by GitHub
parent 025732093f
commit 97381549e6
65 changed files with 12597 additions and 3 deletions

View File

@@ -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 org.wpilib.command3.Scheduler;
import org.wpilib.command3.Trigger;
import org.wpilib.driverstation.DualSenseController;
import org.wpilib.event.EventLoop;
/**
* A version of {@link DualSenseController} with {@link Trigger} factories for command-based.
*
* @see DualSenseController
*/
@SuppressWarnings("MethodName")
public class CommandDualSenseController {
private final CommandGenericHID m_hid;
private final DualSenseController 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 CommandDualSenseController(int port) {
this(Scheduler.getDefault(), port);
}
/**
* 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 CommandDualSenseController(Scheduler scheduler, int port) {
m_hid = CommandGenericHID.getCommandGenericHID(scheduler, port);
m_controller = new DualSenseController(m_hid.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 DualSenseController 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(DualSenseController.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(DualSenseController.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(DualSenseController.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(DualSenseController.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(DualSenseController.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(DualSenseController.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(DualSenseController.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(DualSenseController.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(DualSenseController.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(DualSenseController.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(DualSenseController.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(DualSenseController.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(DualSenseController.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(DualSenseController.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(DualSenseController.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(DualSenseController.Button.MICROPHONE.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(DualSenseController.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(
DualSenseController.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(
DualSenseController.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();
}
}

View File

@@ -0,0 +1,565 @@
// 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 org.wpilib.command3.Scheduler;
import org.wpilib.command3.Trigger;
import org.wpilib.driverstation.XboxController;
import org.wpilib.event.EventLoop;
/**
* A version of {@link XboxController} with {@link Trigger} factories for command-based.
*
* @see XboxController
*/
@SuppressWarnings("MethodName")
public class CommandXboxController {
private final CommandGenericHID m_hid;
private final XboxController 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 CommandXboxController(int port) {
this(Scheduler.getDefault(), port);
}
/**
* 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 CommandXboxController(Scheduler scheduler, int port) {
m_hid = CommandGenericHID.getCommandGenericHID(scheduler, port);
m_controller = new XboxController(m_hid.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 XboxController 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(XboxController.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(XboxController.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(XboxController.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(XboxController.Button.Y.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(XboxController.Button.VIEW.value, loop);
}
/**
* Constructs a Trigger instance around the Xbox button's digital signal.
*
* @return a Trigger instance representing the Xbox 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 #xbox(EventLoop)
*/
public Trigger xbox() {
return xbox(m_hid.getScheduler().getDefaultEventLoop());
}
/**
* Constructs a Trigger instance around the Xbox button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Xbox button's digital signal attached
* to the given loop.
*/
public Trigger xbox(EventLoop loop) {
return m_hid.button(XboxController.Button.XBOX.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(XboxController.Button.MENU.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(XboxController.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(XboxController.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(XboxController.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(XboxController.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(XboxController.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(XboxController.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(XboxController.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(XboxController.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(
XboxController.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(
XboxController.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();
}
}