mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +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:
@@ -8,6 +8,11 @@
|
||||
{%- endmacro %}
|
||||
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;
|
||||
@@ -25,7 +30,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 {{ ConsoleName }}Controller extends GenericHID implements Sendable {
|
||||
public class {{ ConsoleName }}Controller implements HIDDevice, Sendable {
|
||||
/** Represents a digital button on a {{ ConsoleName }}Controller. */
|
||||
public enum Button {
|
||||
{%- for button in buttons %}
|
||||
@@ -91,14 +96,35 @@ public class {{ ConsoleName }}Controller 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 {{ ConsoleName }}Controller(final int port) {
|
||||
super(port);
|
||||
HAL.reportUsage("HID", port, "{{ ConsoleName }}Controller");
|
||||
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 {{ ConsoleName }}Controller(final GenericHID hid) {
|
||||
m_hid = Objects.requireNonNull(hid, "Provided HID object cannot be null");
|
||||
HAL.reportUsage("HID", hid.getPort(), "{{ ConsoleName }}Controller");
|
||||
}
|
||||
{% for stick in sticks %}
|
||||
/**
|
||||
@@ -107,7 +133,7 @@ public class {{ ConsoleName }}Controller extends GenericHID implements Sendable
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double get{{ stick.NameParts|map("capitalize")|join }}() {
|
||||
return getRawAxis(Axis.k{{ stick.NameParts|map("capitalize")|join }}.value);
|
||||
return m_hid.getRawAxis(Axis.k{{ stick.NameParts|map("capitalize")|join }}.value);
|
||||
}
|
||||
{% endfor -%}
|
||||
{% for trigger in triggers %}
|
||||
@@ -118,7 +144,7 @@ public class {{ ConsoleName }}Controller extends GenericHID implements Sendable
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double get{{ capitalize_first(trigger.name) }}Axis() {
|
||||
return getRawAxis(Axis.k{{ capitalize_first(trigger.name) }}.value);
|
||||
return m_hid.getRawAxis(Axis.k{{ capitalize_first(trigger.name) }}.value);
|
||||
}
|
||||
{% if trigger.UseThresholdMethods %}
|
||||
/**
|
||||
@@ -132,7 +158,7 @@ public class {{ ConsoleName }}Controller extends GenericHID implements Sendable
|
||||
* threshold, attached to the given event loop
|
||||
*/
|
||||
public BooleanEvent {{ trigger.name }}(double threshold, EventLoop loop) {
|
||||
return axisGreaterThan(Axis.k{{ capitalize_first(trigger.name) }}.value, threshold, loop);
|
||||
return m_hid.axisGreaterThan(Axis.k{{ capitalize_first(trigger.name) }}.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +181,7 @@ public class {{ ConsoleName }}Controller extends GenericHID implements Sendable
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean get{{ capitalize_first(button.name) }}Button() {
|
||||
return getRawButton(Button.k{{ capitalize_first(button.name) }}.value);
|
||||
return m_hid.getRawButton(Button.k{{ capitalize_first(button.name) }}.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,7 +190,7 @@ public class {{ ConsoleName }}Controller extends GenericHID implements Sendable
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean get{{ capitalize_first(button.name) }}ButtonPressed() {
|
||||
return getRawButtonPressed(Button.k{{ capitalize_first(button.name) }}.value);
|
||||
return m_hid.getRawButtonPressed(Button.k{{ capitalize_first(button.name) }}.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,7 +199,7 @@ public class {{ ConsoleName }}Controller extends GenericHID implements Sendable
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean get{{ capitalize_first(button.name) }}ButtonReleased() {
|
||||
return getRawButtonReleased(Button.k{{ capitalize_first(button.name) }}.value);
|
||||
return m_hid.getRawButtonReleased(Button.k{{ capitalize_first(button.name) }}.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,9 +210,67 @@ public class {{ ConsoleName }}Controller extends GenericHID implements Sendable
|
||||
* attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent {{ button.name }}(EventLoop loop) {
|
||||
return button(Button.k{{ capitalize_first(button.name) }}.value, loop);
|
||||
return m_hid.button(Button.k{{ capitalize_first(button.name) }}.value, loop);
|
||||
}
|
||||
{% endfor %}
|
||||
/**
|
||||
* 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
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("HID");
|
||||
|
||||
@@ -19,7 +19,7 @@ public class {{ ConsoleName }}ControllerSim extends GenericHIDSim {
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public {{ ConsoleName }}ControllerSim({{ ConsoleName }}Controller joystick) {
|
||||
super(joystick);
|
||||
super(joystick.getHID());
|
||||
setAxesMaximumIndex({{ sticks|length + triggers|length }});
|
||||
setButtonsMaximumIndex({{ buttons|length }});
|
||||
setPOVsMaximumIndex(1);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
package org.wpilib.driverstation;
|
||||
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.wpilib.datalog.DataLog;
|
||||
import org.wpilib.driverstation.internal.DriverStationBackend;
|
||||
|
||||
@@ -11,6 +13,56 @@ import org.wpilib.driverstation.internal.DriverStationBackend;
|
||||
public final class DriverStation {
|
||||
private DriverStation() {}
|
||||
|
||||
private static final Lock m_dsLock = new ReentrantLock();
|
||||
private static final GenericHID[] m_hids = new GenericHID[DriverStationBackend.JOYSTICK_PORTS];
|
||||
private static final Gamepad[] m_gamepads = new Gamepad[DriverStationBackend.JOYSTICK_PORTS];
|
||||
|
||||
private static GenericHID getGenericHIDUnderLock(int port) {
|
||||
GenericHID toRet = m_hids[port];
|
||||
if (toRet == null) {
|
||||
toRet = new GenericHID(port);
|
||||
m_hids[port] = toRet;
|
||||
}
|
||||
return toRet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the GenericHID object for the given port. GenericHID objects are cached, so this will
|
||||
* always return the same object for the same port.
|
||||
*
|
||||
* @param port The port index on the Driver Station that the controller is plugged into (0-5).
|
||||
* @return The GenericHID object for the given port.
|
||||
*/
|
||||
public static GenericHID getGenericHID(int port) {
|
||||
m_dsLock.lock();
|
||||
try {
|
||||
return getGenericHIDUnderLock(port);
|
||||
} finally {
|
||||
m_dsLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Gamepad object for the given port. Gamepad objects are cached, so this will always
|
||||
* return the same object for the same port.
|
||||
*
|
||||
* @param port The port index on the Driver Station that the controller is plugged into (0-5).
|
||||
* @return The Gamepad object for the given port.
|
||||
*/
|
||||
public static Gamepad getGamepad(int port) {
|
||||
m_dsLock.lock();
|
||||
try {
|
||||
Gamepad toRet = m_gamepads[port];
|
||||
if (toRet == null) {
|
||||
toRet = new Gamepad(getGenericHIDUnderLock(port));
|
||||
m_gamepads[port] = toRet;
|
||||
}
|
||||
return toRet;
|
||||
} finally {
|
||||
m_dsLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts logging DriverStation data to data log, including joystick data. Repeated calls are
|
||||
* ignored.
|
||||
|
||||
@@ -4,6 +4,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.driverstation.internal.DriverStationBackend;
|
||||
import org.wpilib.event.BooleanEvent;
|
||||
import org.wpilib.event.EventLoop;
|
||||
@@ -18,12 +23,8 @@ import org.wpilib.util.sendable.SendableBuilder;
|
||||
* <p>This class handles Gamepad input that comes from the Driver Station. Each time a value is
|
||||
* requested the most recent value is returned. There is a single class instance for each controller
|
||||
* and the mapping of ports to hardware buttons depends on the code in the Driver Station.
|
||||
*
|
||||
* <p>Only first party controllers from Generic are guaranteed to have the correct mapping, and only
|
||||
* through the official NI DS. Sim is not guaranteed to have the same mapping, as well as any 3rd
|
||||
* party controllers.
|
||||
*/
|
||||
public class Gamepad extends GenericHID implements Sendable {
|
||||
public class Gamepad implements HIDDevice, Sendable {
|
||||
private static final double MAX_DEADBAND = Math.nextDown(1.0);
|
||||
|
||||
/** Represents a digital button on a Gamepad. */
|
||||
@@ -156,14 +157,35 @@ public class Gamepad extends GenericHID implements Sendable {
|
||||
return Math.clamp(deadband, 0.0, MAX_DEADBAND);
|
||||
}
|
||||
|
||||
private final GenericHID m_hid;
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
* Get the underlying GenericHID object.
|
||||
*
|
||||
* @param port The port index on the Driver Station that the controller is plugged into (0-5).
|
||||
* @return the wrapped GenericHID object
|
||||
*/
|
||||
@Override
|
||||
public GenericHID getHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance of a gamepad.
|
||||
*
|
||||
* @param port The port index on the Driver Station that the gamepad is plugged into (0-5).
|
||||
*/
|
||||
public Gamepad(final int port) {
|
||||
super(port);
|
||||
HAL.reportUsage("HID", port, "Gamepad");
|
||||
this(DriverStation.getGenericHID(port));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance of a gamepad with a GenericHID object.
|
||||
*
|
||||
* @param hid The GenericHID object to use for this gamepad.
|
||||
*/
|
||||
public Gamepad(final GenericHID hid) {
|
||||
m_hid = Objects.requireNonNull(hid, "Provided HID object cannot be null");
|
||||
HAL.reportUsage("HID", hid.getPort(), "Gamepad");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1350,7 +1372,7 @@ public class Gamepad extends GenericHID implements Sendable {
|
||||
* @return The state of the button.
|
||||
*/
|
||||
public boolean getButton(Button button) {
|
||||
return getRawButton(button.value);
|
||||
return m_hid.getRawButton(button.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1364,7 +1386,7 @@ public class Gamepad extends GenericHID implements Sendable {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getButtonPressed(Button button) {
|
||||
return getRawButtonPressed(button.value);
|
||||
return m_hid.getRawButtonPressed(button.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1378,7 +1400,7 @@ public class Gamepad extends GenericHID implements Sendable {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getButtonReleased(Button button) {
|
||||
return getRawButtonReleased(button.value);
|
||||
return m_hid.getRawButtonReleased(button.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1389,7 +1411,7 @@ public class Gamepad extends GenericHID implements Sendable {
|
||||
* @return an event instance representing the button's digital signal attached to the given loop.
|
||||
*/
|
||||
public BooleanEvent button(Button button, EventLoop loop) {
|
||||
return super.button(button.value, loop);
|
||||
return m_hid.button(button.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1399,7 +1421,7 @@ public class Gamepad extends GenericHID implements Sendable {
|
||||
* @return The value of the axis.
|
||||
*/
|
||||
public double getAxis(Axis axis) {
|
||||
return getRawAxis(axis.value);
|
||||
return m_hid.getRawAxis(axis.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1412,7 +1434,7 @@ public class Gamepad extends GenericHID implements Sendable {
|
||||
* @return an event instance that is true when the axis value is less than the provided threshold.
|
||||
*/
|
||||
public BooleanEvent axisLessThan(Axis axis, double threshold, EventLoop loop) {
|
||||
return super.axisLessThan(axis.value, threshold, loop);
|
||||
return m_hid.axisLessThan(axis.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1426,15 +1448,115 @@ public class Gamepad extends GenericHID implements Sendable {
|
||||
* threshold.
|
||||
*/
|
||||
public BooleanEvent axisGreaterThan(Axis axis, double threshold, EventLoop loop) {
|
||||
return super.axisGreaterThan(axis.value, threshold, loop);
|
||||
return m_hid.axisGreaterThan(axis.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bitmask of axes for the gamepad.
|
||||
*
|
||||
* @return the number of axis for the current gamepad
|
||||
*/
|
||||
public int getAxesAvailable() {
|
||||
return m_hid.getAxesAvailable();
|
||||
}
|
||||
|
||||
/**
|
||||
* For the current gamepad, return the bitmask of available buttons.
|
||||
*
|
||||
* @return the bitmask of buttons for the current gamepad
|
||||
*/
|
||||
public long getButtonsAvailable() {
|
||||
return m_hid.getButtonsAvailable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if the gamepad is connected.
|
||||
*
|
||||
* @return true if the gamepad is connected
|
||||
*/
|
||||
public boolean isConnected() {
|
||||
return m_hid.isConnected();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of the gamepad.
|
||||
*
|
||||
* @return the type of the gamepad.
|
||||
*/
|
||||
public HIDType getGamepadType() {
|
||||
return m_hid.getGamepadType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the supported outputs for the gamepad.
|
||||
*
|
||||
* @return the supported outputs for the gamepad.
|
||||
*/
|
||||
public EnumSet<SupportedOutput> getSupportedOutputs() {
|
||||
return m_hid.getSupportedOutputs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the gamepad.
|
||||
*
|
||||
* @return the name of the gamepad.
|
||||
*/
|
||||
public String getName() {
|
||||
return m_hid.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set leds on the gamepad. If only mono is supported, the system will use the highest value
|
||||
* passed in.
|
||||
*
|
||||
* @param r Red value from 0-255
|
||||
* @param g Green value from 0-255
|
||||
* @param b Blue value from 0-255
|
||||
*/
|
||||
public void setLeds(int r, int g, int b) {
|
||||
m_hid.setLeds(r, g, b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the rumble output for the HID. 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a touchpad finger is available.
|
||||
*
|
||||
* @param touchpad The touchpad to check.
|
||||
* @param finger The finger to check.
|
||||
* @return true if the touchpad finger is available.
|
||||
*/
|
||||
public boolean getTouchpadFingerAvailable(int touchpad, int finger) {
|
||||
return m_hid.getTouchpadFingerAvailable(touchpad, finger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the touchpad finger data.
|
||||
*
|
||||
* @param touchpad The touchpad to read.
|
||||
* @param finger The finger to read.
|
||||
* @return The touchpad finger data.
|
||||
*/
|
||||
public TouchpadFinger getTouchpadFinger(int touchpad, int finger) {
|
||||
return m_hid.getTouchpadFinger(touchpad, finger);
|
||||
}
|
||||
|
||||
private double getAxisForSendable(Axis axis) {
|
||||
return DriverStationBackend.getStickAxisIfAvailable(getPort(), axis.value).orElse(0.0);
|
||||
return DriverStationBackend.getStickAxisIfAvailable(m_hid.getPort(), axis.value).orElse(0.0);
|
||||
}
|
||||
|
||||
private boolean getButtonForSendable(Button button) {
|
||||
return DriverStationBackend.getStickButtonIfAvailable(getPort(), button.value).orElse(false);
|
||||
return DriverStationBackend.getStickButtonIfAvailable(m_hid.getPort(), button.value)
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.wpilib.math.util.Pair;
|
||||
* requested the most recent value is returned. There is a single class instance for each device and
|
||||
* the mapping of ports to hardware buttons depends on the code in the Driver Station.
|
||||
*/
|
||||
public class GenericHID {
|
||||
public final class GenericHID implements HIDDevice {
|
||||
/** Represents a rumble output on the Joystick. */
|
||||
public enum RumbleType {
|
||||
/** Left rumble motor. */
|
||||
@@ -132,10 +132,20 @@ public class GenericHID {
|
||||
*
|
||||
* @param port The port index on the Driver Station that the device is plugged into.
|
||||
*/
|
||||
public GenericHID(int port) {
|
||||
GenericHID(int port) {
|
||||
m_port = port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this GenericHID object.
|
||||
*
|
||||
* @return this GenericHID object
|
||||
*/
|
||||
@Override
|
||||
public GenericHID getHID() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the button value (starting at button 1).
|
||||
*
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package org.wpilib.driverstation;
|
||||
|
||||
/** Interface for device wrappers backed by a GenericHID. */
|
||||
@SuppressWarnings("PMD.ImplicitFunctionalInterface")
|
||||
public interface HIDDevice {
|
||||
/**
|
||||
* Get the underlying GenericHID object.
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
*/
|
||||
GenericHID getHID();
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
package org.wpilib.driverstation;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.wpilib.event.BooleanEvent;
|
||||
import org.wpilib.event.EventLoop;
|
||||
import org.wpilib.hardware.hal.HAL;
|
||||
@@ -15,7 +16,7 @@ import org.wpilib.hardware.hal.HAL;
|
||||
* requested the most recent value is returned. There is a single class instance for each joystick
|
||||
* and the mapping of ports to hardware buttons depends on the code in the Driver Station.
|
||||
*/
|
||||
public class Joystick extends GenericHID {
|
||||
public class Joystick implements HIDDevice {
|
||||
/** Default X axis channel. */
|
||||
public static final byte kDefaultXChannel = 0;
|
||||
|
||||
@@ -69,21 +70,41 @@ public class Joystick extends GenericHID {
|
||||
|
||||
private final byte[] m_axes = new byte[AxisType.values().length];
|
||||
|
||||
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 joystick.
|
||||
*
|
||||
* @param port The port index on the Driver Station that the joystick is plugged into.
|
||||
*/
|
||||
public Joystick(final int port) {
|
||||
super(port);
|
||||
this(DriverStation.getGenericHID(port));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance of a joystick with a GenericHID object.
|
||||
*
|
||||
* @param hid The GenericHID object to use for this joystick.
|
||||
*/
|
||||
public Joystick(final GenericHID hid) {
|
||||
m_hid = Objects.requireNonNull(hid, "Provided HID object cannot be null");
|
||||
m_axes[AxisType.kX.value] = kDefaultXChannel;
|
||||
m_axes[AxisType.kY.value] = kDefaultYChannel;
|
||||
m_axes[AxisType.kZ.value] = kDefaultZChannel;
|
||||
m_axes[AxisType.kTwist.value] = kDefaultTwistChannel;
|
||||
m_axes[AxisType.kThrottle.value] = kDefaultThrottleChannel;
|
||||
|
||||
HAL.reportUsage("HID", port, "Joystick");
|
||||
HAL.reportUsage("HID", hid.getPort(), "Joystick");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,6 +197,74 @@ public class Joystick extends GenericHID {
|
||||
return m_axes[AxisType.kThrottle.value];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the button value (starting at button 1).
|
||||
*
|
||||
* <p>The buttons are returned in a single 16 bit value with one bit representing the state of
|
||||
* each button. The appropriate button is returned as a boolean value.
|
||||
*
|
||||
* @param button The button number to be read (starting at 1)
|
||||
* @return The state of the button
|
||||
*/
|
||||
public boolean getRawButton(int button) {
|
||||
return m_hid.getRawButton(button);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the button was pressed since the last check. Button indexes begin at 1.
|
||||
*
|
||||
* @param button The button index, beginning at 1.
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getRawButtonPressed(int button) {
|
||||
return m_hid.getRawButtonPressed(button);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the button was released since the last check. Button indexes begin at 1.
|
||||
*
|
||||
* @param button The button index, beginning at 1.
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getRawButtonReleased(int button) {
|
||||
return m_hid.getRawButtonReleased(button);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the axis.
|
||||
*
|
||||
* @param axis The axis to read, starting at 0.
|
||||
* @return The value of the axis.
|
||||
*/
|
||||
public double getRawAxis(int axis) {
|
||||
return m_hid.getRawAxis(axis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the angle in degrees of a POV on the HID.
|
||||
*
|
||||
* <p>The POV angles start at 0 in the up direction, and increase clockwise (e.g. right is 90,
|
||||
* upper-left is 315).
|
||||
*
|
||||
* @param pov The index of the POV to read, starting at 0.
|
||||
* @return the angle of the POV
|
||||
*/
|
||||
public POVDirection getPOV(int pov) {
|
||||
return m_hid.getPOV(pov);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the angle in degrees of the default POV on the HID.
|
||||
*
|
||||
* <p>The POV angles start at 0 in the up direction, and increase clockwise (e.g. right is 90,
|
||||
* upper-left is 315).
|
||||
*
|
||||
* @return the angle of the POV
|
||||
*/
|
||||
public POVDirection getPOV() {
|
||||
return m_hid.getPOV();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the X value of the joystick. This depends on the mapping of the joystick connected to the
|
||||
* current port. On most joysticks, positive is to the right.
|
||||
@@ -183,7 +272,7 @@ public class Joystick extends GenericHID {
|
||||
* @return The X value of the joystick.
|
||||
*/
|
||||
public final double getX() {
|
||||
return getRawAxis(m_axes[AxisType.kX.value]);
|
||||
return m_hid.getRawAxis(m_axes[AxisType.kX.value]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,7 +282,7 @@ public class Joystick extends GenericHID {
|
||||
* @return The Y value of the joystick.
|
||||
*/
|
||||
public final double getY() {
|
||||
return getRawAxis(m_axes[AxisType.kY.value]);
|
||||
return m_hid.getRawAxis(m_axes[AxisType.kY.value]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,7 +291,7 @@ public class Joystick extends GenericHID {
|
||||
* @return the z position
|
||||
*/
|
||||
public final double getZ() {
|
||||
return getRawAxis(m_axes[AxisType.kZ.value]);
|
||||
return m_hid.getRawAxis(m_axes[AxisType.kZ.value]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,7 +301,7 @@ public class Joystick extends GenericHID {
|
||||
* @return The Twist value of the joystick.
|
||||
*/
|
||||
public final double getTwist() {
|
||||
return getRawAxis(m_axes[AxisType.kTwist.value]);
|
||||
return m_hid.getRawAxis(m_axes[AxisType.kTwist.value]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,7 +311,7 @@ public class Joystick extends GenericHID {
|
||||
* @return The Throttle value of the joystick.
|
||||
*/
|
||||
public final double getThrottle() {
|
||||
return getRawAxis(m_axes[AxisType.kThrottle.value]);
|
||||
return m_hid.getRawAxis(m_axes[AxisType.kThrottle.value]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,7 +320,7 @@ public class Joystick extends GenericHID {
|
||||
* @return The state of the trigger.
|
||||
*/
|
||||
public boolean getTrigger() {
|
||||
return getRawButton(ButtonType.kTrigger.value);
|
||||
return m_hid.getRawButton(ButtonType.kTrigger.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,7 +329,7 @@ public class Joystick extends GenericHID {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getTriggerPressed() {
|
||||
return getRawButtonPressed(ButtonType.kTrigger.value);
|
||||
return m_hid.getRawButtonPressed(ButtonType.kTrigger.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,7 +338,7 @@ public class Joystick extends GenericHID {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getTriggerReleased() {
|
||||
return getRawButtonReleased(ButtonType.kTrigger.value);
|
||||
return m_hid.getRawButtonReleased(ButtonType.kTrigger.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,7 +349,7 @@ public class Joystick extends GenericHID {
|
||||
* given loop.
|
||||
*/
|
||||
public BooleanEvent trigger(EventLoop loop) {
|
||||
return button(ButtonType.kTrigger.value, loop);
|
||||
return m_hid.button(ButtonType.kTrigger.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -269,7 +358,7 @@ public class Joystick extends GenericHID {
|
||||
* @return The state of the top button.
|
||||
*/
|
||||
public boolean getTop() {
|
||||
return getRawButton(ButtonType.kTop.value);
|
||||
return m_hid.getRawButton(ButtonType.kTop.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,7 +367,7 @@ public class Joystick extends GenericHID {
|
||||
* @return Whether the button was pressed since the last check.
|
||||
*/
|
||||
public boolean getTopPressed() {
|
||||
return getRawButtonPressed(ButtonType.kTop.value);
|
||||
return m_hid.getRawButtonPressed(ButtonType.kTop.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,7 +376,7 @@ public class Joystick extends GenericHID {
|
||||
* @return Whether the button was released since the last check.
|
||||
*/
|
||||
public boolean getTopReleased() {
|
||||
return getRawButtonReleased(ButtonType.kTop.value);
|
||||
return m_hid.getRawButtonReleased(ButtonType.kTop.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,7 +387,7 @@ public class Joystick extends GenericHID {
|
||||
* loop.
|
||||
*/
|
||||
public BooleanEvent top(EventLoop loop) {
|
||||
return button(ButtonType.kTop.value, loop);
|
||||
return m_hid.button(ButtonType.kTop.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,7 @@ public class GamepadSim extends GenericHIDSim {
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public GamepadSim(Gamepad joystick) {
|
||||
super(joystick);
|
||||
super(joystick.getHID());
|
||||
setAxesMaximumIndex(6);
|
||||
setButtonsMaximumIndex(26);
|
||||
setPOVsMaximumIndex(1);
|
||||
|
||||
@@ -17,7 +17,7 @@ public class JoystickSim extends GenericHIDSim {
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public JoystickSim(Joystick joystick) {
|
||||
super(joystick);
|
||||
super(joystick.getHID());
|
||||
m_joystick = joystick;
|
||||
// default to a reasonable joystick configuration
|
||||
setAxesMaximumIndex(5);
|
||||
|
||||
Reference in New Issue
Block a user