mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
[wpilib] Implement Sendable for HID classes (#6782)
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "frc/{{ ConsoleName }}Controller.h"
|
||||
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <wpi/sendable/SendableBuilder.h>
|
||||
|
||||
#include "frc/event/BooleanEvent.h"
|
||||
|
||||
@@ -77,7 +78,7 @@ bool {{ ConsoleName }}Controller::GetLeftBumperReleased() {
|
||||
bool {{ ConsoleName }}Controller::GetRightBumperReleased() {
|
||||
return GetRawButtonReleased(Button::kRightBumper);
|
||||
}
|
||||
{% elif ConsoleName == "PS4" or ConsoleName == "PS5" %}
|
||||
{%- elif ConsoleName == "PS4" or ConsoleName == "PS5" %}
|
||||
bool {{ ConsoleName }}Controller::GetTouchpad() const {
|
||||
return GetRawButton(Button::kTouchpad);
|
||||
}
|
||||
@@ -89,4 +90,18 @@ bool {{ ConsoleName }}Controller::GetTouchpadPressed() {
|
||||
bool {{ ConsoleName }}Controller::GetTouchpadReleased() {
|
||||
return GetRawButtonReleased(Button::kTouchpad);
|
||||
}
|
||||
{% endif %}
|
||||
{%- endif %}
|
||||
|
||||
void {{ ConsoleName }}Controller::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "{{ ConsoleName }}");
|
||||
{%- for trigger in triggers %}
|
||||
builder.AddDoubleProperty("{{ capitalize_first(trigger.name) }}", [this] { return Get{{ capitalize_first(trigger.name) }}Axis(); }, nullptr);
|
||||
{%- endfor -%}
|
||||
{% for stick in sticks %}
|
||||
builder.AddDoubleProperty("{{ stick.NameParts|map("capitalize")|join }}", [this] { return Get{{ stick.NameParts|map("capitalize")|join }}(); }, nullptr);
|
||||
{%- endfor -%}
|
||||
{% for button in buttons %}
|
||||
builder.AddBooleanProperty("{{ capitalize_first(button.name) }}", [this] { return Get{{ capitalize_first(button.name) }}Button(); }, nullptr);
|
||||
{%- endfor %}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
{%- endmacro %}
|
||||
#pragma once
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/GenericHID.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -24,7 +27,9 @@ namespace frc {
|
||||
* 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.
|
||||
*/
|
||||
class {{ ConsoleName }}Controller : public GenericHID {
|
||||
class {{ ConsoleName }}Controller : public GenericHID,
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<{{ ConsoleName }}Controller> {
|
||||
public:
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -203,6 +208,8 @@ class {{ ConsoleName }}Controller : public GenericHID {
|
||||
static constexpr int k{{ capitalize_first(trigger.name) }} = {{ trigger.value }};
|
||||
{%- endfor %}
|
||||
};
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "frc/PS4Controller.h"
|
||||
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <wpi/sendable/SendableBuilder.h>
|
||||
|
||||
#include "frc/event/BooleanEvent.h"
|
||||
|
||||
@@ -275,3 +276,28 @@ bool PS4Controller::GetTouchpadPressed() {
|
||||
bool PS4Controller::GetTouchpadReleased() {
|
||||
return GetRawButtonReleased(Button::kTouchpad);
|
||||
}
|
||||
|
||||
void PS4Controller::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "PS4");
|
||||
builder.AddDoubleProperty("L2", [this] { return GetL2Axis(); }, nullptr);
|
||||
builder.AddDoubleProperty("R2", [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);
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "frc/PS5Controller.h"
|
||||
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <wpi/sendable/SendableBuilder.h>
|
||||
|
||||
#include "frc/event/BooleanEvent.h"
|
||||
|
||||
@@ -275,3 +276,28 @@ bool PS5Controller::GetTouchpadPressed() {
|
||||
bool PS5Controller::GetTouchpadReleased() {
|
||||
return GetRawButtonReleased(Button::kTouchpad);
|
||||
}
|
||||
|
||||
void PS5Controller::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "PS5");
|
||||
builder.AddDoubleProperty("L2", [this] { return GetL2Axis(); }, nullptr);
|
||||
builder.AddDoubleProperty("R2", [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);
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "frc/StadiaController.h"
|
||||
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <wpi/sendable/SendableBuilder.h>
|
||||
|
||||
#include "frc/event/BooleanEvent.h"
|
||||
|
||||
@@ -295,3 +296,27 @@ bool StadiaController::GetLeftBumperReleased() {
|
||||
bool StadiaController::GetRightBumperReleased() {
|
||||
return GetRawButtonReleased(Button::kRightBumper);
|
||||
}
|
||||
|
||||
void StadiaController::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "Stadia");
|
||||
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);
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "frc/XboxController.h"
|
||||
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <wpi/sendable/SendableBuilder.h>
|
||||
|
||||
#include "frc/event/BooleanEvent.h"
|
||||
|
||||
@@ -239,3 +240,24 @@ bool XboxController::GetLeftBumperReleased() {
|
||||
bool XboxController::GetRightBumperReleased() {
|
||||
return GetRawButtonReleased(Button::kRightBumper);
|
||||
}
|
||||
|
||||
void XboxController::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "Xbox");
|
||||
builder.AddDoubleProperty("LeftTrigger", [this] { return GetLeftTriggerAxis(); }, nullptr);
|
||||
builder.AddDoubleProperty("RightTrigger", [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);
|
||||
}
|
||||
@@ -6,6 +6,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/GenericHID.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -22,7 +25,9 @@ namespace frc {
|
||||
* 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.
|
||||
*/
|
||||
class PS4Controller : public GenericHID {
|
||||
class PS4Controller : public GenericHID,
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<PS4Controller> {
|
||||
public:
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -587,6 +592,8 @@ class PS4Controller : public GenericHID {
|
||||
/// Right trigger 2.
|
||||
static constexpr int kR2 = 4;
|
||||
};
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/GenericHID.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -22,7 +25,9 @@ namespace frc {
|
||||
* 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.
|
||||
*/
|
||||
class PS5Controller : public GenericHID {
|
||||
class PS5Controller : public GenericHID,
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<PS5Controller> {
|
||||
public:
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -587,6 +592,8 @@ class PS5Controller : public GenericHID {
|
||||
/// Right trigger 2.
|
||||
static constexpr int kR2 = 4;
|
||||
};
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/GenericHID.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -22,7 +25,9 @@ namespace frc {
|
||||
* 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.
|
||||
*/
|
||||
class StadiaController : public GenericHID {
|
||||
class StadiaController : public GenericHID,
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<StadiaController> {
|
||||
public:
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -625,6 +630,8 @@ class StadiaController : public GenericHID {
|
||||
/// Right Y axis.
|
||||
static constexpr int kRightY = 4;
|
||||
};
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/GenericHID.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -22,7 +25,9 @@ namespace frc {
|
||||
* 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.
|
||||
*/
|
||||
class XboxController : public GenericHID {
|
||||
class XboxController : public GenericHID,
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<XboxController> {
|
||||
public:
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -524,6 +529,8 @@ class XboxController : public GenericHID {
|
||||
/// Right trigger.
|
||||
static constexpr int kRightTrigger = 3;
|
||||
};
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -10,6 +10,8 @@ package edu.wpi.first.wpilibj;
|
||||
|
||||
{{ "// " if SkipReporting }}import edu.wpi.first.hal.FRCNetComm.tResourceType;
|
||||
{{ "// " if SkipReporting }}import edu.wpi.first.hal.HAL;
|
||||
import edu.wpi.first.util.sendable.Sendable;
|
||||
import edu.wpi.first.util.sendable.SendableBuilder;
|
||||
import edu.wpi.first.wpilibj.event.BooleanEvent;
|
||||
import edu.wpi.first.wpilibj.event.EventLoop;
|
||||
|
||||
@@ -24,7 +26,7 @@ import edu.wpi.first.wpilibj.event.EventLoop;
|
||||
* 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 {
|
||||
public class {{ ConsoleName }}Controller extends GenericHID implements Sendable {
|
||||
/** Represents a digital button on a {{ ConsoleName }}Controller. */
|
||||
public enum Button {
|
||||
{%- for button in buttons %}
|
||||
@@ -252,7 +254,7 @@ public class {{ ConsoleName }}Controller extends GenericHID {
|
||||
public boolean getRightBumperReleased() {
|
||||
return getRawButtonReleased(Button.kRightBumper.value);
|
||||
}
|
||||
{% elif ConsoleName == "PS4" or ConsoleName == "PS5" %}
|
||||
{%- elif ConsoleName == "PS4" or ConsoleName == "PS5" %}
|
||||
/**
|
||||
* Read the value of the touchpad on the controller.
|
||||
*
|
||||
@@ -285,5 +287,20 @@ public class {{ ConsoleName }}Controller extends GenericHID {
|
||||
public boolean getTouchpadReleased() {
|
||||
return getRawButtonReleased(Button.kTouchpad.value);
|
||||
}
|
||||
{% endif -%}
|
||||
{%- endif %}
|
||||
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("HID");
|
||||
builder.publishConstString("ControllerType", "{{ ConsoleName }}");
|
||||
{%- for trigger in triggers %}
|
||||
builder.addDoubleProperty("{{ capitalize_first(trigger.name) }}", this::get{{ capitalize_first(trigger.name) }}Axis, null);
|
||||
{%- endfor -%}
|
||||
{% for stick in sticks %}
|
||||
builder.addDoubleProperty("{{ stick.NameParts|map("capitalize")|join }}", this::get{{ stick.NameParts|map("capitalize")|join }}, null);
|
||||
{%- endfor -%}
|
||||
{% for button in buttons %}
|
||||
builder.addBooleanProperty("{{ capitalize_first(button.name) }}", this::get{{ capitalize_first(button.name) }}Button, null);
|
||||
{%- endfor %}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ package edu.wpi.first.wpilibj;
|
||||
|
||||
import edu.wpi.first.hal.FRCNetComm.tResourceType;
|
||||
import edu.wpi.first.hal.HAL;
|
||||
import edu.wpi.first.util.sendable.Sendable;
|
||||
import edu.wpi.first.util.sendable.SendableBuilder;
|
||||
import edu.wpi.first.wpilibj.event.BooleanEvent;
|
||||
import edu.wpi.first.wpilibj.event.EventLoop;
|
||||
|
||||
@@ -22,7 +24,7 @@ import edu.wpi.first.wpilibj.event.EventLoop;
|
||||
* only through the official NI DS. Sim is not guaranteed to have the same mapping, as well as any
|
||||
* 3rd party controllers.
|
||||
*/
|
||||
public class PS4Controller extends GenericHID {
|
||||
public class PS4Controller extends GenericHID implements Sendable {
|
||||
/** Represents a digital button on a PS4Controller. */
|
||||
public enum Button {
|
||||
/** Square button. */
|
||||
@@ -746,4 +748,30 @@ public class PS4Controller extends GenericHID {
|
||||
public boolean getTouchpadReleased() {
|
||||
return getRawButtonReleased(Button.kTouchpad.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("HID");
|
||||
builder.publishConstString("ControllerType", "PS4");
|
||||
builder.addDoubleProperty("L2", this::getL2Axis, null);
|
||||
builder.addDoubleProperty("R2", this::getR2Axis, null);
|
||||
builder.addDoubleProperty("LeftX", this::getLeftX, null);
|
||||
builder.addDoubleProperty("LeftY", this::getLeftY, null);
|
||||
builder.addDoubleProperty("RightX", this::getRightX, null);
|
||||
builder.addDoubleProperty("RightY", this::getRightY, null);
|
||||
builder.addBooleanProperty("Square", this::getSquareButton, null);
|
||||
builder.addBooleanProperty("Cross", this::getCrossButton, null);
|
||||
builder.addBooleanProperty("Circle", this::getCircleButton, null);
|
||||
builder.addBooleanProperty("Triangle", this::getTriangleButton, null);
|
||||
builder.addBooleanProperty("L1", this::getL1Button, null);
|
||||
builder.addBooleanProperty("R1", this::getR1Button, null);
|
||||
builder.addBooleanProperty("L2", this::getL2Button, null);
|
||||
builder.addBooleanProperty("R2", this::getR2Button, null);
|
||||
builder.addBooleanProperty("Share", this::getShareButton, null);
|
||||
builder.addBooleanProperty("Options", this::getOptionsButton, null);
|
||||
builder.addBooleanProperty("L3", this::getL3Button, null);
|
||||
builder.addBooleanProperty("R3", this::getR3Button, null);
|
||||
builder.addBooleanProperty("PS", this::getPSButton, null);
|
||||
builder.addBooleanProperty("Touchpad", this::getTouchpadButton, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ package edu.wpi.first.wpilibj;
|
||||
|
||||
// import edu.wpi.first.hal.FRCNetComm.tResourceType;
|
||||
// import edu.wpi.first.hal.HAL;
|
||||
import edu.wpi.first.util.sendable.Sendable;
|
||||
import edu.wpi.first.util.sendable.SendableBuilder;
|
||||
import edu.wpi.first.wpilibj.event.BooleanEvent;
|
||||
import edu.wpi.first.wpilibj.event.EventLoop;
|
||||
|
||||
@@ -22,7 +24,7 @@ import edu.wpi.first.wpilibj.event.EventLoop;
|
||||
* only through the official NI DS. Sim is not guaranteed to have the same mapping, as well as any
|
||||
* 3rd party controllers.
|
||||
*/
|
||||
public class PS5Controller extends GenericHID {
|
||||
public class PS5Controller extends GenericHID implements Sendable {
|
||||
/** Represents a digital button on a PS5Controller. */
|
||||
public enum Button {
|
||||
/** Square button. */
|
||||
@@ -746,4 +748,30 @@ public class PS5Controller extends GenericHID {
|
||||
public boolean getTouchpadReleased() {
|
||||
return getRawButtonReleased(Button.kTouchpad.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("HID");
|
||||
builder.publishConstString("ControllerType", "PS5");
|
||||
builder.addDoubleProperty("L2", this::getL2Axis, null);
|
||||
builder.addDoubleProperty("R2", this::getR2Axis, null);
|
||||
builder.addDoubleProperty("LeftX", this::getLeftX, null);
|
||||
builder.addDoubleProperty("LeftY", this::getLeftY, null);
|
||||
builder.addDoubleProperty("RightX", this::getRightX, null);
|
||||
builder.addDoubleProperty("RightY", this::getRightY, null);
|
||||
builder.addBooleanProperty("Square", this::getSquareButton, null);
|
||||
builder.addBooleanProperty("Cross", this::getCrossButton, null);
|
||||
builder.addBooleanProperty("Circle", this::getCircleButton, null);
|
||||
builder.addBooleanProperty("Triangle", this::getTriangleButton, null);
|
||||
builder.addBooleanProperty("L1", this::getL1Button, null);
|
||||
builder.addBooleanProperty("R1", this::getR1Button, null);
|
||||
builder.addBooleanProperty("L2", this::getL2Button, null);
|
||||
builder.addBooleanProperty("R2", this::getR2Button, null);
|
||||
builder.addBooleanProperty("Create", this::getCreateButton, null);
|
||||
builder.addBooleanProperty("Options", this::getOptionsButton, null);
|
||||
builder.addBooleanProperty("L3", this::getL3Button, null);
|
||||
builder.addBooleanProperty("R3", this::getR3Button, null);
|
||||
builder.addBooleanProperty("PS", this::getPSButton, null);
|
||||
builder.addBooleanProperty("Touchpad", this::getTouchpadButton, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ package edu.wpi.first.wpilibj;
|
||||
|
||||
// import edu.wpi.first.hal.FRCNetComm.tResourceType;
|
||||
// import edu.wpi.first.hal.HAL;
|
||||
import edu.wpi.first.util.sendable.Sendable;
|
||||
import edu.wpi.first.util.sendable.SendableBuilder;
|
||||
import edu.wpi.first.wpilibj.event.BooleanEvent;
|
||||
import edu.wpi.first.wpilibj.event.EventLoop;
|
||||
|
||||
@@ -22,7 +24,7 @@ import edu.wpi.first.wpilibj.event.EventLoop;
|
||||
* only through the official NI DS. Sim is not guaranteed to have the same mapping, as well as any
|
||||
* 3rd party controllers.
|
||||
*/
|
||||
public class StadiaController extends GenericHID {
|
||||
public class StadiaController extends GenericHID implements Sendable {
|
||||
/** Represents a digital button on a StadiaController. */
|
||||
public enum Button {
|
||||
/** A button. */
|
||||
@@ -795,4 +797,29 @@ public class StadiaController extends GenericHID {
|
||||
public boolean getRightBumperReleased() {
|
||||
return getRawButtonReleased(Button.kRightBumper.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("HID");
|
||||
builder.publishConstString("ControllerType", "Stadia");
|
||||
builder.addDoubleProperty("LeftX", this::getLeftX, null);
|
||||
builder.addDoubleProperty("RightX", this::getRightX, null);
|
||||
builder.addDoubleProperty("LeftY", this::getLeftY, null);
|
||||
builder.addDoubleProperty("RightY", this::getRightY, null);
|
||||
builder.addBooleanProperty("A", this::getAButton, null);
|
||||
builder.addBooleanProperty("B", this::getBButton, null);
|
||||
builder.addBooleanProperty("X", this::getXButton, null);
|
||||
builder.addBooleanProperty("Y", this::getYButton, null);
|
||||
builder.addBooleanProperty("LeftBumper", this::getLeftBumperButton, null);
|
||||
builder.addBooleanProperty("RightBumper", this::getRightBumperButton, null);
|
||||
builder.addBooleanProperty("LeftStick", this::getLeftStickButton, null);
|
||||
builder.addBooleanProperty("RightStick", this::getRightStickButton, null);
|
||||
builder.addBooleanProperty("Ellipses", this::getEllipsesButton, null);
|
||||
builder.addBooleanProperty("Hamburger", this::getHamburgerButton, null);
|
||||
builder.addBooleanProperty("Stadia", this::getStadiaButton, null);
|
||||
builder.addBooleanProperty("RightTrigger", this::getRightTriggerButton, null);
|
||||
builder.addBooleanProperty("LeftTrigger", this::getLeftTriggerButton, null);
|
||||
builder.addBooleanProperty("Google", this::getGoogleButton, null);
|
||||
builder.addBooleanProperty("Frame", this::getFrameButton, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ package edu.wpi.first.wpilibj;
|
||||
|
||||
import edu.wpi.first.hal.FRCNetComm.tResourceType;
|
||||
import edu.wpi.first.hal.HAL;
|
||||
import edu.wpi.first.util.sendable.Sendable;
|
||||
import edu.wpi.first.util.sendable.SendableBuilder;
|
||||
import edu.wpi.first.wpilibj.event.BooleanEvent;
|
||||
import edu.wpi.first.wpilibj.event.EventLoop;
|
||||
|
||||
@@ -22,7 +24,7 @@ import edu.wpi.first.wpilibj.event.EventLoop;
|
||||
* only through the official NI DS. Sim is not guaranteed to have the same mapping, as well as any
|
||||
* 3rd party controllers.
|
||||
*/
|
||||
public class XboxController extends GenericHID {
|
||||
public class XboxController extends GenericHID implements Sendable {
|
||||
/** Represents a digital button on a XboxController. */
|
||||
public enum Button {
|
||||
/** A button. */
|
||||
@@ -671,4 +673,26 @@ public class XboxController extends GenericHID {
|
||||
public boolean getRightBumperReleased() {
|
||||
return getRawButtonReleased(Button.kRightBumper.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("HID");
|
||||
builder.publishConstString("ControllerType", "Xbox");
|
||||
builder.addDoubleProperty("LeftTrigger", this::getLeftTriggerAxis, null);
|
||||
builder.addDoubleProperty("RightTrigger", this::getRightTriggerAxis, null);
|
||||
builder.addDoubleProperty("LeftX", this::getLeftX, null);
|
||||
builder.addDoubleProperty("RightX", this::getRightX, null);
|
||||
builder.addDoubleProperty("LeftY", this::getLeftY, null);
|
||||
builder.addDoubleProperty("RightY", this::getRightY, null);
|
||||
builder.addBooleanProperty("A", this::getAButton, null);
|
||||
builder.addBooleanProperty("B", this::getBButton, null);
|
||||
builder.addBooleanProperty("X", this::getXButton, null);
|
||||
builder.addBooleanProperty("Y", this::getYButton, null);
|
||||
builder.addBooleanProperty("LeftBumper", this::getLeftBumperButton, null);
|
||||
builder.addBooleanProperty("RightBumper", this::getRightBumperButton, null);
|
||||
builder.addBooleanProperty("Back", this::getBackButton, null);
|
||||
builder.addBooleanProperty("Start", this::getStartButton, null);
|
||||
builder.addBooleanProperty("LeftStick", this::getLeftStickButton, null);
|
||||
builder.addBooleanProperty("RightStick", this::getRightStickButton, null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user