[wpilib, commands] Cache controller BooleanEvents/Triggers and directly construct Triggers (#6738)

This has been a common footgun for teams, due to calling the factory functions in periodic loops.
This commit is contained in:
Gold856
2024-07-29 10:58:23 -04:00
committed by GitHub
parent 073192d513
commit 3c2bdafd57
21 changed files with 235 additions and 187 deletions

View File

@@ -13,7 +13,7 @@ frc::GenericHID& CommandGenericHID::GetHID() {
}
Trigger CommandGenericHID::Button(int button, frc::EventLoop* loop) const {
return m_hid.Button(button, loop).CastTo<Trigger>();
return Trigger(loop, [this, button] { return m_hid.GetRawButton(button); });
}
Trigger CommandGenericHID::POV(int angle, frc::EventLoop* loop) const {