[commands] Add functions to HID classes to allow use of axes as BooleanEvents/Triggers (#4762)

This commit is contained in:
Ryan Blue
2022-12-26 14:29:14 -05:00
committed by GitHub
parent 87a34af367
commit 176fddeb4c
12 changed files with 413 additions and 0 deletions

View File

@@ -54,3 +54,17 @@ Trigger CommandGenericHID::POVUpLeft(frc::EventLoop* loop) const {
Trigger CommandGenericHID::POVCenter(frc::EventLoop* loop) const {
return POV(360, loop);
}
Trigger CommandGenericHID::AxisLessThan(int axis, double threshold,
frc::EventLoop* loop) const {
return Trigger(loop, [this, axis, threshold]() {
return this->GetRawAxis(axis) < threshold;
});
}
Trigger CommandGenericHID::AxisGreaterThan(int axis, double threshold,
frc::EventLoop* loop) const {
return Trigger(loop, [this, axis, threshold]() {
return this->GetRawAxis(axis) > threshold;
});
}