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:
@@ -89,6 +89,20 @@ BooleanEvent GenericHID::POVCenter(EventLoop* loop) const {
|
||||
return POV(360, loop);
|
||||
}
|
||||
|
||||
BooleanEvent GenericHID::AxisLessThan(int axis, double threshold,
|
||||
EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this, axis, threshold]() {
|
||||
return this->GetRawAxis(axis) < threshold;
|
||||
});
|
||||
}
|
||||
|
||||
BooleanEvent GenericHID::AxisGreaterThan(int axis, double threshold,
|
||||
EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this, axis, threshold]() {
|
||||
return this->GetRawAxis(axis) > threshold;
|
||||
});
|
||||
}
|
||||
|
||||
int GenericHID::GetAxisCount() const {
|
||||
return DriverStation::GetStickAxisCount(m_port);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user