mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
[wpilib,cmd] Cache HID wrappers (#8970)
Store DriverStation-owned GenericHID and Gamepad instances in Java and C++, and expose the cached objects to Python bindings. Move hand-written command gamepad and joystick wrappers to compose cached CommandGenericHID instances plus typed HID wrappers, including a Python CommandGamepad. This will let us remove UserControls, while helping ensure that we don't have state smashing between GenericHID objects. Another bonus is without inheritance, intellisense will no longer show a bunch of annoying methods, and instead just what actually exists. --------- Co-authored-by: Peter Johnson <johnson.peter@gmail.com>
This commit is contained in:
@@ -6,6 +6,11 @@
|
||||
|
||||
package org.wpilib.driverstation;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
import org.wpilib.driverstation.GenericHID.HIDType;
|
||||
import org.wpilib.driverstation.GenericHID.RumbleType;
|
||||
import org.wpilib.driverstation.GenericHID.SupportedOutput;
|
||||
import org.wpilib.event.BooleanEvent;
|
||||
import org.wpilib.event.EventLoop;
|
||||
import org.wpilib.hardware.hal.HAL;
|
||||
@@ -23,7 +28,7 @@ import org.wpilib.util.sendable.SendableBuilder;
|
||||
* only through the official NI DS. Sim is not guaranteed to have the same mapping, as well as any
|
||||
* 3rd party controllers.
|
||||
*/
|
||||
public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
public class NiDsPS4Controller implements HIDDevice, Sendable {
|
||||
/** Represents a digital button on a NiDsPS4Controller. */
|
||||
public enum Button {
|
||||
/** Square button. */
|
||||
@@ -117,14 +122,35 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
private final GenericHID m_hid;
|
||||
|
||||
/**
|
||||
* Get the underlying GenericHID object.
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
*/
|
||||
@Override
|
||||
public GenericHID getHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
*
|
||||
* @param port The port index on the Driver Station that the controller is plugged into (0-5).
|
||||
*/
|
||||
public NiDsPS4Controller(final int port) {
|
||||
super(port);
|
||||
HAL.reportUsage("HID", port, "NiDsPS4Controller");
|
||||
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 NiDsPS4Controller(final GenericHID hid) {
|
||||
m_hid = Objects.requireNonNull(hid, "Provided HID object cannot be null");
|
||||
HAL.reportUsage("HID", hid.getPort(), "NiDsPS4Controller");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,7 +159,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftX() {
|
||||
return getRawAxis(Axis.kLeftX.value);
|
||||
return m_hid.getRawAxis(Axis.kLeftX.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,7 +168,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftY() {
|
||||
return getRawAxis(Axis.kLeftY.value);
|
||||
return m_hid.getRawAxis(Axis.kLeftY.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,7 +177,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightX() {
|
||||
return getRawAxis(Axis.kRightX.value);
|
||||
return m_hid.getRawAxis(Axis.kRightX.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,7 +186,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightY() {
|
||||
return getRawAxis(Axis.kRightY.value);
|
||||
return m_hid.getRawAxis(Axis.kRightY.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,7 +196,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getL2Axis() {
|
||||
return getRawAxis(Axis.kL2.value);
|
||||
return m_hid.getRawAxis(Axis.kL2.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,7 +206,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getR2Axis() {
|
||||
return getRawAxis(Axis.kR2.value);
|
||||
return m_hid.getRawAxis(Axis.kR2.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,7 +215,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getSquareButton() {
|
||||
return getRawButton(Button.kSquare.value);
|
||||
return m_hid.getRawButton(Button.kSquare.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,7 +224,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getSquareButtonPressed() {
|
||||
return getRawButtonPressed(Button.kSquare.value);
|
||||
return m_hid.getRawButtonPressed(Button.kSquare.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,7 +233,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getSquareButtonReleased() {
|
||||
return getRawButtonReleased(Button.kSquare.value);
|
||||
return m_hid.getRawButtonReleased(Button.kSquare.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,7 +244,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent square(EventLoop loop) {
|
||||
return button(Button.kSquare.value, loop);
|
||||
return m_hid.button(Button.kSquare.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,7 +253,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getCrossButton() {
|
||||
return getRawButton(Button.kCross.value);
|
||||
return m_hid.getRawButton(Button.kCross.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,7 +262,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getCrossButtonPressed() {
|
||||
return getRawButtonPressed(Button.kCross.value);
|
||||
return m_hid.getRawButtonPressed(Button.kCross.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -245,7 +271,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getCrossButtonReleased() {
|
||||
return getRawButtonReleased(Button.kCross.value);
|
||||
return m_hid.getRawButtonReleased(Button.kCross.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,7 +282,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent cross(EventLoop loop) {
|
||||
return button(Button.kCross.value, loop);
|
||||
return m_hid.button(Button.kCross.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -265,7 +291,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getCircleButton() {
|
||||
return getRawButton(Button.kCircle.value);
|
||||
return m_hid.getRawButton(Button.kCircle.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,7 +300,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getCircleButtonPressed() {
|
||||
return getRawButtonPressed(Button.kCircle.value);
|
||||
return m_hid.getRawButtonPressed(Button.kCircle.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,7 +309,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getCircleButtonReleased() {
|
||||
return getRawButtonReleased(Button.kCircle.value);
|
||||
return m_hid.getRawButtonReleased(Button.kCircle.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,7 +320,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent circle(EventLoop loop) {
|
||||
return button(Button.kCircle.value, loop);
|
||||
return m_hid.button(Button.kCircle.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -303,7 +329,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getTriangleButton() {
|
||||
return getRawButton(Button.kTriangle.value);
|
||||
return m_hid.getRawButton(Button.kTriangle.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -312,7 +338,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getTriangleButtonPressed() {
|
||||
return getRawButtonPressed(Button.kTriangle.value);
|
||||
return m_hid.getRawButtonPressed(Button.kTriangle.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,7 +347,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getTriangleButtonReleased() {
|
||||
return getRawButtonReleased(Button.kTriangle.value);
|
||||
return m_hid.getRawButtonReleased(Button.kTriangle.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -332,7 +358,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent triangle(EventLoop loop) {
|
||||
return button(Button.kTriangle.value, loop);
|
||||
return m_hid.button(Button.kTriangle.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,7 +367,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getL1Button() {
|
||||
return getRawButton(Button.kL1.value);
|
||||
return m_hid.getRawButton(Button.kL1.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -350,7 +376,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getL1ButtonPressed() {
|
||||
return getRawButtonPressed(Button.kL1.value);
|
||||
return m_hid.getRawButtonPressed(Button.kL1.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -359,7 +385,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getL1ButtonReleased() {
|
||||
return getRawButtonReleased(Button.kL1.value);
|
||||
return m_hid.getRawButtonReleased(Button.kL1.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -370,7 +396,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent L1(EventLoop loop) {
|
||||
return button(Button.kL1.value, loop);
|
||||
return m_hid.button(Button.kL1.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -379,7 +405,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getR1Button() {
|
||||
return getRawButton(Button.kR1.value);
|
||||
return m_hid.getRawButton(Button.kR1.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,7 +414,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getR1ButtonPressed() {
|
||||
return getRawButtonPressed(Button.kR1.value);
|
||||
return m_hid.getRawButtonPressed(Button.kR1.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -397,7 +423,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getR1ButtonReleased() {
|
||||
return getRawButtonReleased(Button.kR1.value);
|
||||
return m_hid.getRawButtonReleased(Button.kR1.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -408,7 +434,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent R1(EventLoop loop) {
|
||||
return button(Button.kR1.value, loop);
|
||||
return m_hid.button(Button.kR1.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -417,7 +443,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getL2Button() {
|
||||
return getRawButton(Button.kL2.value);
|
||||
return m_hid.getRawButton(Button.kL2.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -426,7 +452,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getL2ButtonPressed() {
|
||||
return getRawButtonPressed(Button.kL2.value);
|
||||
return m_hid.getRawButtonPressed(Button.kL2.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -435,7 +461,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getL2ButtonReleased() {
|
||||
return getRawButtonReleased(Button.kL2.value);
|
||||
return m_hid.getRawButtonReleased(Button.kL2.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -446,7 +472,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent L2(EventLoop loop) {
|
||||
return button(Button.kL2.value, loop);
|
||||
return m_hid.button(Button.kL2.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -455,7 +481,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getR2Button() {
|
||||
return getRawButton(Button.kR2.value);
|
||||
return m_hid.getRawButton(Button.kR2.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -464,7 +490,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getR2ButtonPressed() {
|
||||
return getRawButtonPressed(Button.kR2.value);
|
||||
return m_hid.getRawButtonPressed(Button.kR2.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -473,7 +499,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getR2ButtonReleased() {
|
||||
return getRawButtonReleased(Button.kR2.value);
|
||||
return m_hid.getRawButtonReleased(Button.kR2.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -484,7 +510,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent R2(EventLoop loop) {
|
||||
return button(Button.kR2.value, loop);
|
||||
return m_hid.button(Button.kR2.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -493,7 +519,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getShareButton() {
|
||||
return getRawButton(Button.kShare.value);
|
||||
return m_hid.getRawButton(Button.kShare.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -502,7 +528,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getShareButtonPressed() {
|
||||
return getRawButtonPressed(Button.kShare.value);
|
||||
return m_hid.getRawButtonPressed(Button.kShare.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -511,7 +537,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getShareButtonReleased() {
|
||||
return getRawButtonReleased(Button.kShare.value);
|
||||
return m_hid.getRawButtonReleased(Button.kShare.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -522,7 +548,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent share(EventLoop loop) {
|
||||
return button(Button.kShare.value, loop);
|
||||
return m_hid.button(Button.kShare.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -531,7 +557,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getOptionsButton() {
|
||||
return getRawButton(Button.kOptions.value);
|
||||
return m_hid.getRawButton(Button.kOptions.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -540,7 +566,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getOptionsButtonPressed() {
|
||||
return getRawButtonPressed(Button.kOptions.value);
|
||||
return m_hid.getRawButtonPressed(Button.kOptions.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -549,7 +575,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getOptionsButtonReleased() {
|
||||
return getRawButtonReleased(Button.kOptions.value);
|
||||
return m_hid.getRawButtonReleased(Button.kOptions.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -560,7 +586,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent options(EventLoop loop) {
|
||||
return button(Button.kOptions.value, loop);
|
||||
return m_hid.button(Button.kOptions.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -569,7 +595,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getL3Button() {
|
||||
return getRawButton(Button.kL3.value);
|
||||
return m_hid.getRawButton(Button.kL3.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -578,7 +604,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getL3ButtonPressed() {
|
||||
return getRawButtonPressed(Button.kL3.value);
|
||||
return m_hid.getRawButtonPressed(Button.kL3.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -587,7 +613,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getL3ButtonReleased() {
|
||||
return getRawButtonReleased(Button.kL3.value);
|
||||
return m_hid.getRawButtonReleased(Button.kL3.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -598,7 +624,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent L3(EventLoop loop) {
|
||||
return button(Button.kL3.value, loop);
|
||||
return m_hid.button(Button.kL3.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -607,7 +633,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getR3Button() {
|
||||
return getRawButton(Button.kR3.value);
|
||||
return m_hid.getRawButton(Button.kR3.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -616,7 +642,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getR3ButtonPressed() {
|
||||
return getRawButtonPressed(Button.kR3.value);
|
||||
return m_hid.getRawButtonPressed(Button.kR3.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -625,7 +651,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getR3ButtonReleased() {
|
||||
return getRawButtonReleased(Button.kR3.value);
|
||||
return m_hid.getRawButtonReleased(Button.kR3.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -636,7 +662,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent R3(EventLoop loop) {
|
||||
return button(Button.kR3.value, loop);
|
||||
return m_hid.button(Button.kR3.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -645,7 +671,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getPSButton() {
|
||||
return getRawButton(Button.kPS.value);
|
||||
return m_hid.getRawButton(Button.kPS.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -654,7 +680,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getPSButtonPressed() {
|
||||
return getRawButtonPressed(Button.kPS.value);
|
||||
return m_hid.getRawButtonPressed(Button.kPS.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -663,7 +689,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getPSButtonReleased() {
|
||||
return getRawButtonReleased(Button.kPS.value);
|
||||
return m_hid.getRawButtonReleased(Button.kPS.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -674,7 +700,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent PS(EventLoop loop) {
|
||||
return button(Button.kPS.value, loop);
|
||||
return m_hid.button(Button.kPS.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -683,7 +709,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getTouchpadButton() {
|
||||
return getRawButton(Button.kTouchpad.value);
|
||||
return m_hid.getRawButton(Button.kTouchpad.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -692,7 +718,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getTouchpadButtonPressed() {
|
||||
return getRawButtonPressed(Button.kTouchpad.value);
|
||||
return m_hid.getRawButtonPressed(Button.kTouchpad.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -701,7 +727,7 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getTouchpadButtonReleased() {
|
||||
return getRawButtonReleased(Button.kTouchpad.value);
|
||||
return m_hid.getRawButtonReleased(Button.kTouchpad.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -712,7 +738,65 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent touchpad(EventLoop loop) {
|
||||
return button(Button.kTouchpad.value, loop);
|
||||
return m_hid.button(Button.kTouchpad.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if the controller is connected.
|
||||
*
|
||||
* @return true if the controller is connected
|
||||
*/
|
||||
public boolean isConnected() {
|
||||
return m_hid.isConnected();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of the controller.
|
||||
*
|
||||
* @return the type of the controller.
|
||||
*/
|
||||
public HIDType getGamepadType() {
|
||||
return m_hid.getGamepadType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the supported outputs of the controller.
|
||||
*
|
||||
* @return the supported outputs of the controller.
|
||||
*/
|
||||
public EnumSet<SupportedOutput> getSupportedOutputs() {
|
||||
return m_hid.getSupportedOutputs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the controller.
|
||||
*
|
||||
* @return the name of the controller.
|
||||
*/
|
||||
public String getName() {
|
||||
return m_hid.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the port number of the controller.
|
||||
*
|
||||
* @return The port number of the controller.
|
||||
*/
|
||||
public int getPort() {
|
||||
return m_hid.getPort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the rumble output for the HID.
|
||||
*
|
||||
* <p>The DS currently supports 4 rumble values: left rumble, right rumble, left trigger rumble,
|
||||
* and right trigger rumble.
|
||||
*
|
||||
* @param type Which rumble value to set
|
||||
* @param value The normalized value (0 to 1) to set the rumble to
|
||||
*/
|
||||
public void setRumble(RumbleType type, double value) {
|
||||
m_hid.setRumble(type, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
|
||||
package org.wpilib.driverstation;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
import org.wpilib.driverstation.GenericHID.HIDType;
|
||||
import org.wpilib.driverstation.GenericHID.RumbleType;
|
||||
import org.wpilib.driverstation.GenericHID.SupportedOutput;
|
||||
import org.wpilib.event.BooleanEvent;
|
||||
import org.wpilib.event.EventLoop;
|
||||
import org.wpilib.hardware.hal.HAL;
|
||||
@@ -23,7 +28,7 @@ import org.wpilib.util.sendable.SendableBuilder;
|
||||
* only through the official NI DS. Sim is not guaranteed to have the same mapping, as well as any
|
||||
* 3rd party controllers.
|
||||
*/
|
||||
public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
public class NiDsPS5Controller implements HIDDevice, Sendable {
|
||||
/** Represents a digital button on a NiDsPS5Controller. */
|
||||
public enum Button {
|
||||
/** Square button. */
|
||||
@@ -117,14 +122,35 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
private final GenericHID m_hid;
|
||||
|
||||
/**
|
||||
* Get the underlying GenericHID object.
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
*/
|
||||
@Override
|
||||
public GenericHID getHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
*
|
||||
* @param port The port index on the Driver Station that the controller is plugged into (0-5).
|
||||
*/
|
||||
public NiDsPS5Controller(final int port) {
|
||||
super(port);
|
||||
HAL.reportUsage("HID", port, "NiDsPS5Controller");
|
||||
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 NiDsPS5Controller(final GenericHID hid) {
|
||||
m_hid = Objects.requireNonNull(hid, "Provided HID object cannot be null");
|
||||
HAL.reportUsage("HID", hid.getPort(), "NiDsPS5Controller");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,7 +159,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftX() {
|
||||
return getRawAxis(Axis.kLeftX.value);
|
||||
return m_hid.getRawAxis(Axis.kLeftX.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,7 +168,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftY() {
|
||||
return getRawAxis(Axis.kLeftY.value);
|
||||
return m_hid.getRawAxis(Axis.kLeftY.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,7 +177,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightX() {
|
||||
return getRawAxis(Axis.kRightX.value);
|
||||
return m_hid.getRawAxis(Axis.kRightX.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,7 +186,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightY() {
|
||||
return getRawAxis(Axis.kRightY.value);
|
||||
return m_hid.getRawAxis(Axis.kRightY.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,7 +196,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getL2Axis() {
|
||||
return getRawAxis(Axis.kL2.value);
|
||||
return m_hid.getRawAxis(Axis.kL2.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,7 +206,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getR2Axis() {
|
||||
return getRawAxis(Axis.kR2.value);
|
||||
return m_hid.getRawAxis(Axis.kR2.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,7 +215,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getSquareButton() {
|
||||
return getRawButton(Button.kSquare.value);
|
||||
return m_hid.getRawButton(Button.kSquare.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,7 +224,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getSquareButtonPressed() {
|
||||
return getRawButtonPressed(Button.kSquare.value);
|
||||
return m_hid.getRawButtonPressed(Button.kSquare.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,7 +233,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getSquareButtonReleased() {
|
||||
return getRawButtonReleased(Button.kSquare.value);
|
||||
return m_hid.getRawButtonReleased(Button.kSquare.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,7 +244,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent square(EventLoop loop) {
|
||||
return button(Button.kSquare.value, loop);
|
||||
return m_hid.button(Button.kSquare.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,7 +253,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getCrossButton() {
|
||||
return getRawButton(Button.kCross.value);
|
||||
return m_hid.getRawButton(Button.kCross.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,7 +262,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getCrossButtonPressed() {
|
||||
return getRawButtonPressed(Button.kCross.value);
|
||||
return m_hid.getRawButtonPressed(Button.kCross.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -245,7 +271,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getCrossButtonReleased() {
|
||||
return getRawButtonReleased(Button.kCross.value);
|
||||
return m_hid.getRawButtonReleased(Button.kCross.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,7 +282,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent cross(EventLoop loop) {
|
||||
return button(Button.kCross.value, loop);
|
||||
return m_hid.button(Button.kCross.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -265,7 +291,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getCircleButton() {
|
||||
return getRawButton(Button.kCircle.value);
|
||||
return m_hid.getRawButton(Button.kCircle.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,7 +300,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getCircleButtonPressed() {
|
||||
return getRawButtonPressed(Button.kCircle.value);
|
||||
return m_hid.getRawButtonPressed(Button.kCircle.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,7 +309,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getCircleButtonReleased() {
|
||||
return getRawButtonReleased(Button.kCircle.value);
|
||||
return m_hid.getRawButtonReleased(Button.kCircle.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,7 +320,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent circle(EventLoop loop) {
|
||||
return button(Button.kCircle.value, loop);
|
||||
return m_hid.button(Button.kCircle.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -303,7 +329,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getTriangleButton() {
|
||||
return getRawButton(Button.kTriangle.value);
|
||||
return m_hid.getRawButton(Button.kTriangle.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -312,7 +338,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getTriangleButtonPressed() {
|
||||
return getRawButtonPressed(Button.kTriangle.value);
|
||||
return m_hid.getRawButtonPressed(Button.kTriangle.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,7 +347,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getTriangleButtonReleased() {
|
||||
return getRawButtonReleased(Button.kTriangle.value);
|
||||
return m_hid.getRawButtonReleased(Button.kTriangle.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -332,7 +358,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent triangle(EventLoop loop) {
|
||||
return button(Button.kTriangle.value, loop);
|
||||
return m_hid.button(Button.kTriangle.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,7 +367,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getL1Button() {
|
||||
return getRawButton(Button.kL1.value);
|
||||
return m_hid.getRawButton(Button.kL1.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -350,7 +376,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getL1ButtonPressed() {
|
||||
return getRawButtonPressed(Button.kL1.value);
|
||||
return m_hid.getRawButtonPressed(Button.kL1.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -359,7 +385,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getL1ButtonReleased() {
|
||||
return getRawButtonReleased(Button.kL1.value);
|
||||
return m_hid.getRawButtonReleased(Button.kL1.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -370,7 +396,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent L1(EventLoop loop) {
|
||||
return button(Button.kL1.value, loop);
|
||||
return m_hid.button(Button.kL1.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -379,7 +405,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getR1Button() {
|
||||
return getRawButton(Button.kR1.value);
|
||||
return m_hid.getRawButton(Button.kR1.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,7 +414,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getR1ButtonPressed() {
|
||||
return getRawButtonPressed(Button.kR1.value);
|
||||
return m_hid.getRawButtonPressed(Button.kR1.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -397,7 +423,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getR1ButtonReleased() {
|
||||
return getRawButtonReleased(Button.kR1.value);
|
||||
return m_hid.getRawButtonReleased(Button.kR1.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -408,7 +434,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent R1(EventLoop loop) {
|
||||
return button(Button.kR1.value, loop);
|
||||
return m_hid.button(Button.kR1.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -417,7 +443,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getL2Button() {
|
||||
return getRawButton(Button.kL2.value);
|
||||
return m_hid.getRawButton(Button.kL2.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -426,7 +452,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getL2ButtonPressed() {
|
||||
return getRawButtonPressed(Button.kL2.value);
|
||||
return m_hid.getRawButtonPressed(Button.kL2.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -435,7 +461,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getL2ButtonReleased() {
|
||||
return getRawButtonReleased(Button.kL2.value);
|
||||
return m_hid.getRawButtonReleased(Button.kL2.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -446,7 +472,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent L2(EventLoop loop) {
|
||||
return button(Button.kL2.value, loop);
|
||||
return m_hid.button(Button.kL2.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -455,7 +481,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getR2Button() {
|
||||
return getRawButton(Button.kR2.value);
|
||||
return m_hid.getRawButton(Button.kR2.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -464,7 +490,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getR2ButtonPressed() {
|
||||
return getRawButtonPressed(Button.kR2.value);
|
||||
return m_hid.getRawButtonPressed(Button.kR2.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -473,7 +499,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getR2ButtonReleased() {
|
||||
return getRawButtonReleased(Button.kR2.value);
|
||||
return m_hid.getRawButtonReleased(Button.kR2.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -484,7 +510,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent R2(EventLoop loop) {
|
||||
return button(Button.kR2.value, loop);
|
||||
return m_hid.button(Button.kR2.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -493,7 +519,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getCreateButton() {
|
||||
return getRawButton(Button.kCreate.value);
|
||||
return m_hid.getRawButton(Button.kCreate.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -502,7 +528,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getCreateButtonPressed() {
|
||||
return getRawButtonPressed(Button.kCreate.value);
|
||||
return m_hid.getRawButtonPressed(Button.kCreate.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -511,7 +537,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getCreateButtonReleased() {
|
||||
return getRawButtonReleased(Button.kCreate.value);
|
||||
return m_hid.getRawButtonReleased(Button.kCreate.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -522,7 +548,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent create(EventLoop loop) {
|
||||
return button(Button.kCreate.value, loop);
|
||||
return m_hid.button(Button.kCreate.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -531,7 +557,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getOptionsButton() {
|
||||
return getRawButton(Button.kOptions.value);
|
||||
return m_hid.getRawButton(Button.kOptions.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -540,7 +566,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getOptionsButtonPressed() {
|
||||
return getRawButtonPressed(Button.kOptions.value);
|
||||
return m_hid.getRawButtonPressed(Button.kOptions.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -549,7 +575,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getOptionsButtonReleased() {
|
||||
return getRawButtonReleased(Button.kOptions.value);
|
||||
return m_hid.getRawButtonReleased(Button.kOptions.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -560,7 +586,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent options(EventLoop loop) {
|
||||
return button(Button.kOptions.value, loop);
|
||||
return m_hid.button(Button.kOptions.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -569,7 +595,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getL3Button() {
|
||||
return getRawButton(Button.kL3.value);
|
||||
return m_hid.getRawButton(Button.kL3.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -578,7 +604,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getL3ButtonPressed() {
|
||||
return getRawButtonPressed(Button.kL3.value);
|
||||
return m_hid.getRawButtonPressed(Button.kL3.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -587,7 +613,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getL3ButtonReleased() {
|
||||
return getRawButtonReleased(Button.kL3.value);
|
||||
return m_hid.getRawButtonReleased(Button.kL3.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -598,7 +624,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent L3(EventLoop loop) {
|
||||
return button(Button.kL3.value, loop);
|
||||
return m_hid.button(Button.kL3.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -607,7 +633,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getR3Button() {
|
||||
return getRawButton(Button.kR3.value);
|
||||
return m_hid.getRawButton(Button.kR3.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -616,7 +642,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getR3ButtonPressed() {
|
||||
return getRawButtonPressed(Button.kR3.value);
|
||||
return m_hid.getRawButtonPressed(Button.kR3.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -625,7 +651,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getR3ButtonReleased() {
|
||||
return getRawButtonReleased(Button.kR3.value);
|
||||
return m_hid.getRawButtonReleased(Button.kR3.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -636,7 +662,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent R3(EventLoop loop) {
|
||||
return button(Button.kR3.value, loop);
|
||||
return m_hid.button(Button.kR3.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -645,7 +671,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getPSButton() {
|
||||
return getRawButton(Button.kPS.value);
|
||||
return m_hid.getRawButton(Button.kPS.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -654,7 +680,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getPSButtonPressed() {
|
||||
return getRawButtonPressed(Button.kPS.value);
|
||||
return m_hid.getRawButtonPressed(Button.kPS.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -663,7 +689,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getPSButtonReleased() {
|
||||
return getRawButtonReleased(Button.kPS.value);
|
||||
return m_hid.getRawButtonReleased(Button.kPS.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -674,7 +700,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent PS(EventLoop loop) {
|
||||
return button(Button.kPS.value, loop);
|
||||
return m_hid.button(Button.kPS.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -683,7 +709,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getTouchpadButton() {
|
||||
return getRawButton(Button.kTouchpad.value);
|
||||
return m_hid.getRawButton(Button.kTouchpad.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -692,7 +718,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getTouchpadButtonPressed() {
|
||||
return getRawButtonPressed(Button.kTouchpad.value);
|
||||
return m_hid.getRawButtonPressed(Button.kTouchpad.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -701,7 +727,7 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getTouchpadButtonReleased() {
|
||||
return getRawButtonReleased(Button.kTouchpad.value);
|
||||
return m_hid.getRawButtonReleased(Button.kTouchpad.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -712,7 +738,65 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent touchpad(EventLoop loop) {
|
||||
return button(Button.kTouchpad.value, loop);
|
||||
return m_hid.button(Button.kTouchpad.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if the controller is connected.
|
||||
*
|
||||
* @return true if the controller is connected
|
||||
*/
|
||||
public boolean isConnected() {
|
||||
return m_hid.isConnected();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of the controller.
|
||||
*
|
||||
* @return the type of the controller.
|
||||
*/
|
||||
public HIDType getGamepadType() {
|
||||
return m_hid.getGamepadType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the supported outputs of the controller.
|
||||
*
|
||||
* @return the supported outputs of the controller.
|
||||
*/
|
||||
public EnumSet<SupportedOutput> getSupportedOutputs() {
|
||||
return m_hid.getSupportedOutputs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the controller.
|
||||
*
|
||||
* @return the name of the controller.
|
||||
*/
|
||||
public String getName() {
|
||||
return m_hid.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the port number of the controller.
|
||||
*
|
||||
* @return The port number of the controller.
|
||||
*/
|
||||
public int getPort() {
|
||||
return m_hid.getPort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the rumble output for the HID.
|
||||
*
|
||||
* <p>The DS currently supports 4 rumble values: left rumble, right rumble, left trigger rumble,
|
||||
* and right trigger rumble.
|
||||
*
|
||||
* @param type Which rumble value to set
|
||||
* @param value The normalized value (0 to 1) to set the rumble to
|
||||
*/
|
||||
public void setRumble(RumbleType type, double value) {
|
||||
m_hid.setRumble(type, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
|
||||
package org.wpilib.driverstation;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
import org.wpilib.driverstation.GenericHID.HIDType;
|
||||
import org.wpilib.driverstation.GenericHID.RumbleType;
|
||||
import org.wpilib.driverstation.GenericHID.SupportedOutput;
|
||||
import org.wpilib.event.BooleanEvent;
|
||||
import org.wpilib.event.EventLoop;
|
||||
import org.wpilib.hardware.hal.HAL;
|
||||
@@ -23,7 +28,7 @@ import org.wpilib.util.sendable.SendableBuilder;
|
||||
* only through the official NI DS. Sim is not guaranteed to have the same mapping, as well as any
|
||||
* 3rd party controllers.
|
||||
*/
|
||||
public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
public class NiDsStadiaController implements HIDDevice, Sendable {
|
||||
/** Represents a digital button on a NiDsStadiaController. */
|
||||
public enum Button {
|
||||
/** A button. */
|
||||
@@ -115,14 +120,35 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
private final GenericHID m_hid;
|
||||
|
||||
/**
|
||||
* Get the underlying GenericHID object.
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
*/
|
||||
@Override
|
||||
public GenericHID getHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
*
|
||||
* @param port The port index on the Driver Station that the controller is plugged into (0-5).
|
||||
*/
|
||||
public NiDsStadiaController(final int port) {
|
||||
super(port);
|
||||
HAL.reportUsage("HID", port, "NiDsStadiaController");
|
||||
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 NiDsStadiaController(final GenericHID hid) {
|
||||
m_hid = Objects.requireNonNull(hid, "Provided HID object cannot be null");
|
||||
HAL.reportUsage("HID", hid.getPort(), "NiDsStadiaController");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +157,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftX() {
|
||||
return getRawAxis(Axis.kLeftX.value);
|
||||
return m_hid.getRawAxis(Axis.kLeftX.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,7 +166,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightX() {
|
||||
return getRawAxis(Axis.kRightX.value);
|
||||
return m_hid.getRawAxis(Axis.kRightX.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,7 +175,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftY() {
|
||||
return getRawAxis(Axis.kLeftY.value);
|
||||
return m_hid.getRawAxis(Axis.kLeftY.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,7 +184,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightY() {
|
||||
return getRawAxis(Axis.kRightY.value);
|
||||
return m_hid.getRawAxis(Axis.kRightY.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +193,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getAButton() {
|
||||
return getRawButton(Button.kA.value);
|
||||
return m_hid.getRawButton(Button.kA.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,7 +202,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getAButtonPressed() {
|
||||
return getRawButtonPressed(Button.kA.value);
|
||||
return m_hid.getRawButtonPressed(Button.kA.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,7 +211,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getAButtonReleased() {
|
||||
return getRawButtonReleased(Button.kA.value);
|
||||
return m_hid.getRawButtonReleased(Button.kA.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,7 +222,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent a(EventLoop loop) {
|
||||
return button(Button.kA.value, loop);
|
||||
return m_hid.button(Button.kA.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +231,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getBButton() {
|
||||
return getRawButton(Button.kB.value);
|
||||
return m_hid.getRawButton(Button.kB.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,7 +240,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getBButtonPressed() {
|
||||
return getRawButtonPressed(Button.kB.value);
|
||||
return m_hid.getRawButtonPressed(Button.kB.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,7 +249,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getBButtonReleased() {
|
||||
return getRawButtonReleased(Button.kB.value);
|
||||
return m_hid.getRawButtonReleased(Button.kB.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,7 +260,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent b(EventLoop loop) {
|
||||
return button(Button.kB.value, loop);
|
||||
return m_hid.button(Button.kB.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,7 +269,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getXButton() {
|
||||
return getRawButton(Button.kX.value);
|
||||
return m_hid.getRawButton(Button.kX.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,7 +278,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getXButtonPressed() {
|
||||
return getRawButtonPressed(Button.kX.value);
|
||||
return m_hid.getRawButtonPressed(Button.kX.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,7 +287,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getXButtonReleased() {
|
||||
return getRawButtonReleased(Button.kX.value);
|
||||
return m_hid.getRawButtonReleased(Button.kX.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -272,7 +298,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent x(EventLoop loop) {
|
||||
return button(Button.kX.value, loop);
|
||||
return m_hid.button(Button.kX.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -281,7 +307,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getYButton() {
|
||||
return getRawButton(Button.kY.value);
|
||||
return m_hid.getRawButton(Button.kY.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,7 +316,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getYButtonPressed() {
|
||||
return getRawButtonPressed(Button.kY.value);
|
||||
return m_hid.getRawButtonPressed(Button.kY.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -299,7 +325,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getYButtonReleased() {
|
||||
return getRawButtonReleased(Button.kY.value);
|
||||
return m_hid.getRawButtonReleased(Button.kY.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -310,7 +336,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent y(EventLoop loop) {
|
||||
return button(Button.kY.value, loop);
|
||||
return m_hid.button(Button.kY.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,7 +345,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getLeftBumperButton() {
|
||||
return getRawButton(Button.kLeftBumper.value);
|
||||
return m_hid.getRawButton(Button.kLeftBumper.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -328,7 +354,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getLeftBumperButtonPressed() {
|
||||
return getRawButtonPressed(Button.kLeftBumper.value);
|
||||
return m_hid.getRawButtonPressed(Button.kLeftBumper.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,7 +363,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getLeftBumperButtonReleased() {
|
||||
return getRawButtonReleased(Button.kLeftBumper.value);
|
||||
return m_hid.getRawButtonReleased(Button.kLeftBumper.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,7 +374,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent leftBumper(EventLoop loop) {
|
||||
return button(Button.kLeftBumper.value, loop);
|
||||
return m_hid.button(Button.kLeftBumper.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -357,7 +383,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getRightBumperButton() {
|
||||
return getRawButton(Button.kRightBumper.value);
|
||||
return m_hid.getRawButton(Button.kRightBumper.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -366,7 +392,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getRightBumperButtonPressed() {
|
||||
return getRawButtonPressed(Button.kRightBumper.value);
|
||||
return m_hid.getRawButtonPressed(Button.kRightBumper.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -375,7 +401,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getRightBumperButtonReleased() {
|
||||
return getRawButtonReleased(Button.kRightBumper.value);
|
||||
return m_hid.getRawButtonReleased(Button.kRightBumper.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -386,7 +412,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent rightBumper(EventLoop loop) {
|
||||
return button(Button.kRightBumper.value, loop);
|
||||
return m_hid.button(Button.kRightBumper.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -395,7 +421,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getLeftStickButton() {
|
||||
return getRawButton(Button.kLeftStick.value);
|
||||
return m_hid.getRawButton(Button.kLeftStick.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -404,7 +430,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getLeftStickButtonPressed() {
|
||||
return getRawButtonPressed(Button.kLeftStick.value);
|
||||
return m_hid.getRawButtonPressed(Button.kLeftStick.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -413,7 +439,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getLeftStickButtonReleased() {
|
||||
return getRawButtonReleased(Button.kLeftStick.value);
|
||||
return m_hid.getRawButtonReleased(Button.kLeftStick.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -424,7 +450,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent leftStick(EventLoop loop) {
|
||||
return button(Button.kLeftStick.value, loop);
|
||||
return m_hid.button(Button.kLeftStick.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -433,7 +459,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getRightStickButton() {
|
||||
return getRawButton(Button.kRightStick.value);
|
||||
return m_hid.getRawButton(Button.kRightStick.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -442,7 +468,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getRightStickButtonPressed() {
|
||||
return getRawButtonPressed(Button.kRightStick.value);
|
||||
return m_hid.getRawButtonPressed(Button.kRightStick.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -451,7 +477,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getRightStickButtonReleased() {
|
||||
return getRawButtonReleased(Button.kRightStick.value);
|
||||
return m_hid.getRawButtonReleased(Button.kRightStick.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -462,7 +488,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent rightStick(EventLoop loop) {
|
||||
return button(Button.kRightStick.value, loop);
|
||||
return m_hid.button(Button.kRightStick.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -471,7 +497,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getEllipsesButton() {
|
||||
return getRawButton(Button.kEllipses.value);
|
||||
return m_hid.getRawButton(Button.kEllipses.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -480,7 +506,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getEllipsesButtonPressed() {
|
||||
return getRawButtonPressed(Button.kEllipses.value);
|
||||
return m_hid.getRawButtonPressed(Button.kEllipses.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -489,7 +515,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getEllipsesButtonReleased() {
|
||||
return getRawButtonReleased(Button.kEllipses.value);
|
||||
return m_hid.getRawButtonReleased(Button.kEllipses.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -500,7 +526,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent ellipses(EventLoop loop) {
|
||||
return button(Button.kEllipses.value, loop);
|
||||
return m_hid.button(Button.kEllipses.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -509,7 +535,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getHamburgerButton() {
|
||||
return getRawButton(Button.kHamburger.value);
|
||||
return m_hid.getRawButton(Button.kHamburger.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -518,7 +544,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getHamburgerButtonPressed() {
|
||||
return getRawButtonPressed(Button.kHamburger.value);
|
||||
return m_hid.getRawButtonPressed(Button.kHamburger.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -527,7 +553,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getHamburgerButtonReleased() {
|
||||
return getRawButtonReleased(Button.kHamburger.value);
|
||||
return m_hid.getRawButtonReleased(Button.kHamburger.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -538,7 +564,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent hamburger(EventLoop loop) {
|
||||
return button(Button.kHamburger.value, loop);
|
||||
return m_hid.button(Button.kHamburger.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -547,7 +573,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getStadiaButton() {
|
||||
return getRawButton(Button.kStadia.value);
|
||||
return m_hid.getRawButton(Button.kStadia.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -556,7 +582,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getStadiaButtonPressed() {
|
||||
return getRawButtonPressed(Button.kStadia.value);
|
||||
return m_hid.getRawButtonPressed(Button.kStadia.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -565,7 +591,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getStadiaButtonReleased() {
|
||||
return getRawButtonReleased(Button.kStadia.value);
|
||||
return m_hid.getRawButtonReleased(Button.kStadia.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -576,7 +602,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent stadia(EventLoop loop) {
|
||||
return button(Button.kStadia.value, loop);
|
||||
return m_hid.button(Button.kStadia.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -585,7 +611,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getRightTriggerButton() {
|
||||
return getRawButton(Button.kRightTrigger.value);
|
||||
return m_hid.getRawButton(Button.kRightTrigger.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -594,7 +620,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getRightTriggerButtonPressed() {
|
||||
return getRawButtonPressed(Button.kRightTrigger.value);
|
||||
return m_hid.getRawButtonPressed(Button.kRightTrigger.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -603,7 +629,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getRightTriggerButtonReleased() {
|
||||
return getRawButtonReleased(Button.kRightTrigger.value);
|
||||
return m_hid.getRawButtonReleased(Button.kRightTrigger.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -614,7 +640,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent rightTrigger(EventLoop loop) {
|
||||
return button(Button.kRightTrigger.value, loop);
|
||||
return m_hid.button(Button.kRightTrigger.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -623,7 +649,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getLeftTriggerButton() {
|
||||
return getRawButton(Button.kLeftTrigger.value);
|
||||
return m_hid.getRawButton(Button.kLeftTrigger.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -632,7 +658,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getLeftTriggerButtonPressed() {
|
||||
return getRawButtonPressed(Button.kLeftTrigger.value);
|
||||
return m_hid.getRawButtonPressed(Button.kLeftTrigger.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -641,7 +667,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getLeftTriggerButtonReleased() {
|
||||
return getRawButtonReleased(Button.kLeftTrigger.value);
|
||||
return m_hid.getRawButtonReleased(Button.kLeftTrigger.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -652,7 +678,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent leftTrigger(EventLoop loop) {
|
||||
return button(Button.kLeftTrigger.value, loop);
|
||||
return m_hid.button(Button.kLeftTrigger.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -661,7 +687,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getGoogleButton() {
|
||||
return getRawButton(Button.kGoogle.value);
|
||||
return m_hid.getRawButton(Button.kGoogle.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -670,7 +696,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getGoogleButtonPressed() {
|
||||
return getRawButtonPressed(Button.kGoogle.value);
|
||||
return m_hid.getRawButtonPressed(Button.kGoogle.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -679,7 +705,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getGoogleButtonReleased() {
|
||||
return getRawButtonReleased(Button.kGoogle.value);
|
||||
return m_hid.getRawButtonReleased(Button.kGoogle.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -690,7 +716,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent google(EventLoop loop) {
|
||||
return button(Button.kGoogle.value, loop);
|
||||
return m_hid.button(Button.kGoogle.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -699,7 +725,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getFrameButton() {
|
||||
return getRawButton(Button.kFrame.value);
|
||||
return m_hid.getRawButton(Button.kFrame.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -708,7 +734,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getFrameButtonPressed() {
|
||||
return getRawButtonPressed(Button.kFrame.value);
|
||||
return m_hid.getRawButtonPressed(Button.kFrame.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -717,7 +743,7 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getFrameButtonReleased() {
|
||||
return getRawButtonReleased(Button.kFrame.value);
|
||||
return m_hid.getRawButtonReleased(Button.kFrame.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -728,7 +754,65 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent frame(EventLoop loop) {
|
||||
return button(Button.kFrame.value, loop);
|
||||
return m_hid.button(Button.kFrame.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if the controller is connected.
|
||||
*
|
||||
* @return true if the controller is connected
|
||||
*/
|
||||
public boolean isConnected() {
|
||||
return m_hid.isConnected();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of the controller.
|
||||
*
|
||||
* @return the type of the controller.
|
||||
*/
|
||||
public HIDType getGamepadType() {
|
||||
return m_hid.getGamepadType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the supported outputs of the controller.
|
||||
*
|
||||
* @return the supported outputs of the controller.
|
||||
*/
|
||||
public EnumSet<SupportedOutput> getSupportedOutputs() {
|
||||
return m_hid.getSupportedOutputs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the controller.
|
||||
*
|
||||
* @return the name of the controller.
|
||||
*/
|
||||
public String getName() {
|
||||
return m_hid.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the port number of the controller.
|
||||
*
|
||||
* @return The port number of the controller.
|
||||
*/
|
||||
public int getPort() {
|
||||
return m_hid.getPort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the rumble output for the HID.
|
||||
*
|
||||
* <p>The DS currently supports 4 rumble values: left rumble, right rumble, left trigger rumble,
|
||||
* and right trigger rumble.
|
||||
*
|
||||
* @param type Which rumble value to set
|
||||
* @param value The normalized value (0 to 1) to set the rumble to
|
||||
*/
|
||||
public void setRumble(RumbleType type, double value) {
|
||||
m_hid.setRumble(type, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
|
||||
package org.wpilib.driverstation;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
import org.wpilib.driverstation.GenericHID.HIDType;
|
||||
import org.wpilib.driverstation.GenericHID.RumbleType;
|
||||
import org.wpilib.driverstation.GenericHID.SupportedOutput;
|
||||
import org.wpilib.event.BooleanEvent;
|
||||
import org.wpilib.event.EventLoop;
|
||||
import org.wpilib.hardware.hal.HAL;
|
||||
@@ -23,7 +28,7 @@ import org.wpilib.util.sendable.SendableBuilder;
|
||||
* only through the official NI DS. Sim is not guaranteed to have the same mapping, as well as any
|
||||
* 3rd party controllers.
|
||||
*/
|
||||
public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
public class NiDsXboxController implements HIDDevice, Sendable {
|
||||
/** Represents a digital button on a NiDsXboxController. */
|
||||
public enum Button {
|
||||
/** A button. */
|
||||
@@ -109,14 +114,35 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
private final GenericHID m_hid;
|
||||
|
||||
/**
|
||||
* Get the underlying GenericHID object.
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
*/
|
||||
@Override
|
||||
public GenericHID getHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
*
|
||||
* @param port The port index on the Driver Station that the controller is plugged into (0-5).
|
||||
*/
|
||||
public NiDsXboxController(final int port) {
|
||||
super(port);
|
||||
HAL.reportUsage("HID", port, "NiDsXboxController");
|
||||
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 NiDsXboxController(final GenericHID hid) {
|
||||
m_hid = Objects.requireNonNull(hid, "Provided HID object cannot be null");
|
||||
HAL.reportUsage("HID", hid.getPort(), "NiDsXboxController");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,7 +151,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftX() {
|
||||
return getRawAxis(Axis.kLeftX.value);
|
||||
return m_hid.getRawAxis(Axis.kLeftX.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +160,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightX() {
|
||||
return getRawAxis(Axis.kRightX.value);
|
||||
return m_hid.getRawAxis(Axis.kRightX.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +169,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftY() {
|
||||
return getRawAxis(Axis.kLeftY.value);
|
||||
return m_hid.getRawAxis(Axis.kLeftY.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,7 +178,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightY() {
|
||||
return getRawAxis(Axis.kRightY.value);
|
||||
return m_hid.getRawAxis(Axis.kRightY.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,7 +188,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftTriggerAxis() {
|
||||
return getRawAxis(Axis.kLeftTrigger.value);
|
||||
return m_hid.getRawAxis(Axis.kLeftTrigger.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,7 +202,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* threshold, attached to the given event loop
|
||||
*/
|
||||
public BooleanEvent leftTrigger(double threshold, EventLoop loop) {
|
||||
return axisGreaterThan(Axis.kLeftTrigger.value, threshold, loop);
|
||||
return m_hid.axisGreaterThan(Axis.kLeftTrigger.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,7 +224,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightTriggerAxis() {
|
||||
return getRawAxis(Axis.kRightTrigger.value);
|
||||
return m_hid.getRawAxis(Axis.kRightTrigger.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,7 +238,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* threshold, attached to the given event loop
|
||||
*/
|
||||
public BooleanEvent rightTrigger(double threshold, EventLoop loop) {
|
||||
return axisGreaterThan(Axis.kRightTrigger.value, threshold, loop);
|
||||
return m_hid.axisGreaterThan(Axis.kRightTrigger.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,7 +259,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getAButton() {
|
||||
return getRawButton(Button.kA.value);
|
||||
return m_hid.getRawButton(Button.kA.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,7 +268,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getAButtonPressed() {
|
||||
return getRawButtonPressed(Button.kA.value);
|
||||
return m_hid.getRawButtonPressed(Button.kA.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,7 +277,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getAButtonReleased() {
|
||||
return getRawButtonReleased(Button.kA.value);
|
||||
return m_hid.getRawButtonReleased(Button.kA.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,7 +288,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent a(EventLoop loop) {
|
||||
return button(Button.kA.value, loop);
|
||||
return m_hid.button(Button.kA.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,7 +297,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getBButton() {
|
||||
return getRawButton(Button.kB.value);
|
||||
return m_hid.getRawButton(Button.kB.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -280,7 +306,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getBButtonPressed() {
|
||||
return getRawButtonPressed(Button.kB.value);
|
||||
return m_hid.getRawButtonPressed(Button.kB.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -289,7 +315,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getBButtonReleased() {
|
||||
return getRawButtonReleased(Button.kB.value);
|
||||
return m_hid.getRawButtonReleased(Button.kB.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,7 +326,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent b(EventLoop loop) {
|
||||
return button(Button.kB.value, loop);
|
||||
return m_hid.button(Button.kB.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,7 +335,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getXButton() {
|
||||
return getRawButton(Button.kX.value);
|
||||
return m_hid.getRawButton(Button.kX.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,7 +344,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getXButtonPressed() {
|
||||
return getRawButtonPressed(Button.kX.value);
|
||||
return m_hid.getRawButtonPressed(Button.kX.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,7 +353,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getXButtonReleased() {
|
||||
return getRawButtonReleased(Button.kX.value);
|
||||
return m_hid.getRawButtonReleased(Button.kX.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -338,7 +364,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent x(EventLoop loop) {
|
||||
return button(Button.kX.value, loop);
|
||||
return m_hid.button(Button.kX.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -347,7 +373,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getYButton() {
|
||||
return getRawButton(Button.kY.value);
|
||||
return m_hid.getRawButton(Button.kY.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,7 +382,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getYButtonPressed() {
|
||||
return getRawButtonPressed(Button.kY.value);
|
||||
return m_hid.getRawButtonPressed(Button.kY.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -365,7 +391,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getYButtonReleased() {
|
||||
return getRawButtonReleased(Button.kY.value);
|
||||
return m_hid.getRawButtonReleased(Button.kY.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -376,7 +402,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent y(EventLoop loop) {
|
||||
return button(Button.kY.value, loop);
|
||||
return m_hid.button(Button.kY.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -385,7 +411,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getLeftBumperButton() {
|
||||
return getRawButton(Button.kLeftBumper.value);
|
||||
return m_hid.getRawButton(Button.kLeftBumper.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -394,7 +420,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getLeftBumperButtonPressed() {
|
||||
return getRawButtonPressed(Button.kLeftBumper.value);
|
||||
return m_hid.getRawButtonPressed(Button.kLeftBumper.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -403,7 +429,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getLeftBumperButtonReleased() {
|
||||
return getRawButtonReleased(Button.kLeftBumper.value);
|
||||
return m_hid.getRawButtonReleased(Button.kLeftBumper.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -414,7 +440,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent leftBumper(EventLoop loop) {
|
||||
return button(Button.kLeftBumper.value, loop);
|
||||
return m_hid.button(Button.kLeftBumper.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -423,7 +449,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getRightBumperButton() {
|
||||
return getRawButton(Button.kRightBumper.value);
|
||||
return m_hid.getRawButton(Button.kRightBumper.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -432,7 +458,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getRightBumperButtonPressed() {
|
||||
return getRawButtonPressed(Button.kRightBumper.value);
|
||||
return m_hid.getRawButtonPressed(Button.kRightBumper.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -441,7 +467,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getRightBumperButtonReleased() {
|
||||
return getRawButtonReleased(Button.kRightBumper.value);
|
||||
return m_hid.getRawButtonReleased(Button.kRightBumper.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -452,7 +478,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent rightBumper(EventLoop loop) {
|
||||
return button(Button.kRightBumper.value, loop);
|
||||
return m_hid.button(Button.kRightBumper.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -461,7 +487,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getBackButton() {
|
||||
return getRawButton(Button.kBack.value);
|
||||
return m_hid.getRawButton(Button.kBack.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -470,7 +496,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getBackButtonPressed() {
|
||||
return getRawButtonPressed(Button.kBack.value);
|
||||
return m_hid.getRawButtonPressed(Button.kBack.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -479,7 +505,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getBackButtonReleased() {
|
||||
return getRawButtonReleased(Button.kBack.value);
|
||||
return m_hid.getRawButtonReleased(Button.kBack.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -490,7 +516,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent back(EventLoop loop) {
|
||||
return button(Button.kBack.value, loop);
|
||||
return m_hid.button(Button.kBack.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -499,7 +525,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getStartButton() {
|
||||
return getRawButton(Button.kStart.value);
|
||||
return m_hid.getRawButton(Button.kStart.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -508,7 +534,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getStartButtonPressed() {
|
||||
return getRawButtonPressed(Button.kStart.value);
|
||||
return m_hid.getRawButtonPressed(Button.kStart.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -517,7 +543,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getStartButtonReleased() {
|
||||
return getRawButtonReleased(Button.kStart.value);
|
||||
return m_hid.getRawButtonReleased(Button.kStart.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -528,7 +554,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent start(EventLoop loop) {
|
||||
return button(Button.kStart.value, loop);
|
||||
return m_hid.button(Button.kStart.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -537,7 +563,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getLeftStickButton() {
|
||||
return getRawButton(Button.kLeftStick.value);
|
||||
return m_hid.getRawButton(Button.kLeftStick.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -546,7 +572,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getLeftStickButtonPressed() {
|
||||
return getRawButtonPressed(Button.kLeftStick.value);
|
||||
return m_hid.getRawButtonPressed(Button.kLeftStick.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -555,7 +581,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getLeftStickButtonReleased() {
|
||||
return getRawButtonReleased(Button.kLeftStick.value);
|
||||
return m_hid.getRawButtonReleased(Button.kLeftStick.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -566,7 +592,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent leftStick(EventLoop loop) {
|
||||
return button(Button.kLeftStick.value, loop);
|
||||
return m_hid.button(Button.kLeftStick.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -575,7 +601,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getRightStickButton() {
|
||||
return getRawButton(Button.kRightStick.value);
|
||||
return m_hid.getRawButton(Button.kRightStick.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -584,7 +610,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getRightStickButtonPressed() {
|
||||
return getRawButtonPressed(Button.kRightStick.value);
|
||||
return m_hid.getRawButtonPressed(Button.kRightStick.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -593,7 +619,7 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getRightStickButtonReleased() {
|
||||
return getRawButtonReleased(Button.kRightStick.value);
|
||||
return m_hid.getRawButtonReleased(Button.kRightStick.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -604,7 +630,65 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent rightStick(EventLoop loop) {
|
||||
return button(Button.kRightStick.value, loop);
|
||||
return m_hid.button(Button.kRightStick.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if the controller is connected.
|
||||
*
|
||||
* @return true if the controller is connected
|
||||
*/
|
||||
public boolean isConnected() {
|
||||
return m_hid.isConnected();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of the controller.
|
||||
*
|
||||
* @return the type of the controller.
|
||||
*/
|
||||
public HIDType getGamepadType() {
|
||||
return m_hid.getGamepadType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the supported outputs of the controller.
|
||||
*
|
||||
* @return the supported outputs of the controller.
|
||||
*/
|
||||
public EnumSet<SupportedOutput> getSupportedOutputs() {
|
||||
return m_hid.getSupportedOutputs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the controller.
|
||||
*
|
||||
* @return the name of the controller.
|
||||
*/
|
||||
public String getName() {
|
||||
return m_hid.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the port number of the controller.
|
||||
*
|
||||
* @return The port number of the controller.
|
||||
*/
|
||||
public int getPort() {
|
||||
return m_hid.getPort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the rumble output for the HID.
|
||||
*
|
||||
* <p>The DS currently supports 4 rumble values: left rumble, right rumble, left trigger rumble,
|
||||
* and right trigger rumble.
|
||||
*
|
||||
* @param type Which rumble value to set
|
||||
* @param value The normalized value (0 to 1) to set the rumble to
|
||||
*/
|
||||
public void setRumble(RumbleType type, double value) {
|
||||
m_hid.setRumble(type, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,7 @@ public class NiDsPS4ControllerSim extends GenericHIDSim {
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public NiDsPS4ControllerSim(NiDsPS4Controller joystick) {
|
||||
super(joystick);
|
||||
super(joystick.getHID());
|
||||
setAxesMaximumIndex(6);
|
||||
setButtonsMaximumIndex(14);
|
||||
setPOVsMaximumIndex(1);
|
||||
|
||||
@@ -17,7 +17,7 @@ public class NiDsPS5ControllerSim extends GenericHIDSim {
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public NiDsPS5ControllerSim(NiDsPS5Controller joystick) {
|
||||
super(joystick);
|
||||
super(joystick.getHID());
|
||||
setAxesMaximumIndex(6);
|
||||
setButtonsMaximumIndex(14);
|
||||
setPOVsMaximumIndex(1);
|
||||
|
||||
@@ -17,7 +17,7 @@ public class NiDsStadiaControllerSim extends GenericHIDSim {
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public NiDsStadiaControllerSim(NiDsStadiaController joystick) {
|
||||
super(joystick);
|
||||
super(joystick.getHID());
|
||||
setAxesMaximumIndex(4);
|
||||
setButtonsMaximumIndex(15);
|
||||
setPOVsMaximumIndex(1);
|
||||
|
||||
@@ -17,7 +17,7 @@ public class NiDsXboxControllerSim extends GenericHIDSim {
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public NiDsXboxControllerSim(NiDsXboxController joystick) {
|
||||
super(joystick);
|
||||
super(joystick.getHID());
|
||||
setAxesMaximumIndex(6);
|
||||
setButtonsMaximumIndex(10);
|
||||
setPOVsMaximumIndex(1);
|
||||
|
||||
Reference in New Issue
Block a user