mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[commands] Add functions to HID classes to allow use of axes as BooleanEvents/Triggers (#4762)
This commit is contained in:
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -49,3 +49,13 @@ Trigger CommandXboxController::Back(frc::EventLoop* loop) const {
|
||||
Trigger CommandXboxController::Start(frc::EventLoop* loop) const {
|
||||
return XboxController::Start(loop).CastTo<Trigger>();
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::LeftTrigger(double threshold,
|
||||
frc::EventLoop* loop) const {
|
||||
return XboxController::LeftTrigger(threshold, loop).CastTo<Trigger>();
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::RightTrigger(double threshold,
|
||||
frc::EventLoop* loop) const {
|
||||
return XboxController::RightTrigger(threshold, loop).CastTo<Trigger>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user