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:
@@ -6,51 +6,63 @@
|
||||
|
||||
#include "wpi/driverstation/NiDsPS4Controller.hpp"
|
||||
|
||||
#include "wpi/driverstation/DriverStation.hpp"
|
||||
#include "wpi/event/BooleanEvent.hpp"
|
||||
#include "wpi/hal/UsageReporting.hpp"
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
#include "wpi/event/BooleanEvent.hpp"
|
||||
|
||||
using namespace wpi;
|
||||
|
||||
NiDsPS4Controller::NiDsPS4Controller(int port) : GenericHID(port) {
|
||||
HAL_ReportUsage("HID", port, "NiDsPS4Controller");
|
||||
NiDsPS4Controller::NiDsPS4Controller(int port)
|
||||
: NiDsPS4Controller{DriverStation::GetGenericHID(port)} {}
|
||||
|
||||
NiDsPS4Controller::NiDsPS4Controller(GenericHID& hid)
|
||||
: m_hid{&hid} {
|
||||
HAL_ReportUsage("HID", hid.GetPort(), "NiDsPS4Controller");
|
||||
}
|
||||
|
||||
GenericHID& NiDsPS4Controller::GetHID() {
|
||||
return *m_hid;
|
||||
}
|
||||
|
||||
const GenericHID& NiDsPS4Controller::GetHID() const {
|
||||
return *m_hid;
|
||||
}
|
||||
|
||||
double NiDsPS4Controller::GetLeftX() const {
|
||||
return GetRawAxis(Axis::kLeftX);
|
||||
return m_hid->GetRawAxis(Axis::kLeftX);
|
||||
}
|
||||
|
||||
double NiDsPS4Controller::GetLeftY() const {
|
||||
return GetRawAxis(Axis::kLeftY);
|
||||
return m_hid->GetRawAxis(Axis::kLeftY);
|
||||
}
|
||||
|
||||
double NiDsPS4Controller::GetRightX() const {
|
||||
return GetRawAxis(Axis::kRightX);
|
||||
return m_hid->GetRawAxis(Axis::kRightX);
|
||||
}
|
||||
|
||||
double NiDsPS4Controller::GetRightY() const {
|
||||
return GetRawAxis(Axis::kRightY);
|
||||
return m_hid->GetRawAxis(Axis::kRightY);
|
||||
}
|
||||
|
||||
double NiDsPS4Controller::GetL2Axis() const {
|
||||
return GetRawAxis(Axis::kL2);
|
||||
return m_hid->GetRawAxis(Axis::kL2);
|
||||
}
|
||||
|
||||
double NiDsPS4Controller::GetR2Axis() const {
|
||||
return GetRawAxis(Axis::kR2);
|
||||
return m_hid->GetRawAxis(Axis::kR2);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetSquareButton() const {
|
||||
return GetRawButton(Button::kSquare);
|
||||
return m_hid->GetRawButton(Button::kSquare);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetSquareButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kSquare);
|
||||
return m_hid->GetRawButtonPressed(Button::kSquare);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetSquareButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kSquare);
|
||||
return m_hid->GetRawButtonReleased(Button::kSquare);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS4Controller::Square(EventLoop* loop) const {
|
||||
@@ -58,15 +70,15 @@ BooleanEvent NiDsPS4Controller::Square(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetCrossButton() const {
|
||||
return GetRawButton(Button::kCross);
|
||||
return m_hid->GetRawButton(Button::kCross);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetCrossButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kCross);
|
||||
return m_hid->GetRawButtonPressed(Button::kCross);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetCrossButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kCross);
|
||||
return m_hid->GetRawButtonReleased(Button::kCross);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS4Controller::Cross(EventLoop* loop) const {
|
||||
@@ -74,15 +86,15 @@ BooleanEvent NiDsPS4Controller::Cross(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetCircleButton() const {
|
||||
return GetRawButton(Button::kCircle);
|
||||
return m_hid->GetRawButton(Button::kCircle);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetCircleButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kCircle);
|
||||
return m_hid->GetRawButtonPressed(Button::kCircle);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetCircleButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kCircle);
|
||||
return m_hid->GetRawButtonReleased(Button::kCircle);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS4Controller::Circle(EventLoop* loop) const {
|
||||
@@ -90,15 +102,15 @@ BooleanEvent NiDsPS4Controller::Circle(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetTriangleButton() const {
|
||||
return GetRawButton(Button::kTriangle);
|
||||
return m_hid->GetRawButton(Button::kTriangle);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetTriangleButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kTriangle);
|
||||
return m_hid->GetRawButtonPressed(Button::kTriangle);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetTriangleButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kTriangle);
|
||||
return m_hid->GetRawButtonReleased(Button::kTriangle);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS4Controller::Triangle(EventLoop* loop) const {
|
||||
@@ -106,15 +118,15 @@ BooleanEvent NiDsPS4Controller::Triangle(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetL1Button() const {
|
||||
return GetRawButton(Button::kL1);
|
||||
return m_hid->GetRawButton(Button::kL1);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetL1ButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kL1);
|
||||
return m_hid->GetRawButtonPressed(Button::kL1);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetL1ButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kL1);
|
||||
return m_hid->GetRawButtonReleased(Button::kL1);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS4Controller::L1(EventLoop* loop) const {
|
||||
@@ -122,15 +134,15 @@ BooleanEvent NiDsPS4Controller::L1(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetR1Button() const {
|
||||
return GetRawButton(Button::kR1);
|
||||
return m_hid->GetRawButton(Button::kR1);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetR1ButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kR1);
|
||||
return m_hid->GetRawButtonPressed(Button::kR1);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetR1ButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kR1);
|
||||
return m_hid->GetRawButtonReleased(Button::kR1);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS4Controller::R1(EventLoop* loop) const {
|
||||
@@ -138,15 +150,15 @@ BooleanEvent NiDsPS4Controller::R1(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetL2Button() const {
|
||||
return GetRawButton(Button::kL2);
|
||||
return m_hid->GetRawButton(Button::kL2);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetL2ButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kL2);
|
||||
return m_hid->GetRawButtonPressed(Button::kL2);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetL2ButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kL2);
|
||||
return m_hid->GetRawButtonReleased(Button::kL2);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS4Controller::L2(EventLoop* loop) const {
|
||||
@@ -154,15 +166,15 @@ BooleanEvent NiDsPS4Controller::L2(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetR2Button() const {
|
||||
return GetRawButton(Button::kR2);
|
||||
return m_hid->GetRawButton(Button::kR2);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetR2ButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kR2);
|
||||
return m_hid->GetRawButtonPressed(Button::kR2);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetR2ButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kR2);
|
||||
return m_hid->GetRawButtonReleased(Button::kR2);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS4Controller::R2(EventLoop* loop) const {
|
||||
@@ -170,15 +182,15 @@ BooleanEvent NiDsPS4Controller::R2(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetShareButton() const {
|
||||
return GetRawButton(Button::kShare);
|
||||
return m_hid->GetRawButton(Button::kShare);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetShareButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kShare);
|
||||
return m_hid->GetRawButtonPressed(Button::kShare);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetShareButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kShare);
|
||||
return m_hid->GetRawButtonReleased(Button::kShare);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS4Controller::Share(EventLoop* loop) const {
|
||||
@@ -186,15 +198,15 @@ BooleanEvent NiDsPS4Controller::Share(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetOptionsButton() const {
|
||||
return GetRawButton(Button::kOptions);
|
||||
return m_hid->GetRawButton(Button::kOptions);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetOptionsButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kOptions);
|
||||
return m_hid->GetRawButtonPressed(Button::kOptions);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetOptionsButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kOptions);
|
||||
return m_hid->GetRawButtonReleased(Button::kOptions);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS4Controller::Options(EventLoop* loop) const {
|
||||
@@ -202,15 +214,15 @@ BooleanEvent NiDsPS4Controller::Options(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetL3Button() const {
|
||||
return GetRawButton(Button::kL3);
|
||||
return m_hid->GetRawButton(Button::kL3);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetL3ButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kL3);
|
||||
return m_hid->GetRawButtonPressed(Button::kL3);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetL3ButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kL3);
|
||||
return m_hid->GetRawButtonReleased(Button::kL3);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS4Controller::L3(EventLoop* loop) const {
|
||||
@@ -218,15 +230,15 @@ BooleanEvent NiDsPS4Controller::L3(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetR3Button() const {
|
||||
return GetRawButton(Button::kR3);
|
||||
return m_hid->GetRawButton(Button::kR3);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetR3ButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kR3);
|
||||
return m_hid->GetRawButtonPressed(Button::kR3);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetR3ButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kR3);
|
||||
return m_hid->GetRawButtonReleased(Button::kR3);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS4Controller::R3(EventLoop* loop) const {
|
||||
@@ -234,15 +246,15 @@ BooleanEvent NiDsPS4Controller::R3(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetPSButton() const {
|
||||
return GetRawButton(Button::kPS);
|
||||
return m_hid->GetRawButton(Button::kPS);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetPSButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kPS);
|
||||
return m_hid->GetRawButtonPressed(Button::kPS);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetPSButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kPS);
|
||||
return m_hid->GetRawButtonReleased(Button::kPS);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS4Controller::PS(EventLoop* loop) const {
|
||||
@@ -250,42 +262,87 @@ BooleanEvent NiDsPS4Controller::PS(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetTouchpadButton() const {
|
||||
return GetRawButton(Button::kTouchpad);
|
||||
return m_hid->GetRawButton(Button::kTouchpad);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetTouchpadButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kTouchpad);
|
||||
return m_hid->GetRawButtonPressed(Button::kTouchpad);
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::GetTouchpadButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kTouchpad);
|
||||
return m_hid->GetRawButtonReleased(Button::kTouchpad);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS4Controller::Touchpad(EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this]() { return this->GetTouchpadButton(); });
|
||||
}
|
||||
|
||||
bool NiDsPS4Controller::IsConnected() const {
|
||||
return m_hid->IsConnected();
|
||||
}
|
||||
|
||||
GenericHID::HIDType NiDsPS4Controller::GetGamepadType() const {
|
||||
return m_hid->GetGamepadType();
|
||||
}
|
||||
|
||||
GenericHID::SupportedOutputs NiDsPS4Controller::GetSupportedOutputs() const {
|
||||
return m_hid->GetSupportedOutputs();
|
||||
}
|
||||
|
||||
std::string NiDsPS4Controller::GetName() const {
|
||||
return m_hid->GetName();
|
||||
}
|
||||
|
||||
int NiDsPS4Controller::GetPort() const {
|
||||
return m_hid->GetPort();
|
||||
}
|
||||
|
||||
void NiDsPS4Controller::SetRumble(GenericHID::RumbleType type,
|
||||
double value) {
|
||||
m_hid->SetRumble(type, value);
|
||||
}
|
||||
|
||||
void NiDsPS4Controller::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "NiDsPS4");
|
||||
builder.AddDoubleProperty("L2 Axis", [this] { return GetL2Axis(); }, nullptr);
|
||||
builder.AddDoubleProperty("R2 Axis", [this] { return GetR2Axis(); }, nullptr);
|
||||
builder.AddDoubleProperty("LeftX", [this] { return GetLeftX(); }, nullptr);
|
||||
builder.AddDoubleProperty("LeftY", [this] { return GetLeftY(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightX", [this] { return GetRightX(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightY", [this] { return GetRightY(); }, nullptr);
|
||||
builder.AddBooleanProperty("Square", [this] { return GetSquareButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Cross", [this] { return GetCrossButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Circle", [this] { return GetCircleButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Triangle", [this] { return GetTriangleButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("L1", [this] { return GetL1Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("R1", [this] { return GetR1Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("L2", [this] { return GetL2Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("R2", [this] { return GetR2Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("Share", [this] { return GetShareButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Options", [this] { return GetOptionsButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("L3", [this] { return GetL3Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("R3", [this] { return GetR3Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("PS", [this] { return GetPSButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Touchpad", [this] { return GetTouchpadButton(); }, nullptr);
|
||||
builder.AddDoubleProperty("L2 Axis",
|
||||
[this] { return GetL2Axis(); }, nullptr);
|
||||
builder.AddDoubleProperty("R2 Axis",
|
||||
[this] { return GetR2Axis(); }, nullptr);
|
||||
builder.AddDoubleProperty("LeftX",
|
||||
[this] { return GetLeftX(); }, nullptr);
|
||||
builder.AddDoubleProperty("LeftY",
|
||||
[this] { return GetLeftY(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightX",
|
||||
[this] { return GetRightX(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightY",
|
||||
[this] { return GetRightY(); }, nullptr);
|
||||
builder.AddBooleanProperty("Square",
|
||||
[this] { return GetSquareButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Cross",
|
||||
[this] { return GetCrossButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Circle",
|
||||
[this] { return GetCircleButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Triangle",
|
||||
[this] { return GetTriangleButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("L1",
|
||||
[this] { return GetL1Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("R1",
|
||||
[this] { return GetR1Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("L2",
|
||||
[this] { return GetL2Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("R2",
|
||||
[this] { return GetR2Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("Share",
|
||||
[this] { return GetShareButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Options",
|
||||
[this] { return GetOptionsButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("L3",
|
||||
[this] { return GetL3Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("R3",
|
||||
[this] { return GetR3Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("PS",
|
||||
[this] { return GetPSButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Touchpad",
|
||||
[this] { return GetTouchpadButton(); }, nullptr);
|
||||
}
|
||||
@@ -6,51 +6,63 @@
|
||||
|
||||
#include "wpi/driverstation/NiDsPS5Controller.hpp"
|
||||
|
||||
#include "wpi/driverstation/DriverStation.hpp"
|
||||
#include "wpi/event/BooleanEvent.hpp"
|
||||
#include "wpi/hal/UsageReporting.hpp"
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
#include "wpi/event/BooleanEvent.hpp"
|
||||
|
||||
using namespace wpi;
|
||||
|
||||
NiDsPS5Controller::NiDsPS5Controller(int port) : GenericHID(port) {
|
||||
HAL_ReportUsage("HID", port, "NiDsPS5Controller");
|
||||
NiDsPS5Controller::NiDsPS5Controller(int port)
|
||||
: NiDsPS5Controller{DriverStation::GetGenericHID(port)} {}
|
||||
|
||||
NiDsPS5Controller::NiDsPS5Controller(GenericHID& hid)
|
||||
: m_hid{&hid} {
|
||||
HAL_ReportUsage("HID", hid.GetPort(), "NiDsPS5Controller");
|
||||
}
|
||||
|
||||
GenericHID& NiDsPS5Controller::GetHID() {
|
||||
return *m_hid;
|
||||
}
|
||||
|
||||
const GenericHID& NiDsPS5Controller::GetHID() const {
|
||||
return *m_hid;
|
||||
}
|
||||
|
||||
double NiDsPS5Controller::GetLeftX() const {
|
||||
return GetRawAxis(Axis::kLeftX);
|
||||
return m_hid->GetRawAxis(Axis::kLeftX);
|
||||
}
|
||||
|
||||
double NiDsPS5Controller::GetLeftY() const {
|
||||
return GetRawAxis(Axis::kLeftY);
|
||||
return m_hid->GetRawAxis(Axis::kLeftY);
|
||||
}
|
||||
|
||||
double NiDsPS5Controller::GetRightX() const {
|
||||
return GetRawAxis(Axis::kRightX);
|
||||
return m_hid->GetRawAxis(Axis::kRightX);
|
||||
}
|
||||
|
||||
double NiDsPS5Controller::GetRightY() const {
|
||||
return GetRawAxis(Axis::kRightY);
|
||||
return m_hid->GetRawAxis(Axis::kRightY);
|
||||
}
|
||||
|
||||
double NiDsPS5Controller::GetL2Axis() const {
|
||||
return GetRawAxis(Axis::kL2);
|
||||
return m_hid->GetRawAxis(Axis::kL2);
|
||||
}
|
||||
|
||||
double NiDsPS5Controller::GetR2Axis() const {
|
||||
return GetRawAxis(Axis::kR2);
|
||||
return m_hid->GetRawAxis(Axis::kR2);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetSquareButton() const {
|
||||
return GetRawButton(Button::kSquare);
|
||||
return m_hid->GetRawButton(Button::kSquare);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetSquareButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kSquare);
|
||||
return m_hid->GetRawButtonPressed(Button::kSquare);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetSquareButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kSquare);
|
||||
return m_hid->GetRawButtonReleased(Button::kSquare);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS5Controller::Square(EventLoop* loop) const {
|
||||
@@ -58,15 +70,15 @@ BooleanEvent NiDsPS5Controller::Square(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetCrossButton() const {
|
||||
return GetRawButton(Button::kCross);
|
||||
return m_hid->GetRawButton(Button::kCross);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetCrossButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kCross);
|
||||
return m_hid->GetRawButtonPressed(Button::kCross);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetCrossButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kCross);
|
||||
return m_hid->GetRawButtonReleased(Button::kCross);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS5Controller::Cross(EventLoop* loop) const {
|
||||
@@ -74,15 +86,15 @@ BooleanEvent NiDsPS5Controller::Cross(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetCircleButton() const {
|
||||
return GetRawButton(Button::kCircle);
|
||||
return m_hid->GetRawButton(Button::kCircle);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetCircleButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kCircle);
|
||||
return m_hid->GetRawButtonPressed(Button::kCircle);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetCircleButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kCircle);
|
||||
return m_hid->GetRawButtonReleased(Button::kCircle);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS5Controller::Circle(EventLoop* loop) const {
|
||||
@@ -90,15 +102,15 @@ BooleanEvent NiDsPS5Controller::Circle(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetTriangleButton() const {
|
||||
return GetRawButton(Button::kTriangle);
|
||||
return m_hid->GetRawButton(Button::kTriangle);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetTriangleButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kTriangle);
|
||||
return m_hid->GetRawButtonPressed(Button::kTriangle);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetTriangleButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kTriangle);
|
||||
return m_hid->GetRawButtonReleased(Button::kTriangle);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS5Controller::Triangle(EventLoop* loop) const {
|
||||
@@ -106,15 +118,15 @@ BooleanEvent NiDsPS5Controller::Triangle(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetL1Button() const {
|
||||
return GetRawButton(Button::kL1);
|
||||
return m_hid->GetRawButton(Button::kL1);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetL1ButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kL1);
|
||||
return m_hid->GetRawButtonPressed(Button::kL1);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetL1ButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kL1);
|
||||
return m_hid->GetRawButtonReleased(Button::kL1);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS5Controller::L1(EventLoop* loop) const {
|
||||
@@ -122,15 +134,15 @@ BooleanEvent NiDsPS5Controller::L1(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetR1Button() const {
|
||||
return GetRawButton(Button::kR1);
|
||||
return m_hid->GetRawButton(Button::kR1);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetR1ButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kR1);
|
||||
return m_hid->GetRawButtonPressed(Button::kR1);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetR1ButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kR1);
|
||||
return m_hid->GetRawButtonReleased(Button::kR1);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS5Controller::R1(EventLoop* loop) const {
|
||||
@@ -138,15 +150,15 @@ BooleanEvent NiDsPS5Controller::R1(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetL2Button() const {
|
||||
return GetRawButton(Button::kL2);
|
||||
return m_hid->GetRawButton(Button::kL2);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetL2ButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kL2);
|
||||
return m_hid->GetRawButtonPressed(Button::kL2);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetL2ButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kL2);
|
||||
return m_hid->GetRawButtonReleased(Button::kL2);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS5Controller::L2(EventLoop* loop) const {
|
||||
@@ -154,15 +166,15 @@ BooleanEvent NiDsPS5Controller::L2(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetR2Button() const {
|
||||
return GetRawButton(Button::kR2);
|
||||
return m_hid->GetRawButton(Button::kR2);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetR2ButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kR2);
|
||||
return m_hid->GetRawButtonPressed(Button::kR2);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetR2ButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kR2);
|
||||
return m_hid->GetRawButtonReleased(Button::kR2);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS5Controller::R2(EventLoop* loop) const {
|
||||
@@ -170,15 +182,15 @@ BooleanEvent NiDsPS5Controller::R2(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetCreateButton() const {
|
||||
return GetRawButton(Button::kCreate);
|
||||
return m_hid->GetRawButton(Button::kCreate);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetCreateButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kCreate);
|
||||
return m_hid->GetRawButtonPressed(Button::kCreate);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetCreateButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kCreate);
|
||||
return m_hid->GetRawButtonReleased(Button::kCreate);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS5Controller::Create(EventLoop* loop) const {
|
||||
@@ -186,15 +198,15 @@ BooleanEvent NiDsPS5Controller::Create(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetOptionsButton() const {
|
||||
return GetRawButton(Button::kOptions);
|
||||
return m_hid->GetRawButton(Button::kOptions);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetOptionsButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kOptions);
|
||||
return m_hid->GetRawButtonPressed(Button::kOptions);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetOptionsButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kOptions);
|
||||
return m_hid->GetRawButtonReleased(Button::kOptions);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS5Controller::Options(EventLoop* loop) const {
|
||||
@@ -202,15 +214,15 @@ BooleanEvent NiDsPS5Controller::Options(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetL3Button() const {
|
||||
return GetRawButton(Button::kL3);
|
||||
return m_hid->GetRawButton(Button::kL3);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetL3ButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kL3);
|
||||
return m_hid->GetRawButtonPressed(Button::kL3);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetL3ButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kL3);
|
||||
return m_hid->GetRawButtonReleased(Button::kL3);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS5Controller::L3(EventLoop* loop) const {
|
||||
@@ -218,15 +230,15 @@ BooleanEvent NiDsPS5Controller::L3(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetR3Button() const {
|
||||
return GetRawButton(Button::kR3);
|
||||
return m_hid->GetRawButton(Button::kR3);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetR3ButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kR3);
|
||||
return m_hid->GetRawButtonPressed(Button::kR3);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetR3ButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kR3);
|
||||
return m_hid->GetRawButtonReleased(Button::kR3);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS5Controller::R3(EventLoop* loop) const {
|
||||
@@ -234,15 +246,15 @@ BooleanEvent NiDsPS5Controller::R3(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetPSButton() const {
|
||||
return GetRawButton(Button::kPS);
|
||||
return m_hid->GetRawButton(Button::kPS);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetPSButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kPS);
|
||||
return m_hid->GetRawButtonPressed(Button::kPS);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetPSButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kPS);
|
||||
return m_hid->GetRawButtonReleased(Button::kPS);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS5Controller::PS(EventLoop* loop) const {
|
||||
@@ -250,42 +262,87 @@ BooleanEvent NiDsPS5Controller::PS(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetTouchpadButton() const {
|
||||
return GetRawButton(Button::kTouchpad);
|
||||
return m_hid->GetRawButton(Button::kTouchpad);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetTouchpadButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kTouchpad);
|
||||
return m_hid->GetRawButtonPressed(Button::kTouchpad);
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::GetTouchpadButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kTouchpad);
|
||||
return m_hid->GetRawButtonReleased(Button::kTouchpad);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsPS5Controller::Touchpad(EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this]() { return this->GetTouchpadButton(); });
|
||||
}
|
||||
|
||||
bool NiDsPS5Controller::IsConnected() const {
|
||||
return m_hid->IsConnected();
|
||||
}
|
||||
|
||||
GenericHID::HIDType NiDsPS5Controller::GetGamepadType() const {
|
||||
return m_hid->GetGamepadType();
|
||||
}
|
||||
|
||||
GenericHID::SupportedOutputs NiDsPS5Controller::GetSupportedOutputs() const {
|
||||
return m_hid->GetSupportedOutputs();
|
||||
}
|
||||
|
||||
std::string NiDsPS5Controller::GetName() const {
|
||||
return m_hid->GetName();
|
||||
}
|
||||
|
||||
int NiDsPS5Controller::GetPort() const {
|
||||
return m_hid->GetPort();
|
||||
}
|
||||
|
||||
void NiDsPS5Controller::SetRumble(GenericHID::RumbleType type,
|
||||
double value) {
|
||||
m_hid->SetRumble(type, value);
|
||||
}
|
||||
|
||||
void NiDsPS5Controller::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "NiDsPS5");
|
||||
builder.AddDoubleProperty("L2 Axis", [this] { return GetL2Axis(); }, nullptr);
|
||||
builder.AddDoubleProperty("R2 Axis", [this] { return GetR2Axis(); }, nullptr);
|
||||
builder.AddDoubleProperty("LeftX", [this] { return GetLeftX(); }, nullptr);
|
||||
builder.AddDoubleProperty("LeftY", [this] { return GetLeftY(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightX", [this] { return GetRightX(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightY", [this] { return GetRightY(); }, nullptr);
|
||||
builder.AddBooleanProperty("Square", [this] { return GetSquareButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Cross", [this] { return GetCrossButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Circle", [this] { return GetCircleButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Triangle", [this] { return GetTriangleButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("L1", [this] { return GetL1Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("R1", [this] { return GetR1Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("L2", [this] { return GetL2Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("R2", [this] { return GetR2Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("Create", [this] { return GetCreateButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Options", [this] { return GetOptionsButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("L3", [this] { return GetL3Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("R3", [this] { return GetR3Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("PS", [this] { return GetPSButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Touchpad", [this] { return GetTouchpadButton(); }, nullptr);
|
||||
builder.AddDoubleProperty("L2 Axis",
|
||||
[this] { return GetL2Axis(); }, nullptr);
|
||||
builder.AddDoubleProperty("R2 Axis",
|
||||
[this] { return GetR2Axis(); }, nullptr);
|
||||
builder.AddDoubleProperty("LeftX",
|
||||
[this] { return GetLeftX(); }, nullptr);
|
||||
builder.AddDoubleProperty("LeftY",
|
||||
[this] { return GetLeftY(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightX",
|
||||
[this] { return GetRightX(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightY",
|
||||
[this] { return GetRightY(); }, nullptr);
|
||||
builder.AddBooleanProperty("Square",
|
||||
[this] { return GetSquareButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Cross",
|
||||
[this] { return GetCrossButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Circle",
|
||||
[this] { return GetCircleButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Triangle",
|
||||
[this] { return GetTriangleButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("L1",
|
||||
[this] { return GetL1Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("R1",
|
||||
[this] { return GetR1Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("L2",
|
||||
[this] { return GetL2Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("R2",
|
||||
[this] { return GetR2Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("Create",
|
||||
[this] { return GetCreateButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Options",
|
||||
[this] { return GetOptionsButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("L3",
|
||||
[this] { return GetL3Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("R3",
|
||||
[this] { return GetR3Button(); }, nullptr);
|
||||
builder.AddBooleanProperty("PS",
|
||||
[this] { return GetPSButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Touchpad",
|
||||
[this] { return GetTouchpadButton(); }, nullptr);
|
||||
}
|
||||
@@ -6,43 +6,55 @@
|
||||
|
||||
#include "wpi/driverstation/NiDsStadiaController.hpp"
|
||||
|
||||
#include "wpi/driverstation/DriverStation.hpp"
|
||||
#include "wpi/event/BooleanEvent.hpp"
|
||||
#include "wpi/hal/UsageReporting.hpp"
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
#include "wpi/event/BooleanEvent.hpp"
|
||||
|
||||
using namespace wpi;
|
||||
|
||||
NiDsStadiaController::NiDsStadiaController(int port) : GenericHID(port) {
|
||||
HAL_ReportUsage("HID", port, "NiDsStadiaController");
|
||||
NiDsStadiaController::NiDsStadiaController(int port)
|
||||
: NiDsStadiaController{DriverStation::GetGenericHID(port)} {}
|
||||
|
||||
NiDsStadiaController::NiDsStadiaController(GenericHID& hid)
|
||||
: m_hid{&hid} {
|
||||
HAL_ReportUsage("HID", hid.GetPort(), "NiDsStadiaController");
|
||||
}
|
||||
|
||||
GenericHID& NiDsStadiaController::GetHID() {
|
||||
return *m_hid;
|
||||
}
|
||||
|
||||
const GenericHID& NiDsStadiaController::GetHID() const {
|
||||
return *m_hid;
|
||||
}
|
||||
|
||||
double NiDsStadiaController::GetLeftX() const {
|
||||
return GetRawAxis(Axis::kLeftX);
|
||||
return m_hid->GetRawAxis(Axis::kLeftX);
|
||||
}
|
||||
|
||||
double NiDsStadiaController::GetRightX() const {
|
||||
return GetRawAxis(Axis::kRightX);
|
||||
return m_hid->GetRawAxis(Axis::kRightX);
|
||||
}
|
||||
|
||||
double NiDsStadiaController::GetLeftY() const {
|
||||
return GetRawAxis(Axis::kLeftY);
|
||||
return m_hid->GetRawAxis(Axis::kLeftY);
|
||||
}
|
||||
|
||||
double NiDsStadiaController::GetRightY() const {
|
||||
return GetRawAxis(Axis::kRightY);
|
||||
return m_hid->GetRawAxis(Axis::kRightY);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetAButton() const {
|
||||
return GetRawButton(Button::kA);
|
||||
return m_hid->GetRawButton(Button::kA);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetAButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kA);
|
||||
return m_hid->GetRawButtonPressed(Button::kA);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetAButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kA);
|
||||
return m_hid->GetRawButtonReleased(Button::kA);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsStadiaController::A(EventLoop* loop) const {
|
||||
@@ -50,15 +62,15 @@ BooleanEvent NiDsStadiaController::A(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetBButton() const {
|
||||
return GetRawButton(Button::kB);
|
||||
return m_hid->GetRawButton(Button::kB);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetBButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kB);
|
||||
return m_hid->GetRawButtonPressed(Button::kB);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetBButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kB);
|
||||
return m_hid->GetRawButtonReleased(Button::kB);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsStadiaController::B(EventLoop* loop) const {
|
||||
@@ -66,15 +78,15 @@ BooleanEvent NiDsStadiaController::B(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetXButton() const {
|
||||
return GetRawButton(Button::kX);
|
||||
return m_hid->GetRawButton(Button::kX);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetXButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kX);
|
||||
return m_hid->GetRawButtonPressed(Button::kX);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetXButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kX);
|
||||
return m_hid->GetRawButtonReleased(Button::kX);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsStadiaController::X(EventLoop* loop) const {
|
||||
@@ -82,15 +94,15 @@ BooleanEvent NiDsStadiaController::X(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetYButton() const {
|
||||
return GetRawButton(Button::kY);
|
||||
return m_hid->GetRawButton(Button::kY);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetYButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kY);
|
||||
return m_hid->GetRawButtonPressed(Button::kY);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetYButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kY);
|
||||
return m_hid->GetRawButtonReleased(Button::kY);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsStadiaController::Y(EventLoop* loop) const {
|
||||
@@ -98,15 +110,15 @@ BooleanEvent NiDsStadiaController::Y(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetLeftBumperButton() const {
|
||||
return GetRawButton(Button::kLeftBumper);
|
||||
return m_hid->GetRawButton(Button::kLeftBumper);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetLeftBumperButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kLeftBumper);
|
||||
return m_hid->GetRawButtonPressed(Button::kLeftBumper);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetLeftBumperButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kLeftBumper);
|
||||
return m_hid->GetRawButtonReleased(Button::kLeftBumper);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsStadiaController::LeftBumper(EventLoop* loop) const {
|
||||
@@ -114,15 +126,15 @@ BooleanEvent NiDsStadiaController::LeftBumper(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetRightBumperButton() const {
|
||||
return GetRawButton(Button::kRightBumper);
|
||||
return m_hid->GetRawButton(Button::kRightBumper);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetRightBumperButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kRightBumper);
|
||||
return m_hid->GetRawButtonPressed(Button::kRightBumper);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetRightBumperButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kRightBumper);
|
||||
return m_hid->GetRawButtonReleased(Button::kRightBumper);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsStadiaController::RightBumper(EventLoop* loop) const {
|
||||
@@ -130,15 +142,15 @@ BooleanEvent NiDsStadiaController::RightBumper(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetLeftStickButton() const {
|
||||
return GetRawButton(Button::kLeftStick);
|
||||
return m_hid->GetRawButton(Button::kLeftStick);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetLeftStickButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kLeftStick);
|
||||
return m_hid->GetRawButtonPressed(Button::kLeftStick);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetLeftStickButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kLeftStick);
|
||||
return m_hid->GetRawButtonReleased(Button::kLeftStick);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsStadiaController::LeftStick(EventLoop* loop) const {
|
||||
@@ -146,15 +158,15 @@ BooleanEvent NiDsStadiaController::LeftStick(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetRightStickButton() const {
|
||||
return GetRawButton(Button::kRightStick);
|
||||
return m_hid->GetRawButton(Button::kRightStick);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetRightStickButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kRightStick);
|
||||
return m_hid->GetRawButtonPressed(Button::kRightStick);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetRightStickButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kRightStick);
|
||||
return m_hid->GetRawButtonReleased(Button::kRightStick);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsStadiaController::RightStick(EventLoop* loop) const {
|
||||
@@ -162,15 +174,15 @@ BooleanEvent NiDsStadiaController::RightStick(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetEllipsesButton() const {
|
||||
return GetRawButton(Button::kEllipses);
|
||||
return m_hid->GetRawButton(Button::kEllipses);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetEllipsesButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kEllipses);
|
||||
return m_hid->GetRawButtonPressed(Button::kEllipses);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetEllipsesButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kEllipses);
|
||||
return m_hid->GetRawButtonReleased(Button::kEllipses);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsStadiaController::Ellipses(EventLoop* loop) const {
|
||||
@@ -178,15 +190,15 @@ BooleanEvent NiDsStadiaController::Ellipses(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetHamburgerButton() const {
|
||||
return GetRawButton(Button::kHamburger);
|
||||
return m_hid->GetRawButton(Button::kHamburger);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetHamburgerButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kHamburger);
|
||||
return m_hid->GetRawButtonPressed(Button::kHamburger);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetHamburgerButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kHamburger);
|
||||
return m_hid->GetRawButtonReleased(Button::kHamburger);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsStadiaController::Hamburger(EventLoop* loop) const {
|
||||
@@ -194,15 +206,15 @@ BooleanEvent NiDsStadiaController::Hamburger(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetStadiaButton() const {
|
||||
return GetRawButton(Button::kStadia);
|
||||
return m_hid->GetRawButton(Button::kStadia);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetStadiaButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kStadia);
|
||||
return m_hid->GetRawButtonPressed(Button::kStadia);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetStadiaButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kStadia);
|
||||
return m_hid->GetRawButtonReleased(Button::kStadia);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsStadiaController::Stadia(EventLoop* loop) const {
|
||||
@@ -210,15 +222,15 @@ BooleanEvent NiDsStadiaController::Stadia(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetRightTriggerButton() const {
|
||||
return GetRawButton(Button::kRightTrigger);
|
||||
return m_hid->GetRawButton(Button::kRightTrigger);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetRightTriggerButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kRightTrigger);
|
||||
return m_hid->GetRawButtonPressed(Button::kRightTrigger);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetRightTriggerButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kRightTrigger);
|
||||
return m_hid->GetRawButtonReleased(Button::kRightTrigger);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsStadiaController::RightTrigger(EventLoop* loop) const {
|
||||
@@ -226,15 +238,15 @@ BooleanEvent NiDsStadiaController::RightTrigger(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetLeftTriggerButton() const {
|
||||
return GetRawButton(Button::kLeftTrigger);
|
||||
return m_hid->GetRawButton(Button::kLeftTrigger);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetLeftTriggerButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kLeftTrigger);
|
||||
return m_hid->GetRawButtonPressed(Button::kLeftTrigger);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetLeftTriggerButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kLeftTrigger);
|
||||
return m_hid->GetRawButtonReleased(Button::kLeftTrigger);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsStadiaController::LeftTrigger(EventLoop* loop) const {
|
||||
@@ -242,15 +254,15 @@ BooleanEvent NiDsStadiaController::LeftTrigger(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetGoogleButton() const {
|
||||
return GetRawButton(Button::kGoogle);
|
||||
return m_hid->GetRawButton(Button::kGoogle);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetGoogleButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kGoogle);
|
||||
return m_hid->GetRawButtonPressed(Button::kGoogle);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetGoogleButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kGoogle);
|
||||
return m_hid->GetRawButtonReleased(Button::kGoogle);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsStadiaController::Google(EventLoop* loop) const {
|
||||
@@ -258,41 +270,85 @@ BooleanEvent NiDsStadiaController::Google(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetFrameButton() const {
|
||||
return GetRawButton(Button::kFrame);
|
||||
return m_hid->GetRawButton(Button::kFrame);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetFrameButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kFrame);
|
||||
return m_hid->GetRawButtonPressed(Button::kFrame);
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::GetFrameButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kFrame);
|
||||
return m_hid->GetRawButtonReleased(Button::kFrame);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsStadiaController::Frame(EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this]() { return this->GetFrameButton(); });
|
||||
}
|
||||
|
||||
bool NiDsStadiaController::IsConnected() const {
|
||||
return m_hid->IsConnected();
|
||||
}
|
||||
|
||||
GenericHID::HIDType NiDsStadiaController::GetGamepadType() const {
|
||||
return m_hid->GetGamepadType();
|
||||
}
|
||||
|
||||
GenericHID::SupportedOutputs NiDsStadiaController::GetSupportedOutputs() const {
|
||||
return m_hid->GetSupportedOutputs();
|
||||
}
|
||||
|
||||
std::string NiDsStadiaController::GetName() const {
|
||||
return m_hid->GetName();
|
||||
}
|
||||
|
||||
int NiDsStadiaController::GetPort() const {
|
||||
return m_hid->GetPort();
|
||||
}
|
||||
|
||||
void NiDsStadiaController::SetRumble(GenericHID::RumbleType type,
|
||||
double value) {
|
||||
m_hid->SetRumble(type, value);
|
||||
}
|
||||
|
||||
void NiDsStadiaController::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "NiDsStadia");
|
||||
builder.AddDoubleProperty("LeftX", [this] { return GetLeftX(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightX", [this] { return GetRightX(); }, nullptr);
|
||||
builder.AddDoubleProperty("LeftY", [this] { return GetLeftY(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightY", [this] { return GetRightY(); }, nullptr);
|
||||
builder.AddBooleanProperty("A", [this] { return GetAButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("B", [this] { return GetBButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("X", [this] { return GetXButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Y", [this] { return GetYButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("LeftBumper", [this] { return GetLeftBumperButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("RightBumper", [this] { return GetRightBumperButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("LeftStick", [this] { return GetLeftStickButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("RightStick", [this] { return GetRightStickButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Ellipses", [this] { return GetEllipsesButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Hamburger", [this] { return GetHamburgerButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Stadia", [this] { return GetStadiaButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("RightTrigger", [this] { return GetRightTriggerButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("LeftTrigger", [this] { return GetLeftTriggerButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Google", [this] { return GetGoogleButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Frame", [this] { return GetFrameButton(); }, nullptr);
|
||||
builder.AddDoubleProperty("LeftX",
|
||||
[this] { return GetLeftX(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightX",
|
||||
[this] { return GetRightX(); }, nullptr);
|
||||
builder.AddDoubleProperty("LeftY",
|
||||
[this] { return GetLeftY(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightY",
|
||||
[this] { return GetRightY(); }, nullptr);
|
||||
builder.AddBooleanProperty("A",
|
||||
[this] { return GetAButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("B",
|
||||
[this] { return GetBButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("X",
|
||||
[this] { return GetXButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Y",
|
||||
[this] { return GetYButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("LeftBumper",
|
||||
[this] { return GetLeftBumperButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("RightBumper",
|
||||
[this] { return GetRightBumperButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("LeftStick",
|
||||
[this] { return GetLeftStickButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("RightStick",
|
||||
[this] { return GetRightStickButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Ellipses",
|
||||
[this] { return GetEllipsesButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Hamburger",
|
||||
[this] { return GetHamburgerButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Stadia",
|
||||
[this] { return GetStadiaButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("RightTrigger",
|
||||
[this] { return GetRightTriggerButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("LeftTrigger",
|
||||
[this] { return GetLeftTriggerButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Google",
|
||||
[this] { return GetGoogleButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Frame",
|
||||
[this] { return GetFrameButton(); }, nullptr);
|
||||
}
|
||||
@@ -6,39 +6,53 @@
|
||||
|
||||
#include "wpi/driverstation/NiDsXboxController.hpp"
|
||||
|
||||
#include "wpi/driverstation/DriverStation.hpp"
|
||||
#include "wpi/event/BooleanEvent.hpp"
|
||||
#include "wpi/hal/UsageReporting.hpp"
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
#include "wpi/event/BooleanEvent.hpp"
|
||||
|
||||
using namespace wpi;
|
||||
|
||||
NiDsXboxController::NiDsXboxController(int port) : GenericHID(port) {
|
||||
HAL_ReportUsage("HID", port, "NiDsXboxController");
|
||||
NiDsXboxController::NiDsXboxController(int port)
|
||||
: NiDsXboxController{DriverStation::GetGenericHID(port)} {}
|
||||
|
||||
NiDsXboxController::NiDsXboxController(GenericHID& hid)
|
||||
: m_hid{&hid} {
|
||||
HAL_ReportUsage("HID", hid.GetPort(), "NiDsXboxController");
|
||||
}
|
||||
|
||||
GenericHID& NiDsXboxController::GetHID() {
|
||||
return *m_hid;
|
||||
}
|
||||
|
||||
const GenericHID& NiDsXboxController::GetHID() const {
|
||||
return *m_hid;
|
||||
}
|
||||
|
||||
double NiDsXboxController::GetLeftX() const {
|
||||
return GetRawAxis(Axis::kLeftX);
|
||||
return m_hid->GetRawAxis(Axis::kLeftX);
|
||||
}
|
||||
|
||||
double NiDsXboxController::GetRightX() const {
|
||||
return GetRawAxis(Axis::kRightX);
|
||||
return m_hid->GetRawAxis(Axis::kRightX);
|
||||
}
|
||||
|
||||
double NiDsXboxController::GetLeftY() const {
|
||||
return GetRawAxis(Axis::kLeftY);
|
||||
return m_hid->GetRawAxis(Axis::kLeftY);
|
||||
}
|
||||
|
||||
double NiDsXboxController::GetRightY() const {
|
||||
return GetRawAxis(Axis::kRightY);
|
||||
return m_hid->GetRawAxis(Axis::kRightY);
|
||||
}
|
||||
|
||||
double NiDsXboxController::GetLeftTriggerAxis() const {
|
||||
return GetRawAxis(Axis::kLeftTrigger);
|
||||
return m_hid->GetRawAxis(Axis::kLeftTrigger);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsXboxController::LeftTrigger(double threshold, EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this, threshold] { return this->GetLeftTriggerAxis() > threshold; });
|
||||
BooleanEvent NiDsXboxController::LeftTrigger(double threshold,
|
||||
EventLoop* loop) const {
|
||||
return BooleanEvent(
|
||||
loop, [this, threshold] { return this->GetLeftTriggerAxis() > threshold; });
|
||||
}
|
||||
|
||||
BooleanEvent NiDsXboxController::LeftTrigger(EventLoop* loop) const {
|
||||
@@ -46,11 +60,13 @@ BooleanEvent NiDsXboxController::LeftTrigger(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
double NiDsXboxController::GetRightTriggerAxis() const {
|
||||
return GetRawAxis(Axis::kRightTrigger);
|
||||
return m_hid->GetRawAxis(Axis::kRightTrigger);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsXboxController::RightTrigger(double threshold, EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this, threshold] { return this->GetRightTriggerAxis() > threshold; });
|
||||
BooleanEvent NiDsXboxController::RightTrigger(double threshold,
|
||||
EventLoop* loop) const {
|
||||
return BooleanEvent(
|
||||
loop, [this, threshold] { return this->GetRightTriggerAxis() > threshold; });
|
||||
}
|
||||
|
||||
BooleanEvent NiDsXboxController::RightTrigger(EventLoop* loop) const {
|
||||
@@ -58,15 +74,15 @@ BooleanEvent NiDsXboxController::RightTrigger(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetAButton() const {
|
||||
return GetRawButton(Button::kA);
|
||||
return m_hid->GetRawButton(Button::kA);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetAButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kA);
|
||||
return m_hid->GetRawButtonPressed(Button::kA);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetAButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kA);
|
||||
return m_hid->GetRawButtonReleased(Button::kA);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsXboxController::A(EventLoop* loop) const {
|
||||
@@ -74,15 +90,15 @@ BooleanEvent NiDsXboxController::A(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetBButton() const {
|
||||
return GetRawButton(Button::kB);
|
||||
return m_hid->GetRawButton(Button::kB);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetBButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kB);
|
||||
return m_hid->GetRawButtonPressed(Button::kB);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetBButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kB);
|
||||
return m_hid->GetRawButtonReleased(Button::kB);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsXboxController::B(EventLoop* loop) const {
|
||||
@@ -90,15 +106,15 @@ BooleanEvent NiDsXboxController::B(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetXButton() const {
|
||||
return GetRawButton(Button::kX);
|
||||
return m_hid->GetRawButton(Button::kX);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetXButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kX);
|
||||
return m_hid->GetRawButtonPressed(Button::kX);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetXButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kX);
|
||||
return m_hid->GetRawButtonReleased(Button::kX);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsXboxController::X(EventLoop* loop) const {
|
||||
@@ -106,15 +122,15 @@ BooleanEvent NiDsXboxController::X(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetYButton() const {
|
||||
return GetRawButton(Button::kY);
|
||||
return m_hid->GetRawButton(Button::kY);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetYButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kY);
|
||||
return m_hid->GetRawButtonPressed(Button::kY);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetYButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kY);
|
||||
return m_hid->GetRawButtonReleased(Button::kY);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsXboxController::Y(EventLoop* loop) const {
|
||||
@@ -122,15 +138,15 @@ BooleanEvent NiDsXboxController::Y(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetLeftBumperButton() const {
|
||||
return GetRawButton(Button::kLeftBumper);
|
||||
return m_hid->GetRawButton(Button::kLeftBumper);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetLeftBumperButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kLeftBumper);
|
||||
return m_hid->GetRawButtonPressed(Button::kLeftBumper);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetLeftBumperButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kLeftBumper);
|
||||
return m_hid->GetRawButtonReleased(Button::kLeftBumper);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsXboxController::LeftBumper(EventLoop* loop) const {
|
||||
@@ -138,15 +154,15 @@ BooleanEvent NiDsXboxController::LeftBumper(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetRightBumperButton() const {
|
||||
return GetRawButton(Button::kRightBumper);
|
||||
return m_hid->GetRawButton(Button::kRightBumper);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetRightBumperButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kRightBumper);
|
||||
return m_hid->GetRawButtonPressed(Button::kRightBumper);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetRightBumperButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kRightBumper);
|
||||
return m_hid->GetRawButtonReleased(Button::kRightBumper);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsXboxController::RightBumper(EventLoop* loop) const {
|
||||
@@ -154,15 +170,15 @@ BooleanEvent NiDsXboxController::RightBumper(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetBackButton() const {
|
||||
return GetRawButton(Button::kBack);
|
||||
return m_hid->GetRawButton(Button::kBack);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetBackButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kBack);
|
||||
return m_hid->GetRawButtonPressed(Button::kBack);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetBackButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kBack);
|
||||
return m_hid->GetRawButtonReleased(Button::kBack);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsXboxController::Back(EventLoop* loop) const {
|
||||
@@ -170,15 +186,15 @@ BooleanEvent NiDsXboxController::Back(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetStartButton() const {
|
||||
return GetRawButton(Button::kStart);
|
||||
return m_hid->GetRawButton(Button::kStart);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetStartButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kStart);
|
||||
return m_hid->GetRawButtonPressed(Button::kStart);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetStartButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kStart);
|
||||
return m_hid->GetRawButtonReleased(Button::kStart);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsXboxController::Start(EventLoop* loop) const {
|
||||
@@ -186,15 +202,15 @@ BooleanEvent NiDsXboxController::Start(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetLeftStickButton() const {
|
||||
return GetRawButton(Button::kLeftStick);
|
||||
return m_hid->GetRawButton(Button::kLeftStick);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetLeftStickButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kLeftStick);
|
||||
return m_hid->GetRawButtonPressed(Button::kLeftStick);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetLeftStickButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kLeftStick);
|
||||
return m_hid->GetRawButtonReleased(Button::kLeftStick);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsXboxController::LeftStick(EventLoop* loop) const {
|
||||
@@ -202,38 +218,79 @@ BooleanEvent NiDsXboxController::LeftStick(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetRightStickButton() const {
|
||||
return GetRawButton(Button::kRightStick);
|
||||
return m_hid->GetRawButton(Button::kRightStick);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetRightStickButtonPressed() {
|
||||
return GetRawButtonPressed(Button::kRightStick);
|
||||
return m_hid->GetRawButtonPressed(Button::kRightStick);
|
||||
}
|
||||
|
||||
bool NiDsXboxController::GetRightStickButtonReleased() {
|
||||
return GetRawButtonReleased(Button::kRightStick);
|
||||
return m_hid->GetRawButtonReleased(Button::kRightStick);
|
||||
}
|
||||
|
||||
BooleanEvent NiDsXboxController::RightStick(EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this]() { return this->GetRightStickButton(); });
|
||||
}
|
||||
|
||||
bool NiDsXboxController::IsConnected() const {
|
||||
return m_hid->IsConnected();
|
||||
}
|
||||
|
||||
GenericHID::HIDType NiDsXboxController::GetGamepadType() const {
|
||||
return m_hid->GetGamepadType();
|
||||
}
|
||||
|
||||
GenericHID::SupportedOutputs NiDsXboxController::GetSupportedOutputs() const {
|
||||
return m_hid->GetSupportedOutputs();
|
||||
}
|
||||
|
||||
std::string NiDsXboxController::GetName() const {
|
||||
return m_hid->GetName();
|
||||
}
|
||||
|
||||
int NiDsXboxController::GetPort() const {
|
||||
return m_hid->GetPort();
|
||||
}
|
||||
|
||||
void NiDsXboxController::SetRumble(GenericHID::RumbleType type,
|
||||
double value) {
|
||||
m_hid->SetRumble(type, value);
|
||||
}
|
||||
|
||||
void NiDsXboxController::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "NiDsXbox");
|
||||
builder.AddDoubleProperty("LeftTrigger Axis", [this] { return GetLeftTriggerAxis(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightTrigger Axis", [this] { return GetRightTriggerAxis(); }, nullptr);
|
||||
builder.AddDoubleProperty("LeftX", [this] { return GetLeftX(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightX", [this] { return GetRightX(); }, nullptr);
|
||||
builder.AddDoubleProperty("LeftY", [this] { return GetLeftY(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightY", [this] { return GetRightY(); }, nullptr);
|
||||
builder.AddBooleanProperty("A", [this] { return GetAButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("B", [this] { return GetBButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("X", [this] { return GetXButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Y", [this] { return GetYButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("LeftBumper", [this] { return GetLeftBumperButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("RightBumper", [this] { return GetRightBumperButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Back", [this] { return GetBackButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Start", [this] { return GetStartButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("LeftStick", [this] { return GetLeftStickButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("RightStick", [this] { return GetRightStickButton(); }, nullptr);
|
||||
builder.AddDoubleProperty("LeftTrigger Axis",
|
||||
[this] { return GetLeftTriggerAxis(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightTrigger Axis",
|
||||
[this] { return GetRightTriggerAxis(); }, nullptr);
|
||||
builder.AddDoubleProperty("LeftX",
|
||||
[this] { return GetLeftX(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightX",
|
||||
[this] { return GetRightX(); }, nullptr);
|
||||
builder.AddDoubleProperty("LeftY",
|
||||
[this] { return GetLeftY(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightY",
|
||||
[this] { return GetRightY(); }, nullptr);
|
||||
builder.AddBooleanProperty("A",
|
||||
[this] { return GetAButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("B",
|
||||
[this] { return GetBButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("X",
|
||||
[this] { return GetXButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Y",
|
||||
[this] { return GetYButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("LeftBumper",
|
||||
[this] { return GetLeftBumperButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("RightBumper",
|
||||
[this] { return GetRightBumperButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Back",
|
||||
[this] { return GetBackButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("Start",
|
||||
[this] { return GetStartButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("LeftStick",
|
||||
[this] { return GetLeftStickButton(); }, nullptr);
|
||||
builder.AddBooleanProperty("RightStick",
|
||||
[this] { return GetRightStickButton(); }, nullptr);
|
||||
}
|
||||
@@ -12,7 +12,7 @@ using namespace wpi;
|
||||
using namespace wpi::sim;
|
||||
|
||||
NiDsPS4ControllerSim::NiDsPS4ControllerSim(const NiDsPS4Controller& joystick)
|
||||
: GenericHIDSim{joystick} {
|
||||
: GenericHIDSim{joystick.GetHID()} {
|
||||
SetAxesMaximumIndex(6);
|
||||
SetButtonsMaximumIndex(14);
|
||||
SetPOVsMaximumIndex(1);
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace wpi;
|
||||
using namespace wpi::sim;
|
||||
|
||||
NiDsPS5ControllerSim::NiDsPS5ControllerSim(const NiDsPS5Controller& joystick)
|
||||
: GenericHIDSim{joystick} {
|
||||
: GenericHIDSim{joystick.GetHID()} {
|
||||
SetAxesMaximumIndex(6);
|
||||
SetButtonsMaximumIndex(14);
|
||||
SetPOVsMaximumIndex(1);
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace wpi;
|
||||
using namespace wpi::sim;
|
||||
|
||||
NiDsStadiaControllerSim::NiDsStadiaControllerSim(const NiDsStadiaController& joystick)
|
||||
: GenericHIDSim{joystick} {
|
||||
: GenericHIDSim{joystick.GetHID()} {
|
||||
SetAxesMaximumIndex(4);
|
||||
SetButtonsMaximumIndex(15);
|
||||
SetPOVsMaximumIndex(1);
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace wpi;
|
||||
using namespace wpi::sim;
|
||||
|
||||
NiDsXboxControllerSim::NiDsXboxControllerSim(const NiDsXboxController& joystick)
|
||||
: GenericHIDSim{joystick} {
|
||||
: GenericHIDSim{joystick.GetHID()} {
|
||||
SetAxesMaximumIndex(6);
|
||||
SetButtonsMaximumIndex(10);
|
||||
SetPOVsMaximumIndex(1);
|
||||
|
||||
Reference in New Issue
Block a user