[wpilib] Add BooleanEvent/Trigger factories on HID classes (#4247)

This commit is contained in:
Starlight220
2022-06-14 08:48:16 +03:00
committed by GitHub
parent 9b1bf5c7f1
commit fd884581e4
24 changed files with 1717 additions and 1 deletions

View File

@@ -96,6 +96,24 @@ class XboxController : public GenericHID {
*/
bool GetRightBumperReleased();
/**
* Constructs an event instance around the left bumper's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left bumper's digital signal
* attached to the given loop.
*/
BooleanEvent LeftBumper(EventLoop* loop) const;
/**
* Constructs an event instance around the right bumper's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right bumper's digital signal
* attached to the given loop.
*/
BooleanEvent RightBumper(EventLoop* loop) const;
/**
* Read the value of the left stick button (LSB) on the controller.
*/
@@ -126,6 +144,24 @@ class XboxController : public GenericHID {
*/
bool GetRightStickButtonReleased();
/**
* Constructs an event instance around the left stick's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left stick's digital signal
* attached to the given loop.
*/
BooleanEvent LeftStick(EventLoop* loop) const;
/**
* Constructs an event instance around the right stick's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right stick's digital signal
* attached to the given loop.
*/
BooleanEvent RightStick(EventLoop* loop) const;
/**
* Read the value of the A button on the controller.
*
@@ -147,6 +183,15 @@ class XboxController : public GenericHID {
*/
bool GetAButtonReleased();
/**
* Constructs an event instance around the A button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the A button's digital signal
* attached to the given loop.
*/
BooleanEvent A(EventLoop* loop) const;
/**
* Read the value of the B button on the controller.
*
@@ -168,6 +213,15 @@ class XboxController : public GenericHID {
*/
bool GetBButtonReleased();
/**
* Constructs an event instance around the B button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the B button's digital signal
* attached to the given loop.
*/
BooleanEvent B(EventLoop* loop) const;
/**
* Read the value of the X button on the controller.
*
@@ -189,6 +243,15 @@ class XboxController : public GenericHID {
*/
bool GetXButtonReleased();
/**
* Constructs an event instance around the X button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the X button's digital signal
* attached to the given loop.
*/
BooleanEvent X(EventLoop* loop) const;
/**
* Read the value of the Y button on the controller.
*
@@ -210,6 +273,15 @@ class XboxController : public GenericHID {
*/
bool GetYButtonReleased();
/**
* Constructs an event instance around the Y button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Y button's digital signal
* attached to the given loop.
*/
BooleanEvent Y(EventLoop* loop) const;
/**
* Whether the Y button was released since the last check.
*
@@ -231,6 +303,15 @@ class XboxController : public GenericHID {
*/
bool GetBackButtonReleased();
/**
* Constructs an event instance around the back button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the back button's digital signal
* attached to the given loop.
*/
BooleanEvent Back(EventLoop* loop) const;
/**
* Read the value of the start button on the controller.
*
@@ -252,6 +333,15 @@ class XboxController : public GenericHID {
*/
bool GetStartButtonReleased();
/**
* Constructs an event instance around the start button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the start button's digital signal
* attached to the given loop.
*/
BooleanEvent Start(EventLoop* loop) const;
struct Button {
static constexpr int kLeftBumper = 5;
static constexpr int kRightBumper = 6;