mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[commands] Add functions to HID classes to allow use of axes as BooleanEvents/Triggers (#4762)
This commit is contained in:
@@ -197,3 +197,25 @@ bool XboxController::GetStartButtonReleased() {
|
||||
BooleanEvent XboxController::Start(EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this]() { return this->GetStartButton(); });
|
||||
}
|
||||
|
||||
BooleanEvent XboxController::LeftTrigger(double threshold,
|
||||
EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this, threshold]() {
|
||||
return this->GetLeftTriggerAxis() > threshold;
|
||||
});
|
||||
}
|
||||
|
||||
BooleanEvent XboxController::LeftTrigger(EventLoop* loop) const {
|
||||
return this->LeftTrigger(0.5, loop);
|
||||
}
|
||||
|
||||
BooleanEvent XboxController::RightTrigger(double threshold,
|
||||
EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this, threshold]() {
|
||||
return this->GetRightTriggerAxis() > threshold;
|
||||
});
|
||||
}
|
||||
|
||||
BooleanEvent XboxController::RightTrigger(EventLoop* loop) const {
|
||||
return this->RightTrigger(0.5, loop);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user