[wpilib] Implement Sendable for HID classes (#6782)

This commit is contained in:
Jade
2024-07-18 22:10:07 +08:00
committed by GitHub
parent 34b8b7a409
commit 7663211819
15 changed files with 287 additions and 14 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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