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