[wpilib] Add StadiaController and command wrapper (#6083)

This commit is contained in:
NC GEARS FRC 1918
2023-12-23 11:15:05 -05:00
committed by GitHub
parent 4e4a468d4d
commit c1178d5add
6 changed files with 2209 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "frc2/command/button/CommandStadiaController.h"
using namespace frc2;
Trigger CommandStadiaController::Button(int button,
frc::EventLoop* loop) const {
return GenericHID::Button(button, loop).CastTo<Trigger>();
}
Trigger CommandStadiaController::LeftBumper(frc::EventLoop* loop) const {
return StadiaController::LeftBumper(loop).CastTo<Trigger>();
}
Trigger CommandStadiaController::RightBumper(frc::EventLoop* loop) const {
return StadiaController::RightBumper(loop).CastTo<Trigger>();
}
Trigger CommandStadiaController::LeftStick(frc::EventLoop* loop) const {
return StadiaController::LeftStick(loop).CastTo<Trigger>();
}
Trigger CommandStadiaController::RightStick(frc::EventLoop* loop) const {
return StadiaController::RightStick(loop).CastTo<Trigger>();
}
Trigger CommandStadiaController::A(frc::EventLoop* loop) const {
return StadiaController::A(loop).CastTo<Trigger>();
}
Trigger CommandStadiaController::B(frc::EventLoop* loop) const {
return StadiaController::B(loop).CastTo<Trigger>();
}
Trigger CommandStadiaController::X(frc::EventLoop* loop) const {
return StadiaController::X(loop).CastTo<Trigger>();
}
Trigger CommandStadiaController::Y(frc::EventLoop* loop) const {
return StadiaController::Y(loop).CastTo<Trigger>();
}
Trigger CommandStadiaController::Ellipses(frc::EventLoop* loop) const {
return StadiaController::Ellipses(loop).CastTo<Trigger>();
}
Trigger CommandStadiaController::Hamburger(frc::EventLoop* loop) const {
return StadiaController::Hamburger(loop).CastTo<Trigger>();
}
Trigger CommandStadiaController::Stadia(frc::EventLoop* loop) const {
return StadiaController::Stadia(loop).CastTo<Trigger>();
}
Trigger CommandStadiaController::Google(frc::EventLoop* loop) const {
return StadiaController::Google(loop).CastTo<Trigger>();
}
Trigger CommandStadiaController::Frame(frc::EventLoop* loop) const {
return StadiaController::Frame(loop).CastTo<Trigger>();
}
Trigger CommandStadiaController::LeftTrigger(frc::EventLoop* loop) const {
return StadiaController::LeftTrigger(loop).CastTo<Trigger>();
}
Trigger CommandStadiaController::RightTrigger(frc::EventLoop* loop) const {
return StadiaController::RightTrigger(loop).CastTo<Trigger>();
}

View File

@@ -0,0 +1,201 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <frc/StadiaController.h>
#include "Trigger.h"
#include "frc2/command/CommandScheduler.h"
namespace frc2 {
/**
* A version of {@link StadiaController} with {@link Trigger} factories for
* command-based.
*
* @see StadiaController
*/
class CommandStadiaController : public frc::StadiaController {
public:
using StadiaController::StadiaController;
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button index
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return an event instance representing the button's digital signal attached
* to the given loop.
*/
Trigger Button(int button,
frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs an event instance around the left bumper's digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return an event instance representing the left bumper's digital signal
* attached to the given loop.
*/
Trigger LeftBumper(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs an event instance around the right bumper's digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return an event instance representing the right bumper's digital signal
* attached to the given loop.
*/
Trigger RightBumper(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs an event instance around the left stick's digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return an event instance representing the left stick's digital signal
* attached to the given loop.
*/
Trigger LeftStick(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs an event instance around the right stick's digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return an event instance representing the right stick's digital signal
* attached to the given loop.
*/
Trigger RightStick(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs an event instance around the A button's digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return an event instance representing the A button's digital signal
* attached to the given loop.
*/
Trigger A(frc::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs an event instance around the B button's digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return an event instance representing the B button's digital signal
* attached to the given loop.
*/
Trigger B(frc::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs an event instance around the X button's digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return an event instance representing the X button's digital signal
* attached to the given loop.
*/
Trigger X(frc::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs an event instance around the Y button's digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return an event instance representing the Y button's digital signal
* attached to the given loop.
*/
Trigger Y(frc::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs an event instance around the ellipses button's digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return an event instance representing the ellipses button's digital signal
* attached to the given loop.
*/
Trigger Ellipses(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs an event instance around the hamburger button's digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return an event instance representing the hamburger button's digital
* signal attached to the given loop.
*/
Trigger Hamburger(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs an event instance around the stadia button's digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return an event instance representing the stadia button's digital signal
* attached to the given loop.
*/
Trigger Stadia(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs an event instance around the google button's digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return an event instance representing the google button's digital signal
* attached to the given loop.
*/
Trigger Google(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs an event instance around the frame button's digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return an event instance representing the frame button's digital signal
* attached to the given loop.
*/
Trigger Frame(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs an event instance around the left trigger's digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return an event instance representing the left trigger's digital signal
* attached to the given loop.
*/
Trigger LeftTrigger(frc::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* Constructs an event instance around the right trigger's digital signal.
*
* @param loop the event loop instance to attach the event to. Defaults to the
* CommandScheduler's default loop.
* @return an event instance representing the right trigger's digital signal
* attached to the given loop.
*/
Trigger RightTrigger(
frc::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
};
} // namespace frc2