mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilib] Implement Sendable for HID classes (#6782)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user