[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

@@ -8,6 +8,7 @@
#include "frc/DriverStation.h"
#include "frc/Errors.h"
#include "frc/event/BooleanEvent.h"
using namespace frc;
@@ -30,6 +31,11 @@ bool GenericHID::GetRawButtonReleased(int button) {
return DriverStation::GetStickButtonReleased(m_port, button);
}
BooleanEvent GenericHID::Button(int button, EventLoop* loop) const {
return BooleanEvent(loop,
[this, button]() { return this->GetRawButton(button); });
}
double GenericHID::GetRawAxis(int axis) const {
return DriverStation::GetStickAxis(m_port, axis);
}