diff --git a/wpilibc/src/generate/main/native/cpp/hid.cpp.jinja b/wpilibc/src/generate/main/native/cpp/hid.cpp.jinja index 05b5572453..77b198a800 100644 --- a/wpilibc/src/generate/main/native/cpp/hid.cpp.jinja +++ b/wpilibc/src/generate/main/native/cpp/hid.cpp.jinja @@ -9,6 +9,7 @@ #include "frc/{{ ConsoleName }}Controller.h" #include +#include #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 %} +} diff --git a/wpilibc/src/generate/main/native/include/frc/hid.h.jinja b/wpilibc/src/generate/main/native/include/frc/hid.h.jinja index 1d2ef67335..4a03a84383 100644 --- a/wpilibc/src/generate/main/native/include/frc/hid.h.jinja +++ b/wpilibc/src/generate/main/native/include/frc/hid.h.jinja @@ -8,6 +8,9 @@ {%- endmacro %} #pragma once +#include +#include + #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 diff --git a/wpilibc/src/generated/main/native/cpp/PS4Controller.cpp b/wpilibc/src/generated/main/native/cpp/PS4Controller.cpp index 3e4b991d8c..1b2b88b182 100644 --- a/wpilibc/src/generated/main/native/cpp/PS4Controller.cpp +++ b/wpilibc/src/generated/main/native/cpp/PS4Controller.cpp @@ -7,6 +7,7 @@ #include "frc/PS4Controller.h" #include +#include #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); +} \ No newline at end of file diff --git a/wpilibc/src/generated/main/native/cpp/PS5Controller.cpp b/wpilibc/src/generated/main/native/cpp/PS5Controller.cpp index 34df999abd..56d50e37ee 100644 --- a/wpilibc/src/generated/main/native/cpp/PS5Controller.cpp +++ b/wpilibc/src/generated/main/native/cpp/PS5Controller.cpp @@ -7,6 +7,7 @@ #include "frc/PS5Controller.h" #include +#include #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); +} \ No newline at end of file diff --git a/wpilibc/src/generated/main/native/cpp/StadiaController.cpp b/wpilibc/src/generated/main/native/cpp/StadiaController.cpp index 54192f2071..ee87b888df 100644 --- a/wpilibc/src/generated/main/native/cpp/StadiaController.cpp +++ b/wpilibc/src/generated/main/native/cpp/StadiaController.cpp @@ -7,6 +7,7 @@ #include "frc/StadiaController.h" #include +#include #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); +} \ No newline at end of file diff --git a/wpilibc/src/generated/main/native/cpp/XboxController.cpp b/wpilibc/src/generated/main/native/cpp/XboxController.cpp index a924ba21ef..4b220170a6 100644 --- a/wpilibc/src/generated/main/native/cpp/XboxController.cpp +++ b/wpilibc/src/generated/main/native/cpp/XboxController.cpp @@ -7,6 +7,7 @@ #include "frc/XboxController.h" #include +#include #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); +} \ No newline at end of file diff --git a/wpilibc/src/generated/main/native/include/frc/PS4Controller.h b/wpilibc/src/generated/main/native/include/frc/PS4Controller.h index 3614cc3fdf..cd589e76ec 100644 --- a/wpilibc/src/generated/main/native/include/frc/PS4Controller.h +++ b/wpilibc/src/generated/main/native/include/frc/PS4Controller.h @@ -6,6 +6,9 @@ #pragma once +#include +#include + #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 { 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 diff --git a/wpilibc/src/generated/main/native/include/frc/PS5Controller.h b/wpilibc/src/generated/main/native/include/frc/PS5Controller.h index 461a853a98..31cd9e3021 100644 --- a/wpilibc/src/generated/main/native/include/frc/PS5Controller.h +++ b/wpilibc/src/generated/main/native/include/frc/PS5Controller.h @@ -6,6 +6,9 @@ #pragma once +#include +#include + #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 { 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 diff --git a/wpilibc/src/generated/main/native/include/frc/StadiaController.h b/wpilibc/src/generated/main/native/include/frc/StadiaController.h index 6a10aa213b..6582cc9bbf 100644 --- a/wpilibc/src/generated/main/native/include/frc/StadiaController.h +++ b/wpilibc/src/generated/main/native/include/frc/StadiaController.h @@ -6,6 +6,9 @@ #pragma once +#include +#include + #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 { 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 diff --git a/wpilibc/src/generated/main/native/include/frc/XboxController.h b/wpilibc/src/generated/main/native/include/frc/XboxController.h index 0a8357df16..ce2c21e048 100644 --- a/wpilibc/src/generated/main/native/include/frc/XboxController.h +++ b/wpilibc/src/generated/main/native/include/frc/XboxController.h @@ -6,6 +6,9 @@ #pragma once +#include +#include + #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 { 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 diff --git a/wpilibj/src/generate/hid.java.jinja b/wpilibj/src/generate/hid.java.jinja index 84dbd8c3e8..3c78bd5a3d 100644 --- a/wpilibj/src/generate/hid.java.jinja +++ b/wpilibj/src/generate/hid.java.jinja @@ -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 %} + } } diff --git a/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/PS4Controller.java b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/PS4Controller.java index 3195c5122b..ca8ae5058f 100644 --- a/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/PS4Controller.java +++ b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/PS4Controller.java @@ -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); + } } diff --git a/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/PS5Controller.java b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/PS5Controller.java index 7b0e3083ab..26c747906f 100644 --- a/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/PS5Controller.java +++ b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/PS5Controller.java @@ -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); + } } diff --git a/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/StadiaController.java b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/StadiaController.java index 916ab3979d..3bcd395eb9 100644 --- a/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/StadiaController.java +++ b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/StadiaController.java @@ -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); + } } diff --git a/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/XboxController.java b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/XboxController.java index 3bf77e11f6..5dc2a0258f 100644 --- a/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/XboxController.java +++ b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/XboxController.java @@ -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); + } }