mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[commands] GenericHIDController: use composition in C++ (#6296)
This commit is contained in:
@@ -6,8 +6,14 @@
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
CommandGenericHID::CommandGenericHID(int port) : m_hid{port} {}
|
||||
|
||||
frc::GenericHID& CommandGenericHID::GetHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::Button(int button, frc::EventLoop* loop) const {
|
||||
return GenericHID::Button(button, loop).CastTo<Trigger>();
|
||||
return m_hid.Button(button, loop).CastTo<Trigger>();
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POV(int angle, frc::EventLoop* loop) const {
|
||||
@@ -16,7 +22,7 @@ Trigger CommandGenericHID::POV(int angle, frc::EventLoop* loop) const {
|
||||
|
||||
Trigger CommandGenericHID::POV(int pov, int angle, frc::EventLoop* loop) const {
|
||||
return Trigger(loop,
|
||||
[this, pov, angle] { return this->GetPOV(pov) == angle; });
|
||||
[this, pov, angle] { return m_hid.GetPOV(pov) == angle; });
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVUp(frc::EventLoop* loop) const {
|
||||
@@ -58,13 +64,13 @@ Trigger CommandGenericHID::POVCenter(frc::EventLoop* loop) const {
|
||||
Trigger CommandGenericHID::AxisLessThan(int axis, double threshold,
|
||||
frc::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, axis, threshold]() {
|
||||
return this->GetRawAxis(axis) < threshold;
|
||||
return m_hid.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;
|
||||
return m_hid.GetRawAxis(axis) > threshold;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user