[wpilib,commands] Use Jinja to generate HID classes (#6274)

This commit is contained in:
Gold856
2024-06-08 12:59:07 -04:00
committed by GitHub
parent a0efc9ca31
commit 65c6306047
75 changed files with 7622 additions and 4546 deletions

View File

@@ -1,263 +0,0 @@
// 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 "frc/PS4Controller.h"
#include <hal/FRCUsageReporting.h>
#include "frc/event/BooleanEvent.h"
using namespace frc;
PS4Controller::PS4Controller(int port) : GenericHID(port) {
HAL_Report(HALUsageReporting::kResourceType_PS4Controller, port + 1);
}
double PS4Controller::GetLeftX() const {
return GetRawAxis(Axis::kLeftX);
}
double PS4Controller::GetRightX() const {
return GetRawAxis(Axis::kRightX);
}
double PS4Controller::GetLeftY() const {
return GetRawAxis(Axis::kLeftY);
}
double PS4Controller::GetRightY() const {
return GetRawAxis(Axis::kRightY);
}
double PS4Controller::GetL2Axis() const {
return GetRawAxis(Axis::kL2);
}
double PS4Controller::GetR2Axis() const {
return GetRawAxis(Axis::kR2);
}
bool PS4Controller::GetSquareButton() const {
return GetRawButton(Button::kSquare);
}
bool PS4Controller::GetSquareButtonPressed() {
return GetRawButtonPressed(Button::kSquare);
}
bool PS4Controller::GetSquareButtonReleased() {
return GetRawButtonReleased(Button::kSquare);
}
BooleanEvent PS4Controller::Square(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetSquareButton(); });
}
bool PS4Controller::GetCrossButton() const {
return GetRawButton(Button::kCross);
}
bool PS4Controller::GetCrossButtonPressed() {
return GetRawButtonPressed(Button::kCross);
}
bool PS4Controller::GetCrossButtonReleased() {
return GetRawButtonReleased(Button::kCross);
}
BooleanEvent PS4Controller::Cross(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetCrossButton(); });
}
bool PS4Controller::GetCircleButton() const {
return GetRawButton(Button::kCircle);
}
bool PS4Controller::GetCircleButtonPressed() {
return GetRawButtonPressed(Button::kCircle);
}
bool PS4Controller::GetCircleButtonReleased() {
return GetRawButtonReleased(Button::kCircle);
}
BooleanEvent PS4Controller::Circle(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetCircleButton(); });
}
bool PS4Controller::GetTriangleButton() const {
return GetRawButton(Button::kTriangle);
}
bool PS4Controller::GetTriangleButtonPressed() {
return GetRawButtonPressed(Button::kTriangle);
}
bool PS4Controller::GetTriangleButtonReleased() {
return GetRawButtonReleased(Button::kTriangle);
}
BooleanEvent PS4Controller::Triangle(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetTriangleButton(); });
}
bool PS4Controller::GetL1Button() const {
return GetRawButton(Button::kL1);
}
bool PS4Controller::GetL1ButtonPressed() {
return GetRawButtonPressed(Button::kL1);
}
bool PS4Controller::GetL1ButtonReleased() {
return GetRawButtonReleased(Button::kL1);
}
BooleanEvent PS4Controller::L1(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetL1Button(); });
}
bool PS4Controller::GetR1Button() const {
return GetRawButton(Button::kR1);
}
bool PS4Controller::GetR1ButtonPressed() {
return GetRawButtonPressed(Button::kR1);
}
bool PS4Controller::GetR1ButtonReleased() {
return GetRawButtonReleased(Button::kR1);
}
BooleanEvent PS4Controller::R1(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetR1Button(); });
}
bool PS4Controller::GetL2Button() const {
return GetRawButton(Button::kL2);
}
bool PS4Controller::GetL2ButtonPressed() {
return GetRawButtonPressed(Button::kL2);
}
bool PS4Controller::GetL2ButtonReleased() {
return GetRawButtonReleased(Button::kL2);
}
BooleanEvent PS4Controller::L2(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetL2Button(); });
}
bool PS4Controller::GetR2Button() const {
return GetRawButton(Button::kR2);
}
bool PS4Controller::GetR2ButtonPressed() {
return GetRawButtonPressed(Button::kR2);
}
bool PS4Controller::GetR2ButtonReleased() {
return GetRawButtonReleased(Button::kR2);
}
BooleanEvent PS4Controller::R2(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetR2Button(); });
}
bool PS4Controller::GetShareButton() const {
return GetRawButton(Button::kShare);
}
bool PS4Controller::GetShareButtonPressed() {
return GetRawButtonPressed(Button::kShare);
}
bool PS4Controller::GetShareButtonReleased() {
return GetRawButtonReleased(Button::kShare);
}
BooleanEvent PS4Controller::Share(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetShareButton(); });
}
bool PS4Controller::GetOptionsButton() const {
return GetRawButton(Button::kOptions);
}
bool PS4Controller::GetOptionsButtonPressed() {
return GetRawButtonPressed(Button::kOptions);
}
bool PS4Controller::GetOptionsButtonReleased() {
return GetRawButtonReleased(Button::kOptions);
}
BooleanEvent PS4Controller::Options(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetOptionsButton(); });
}
bool PS4Controller::GetL3Button() const {
return GetRawButton(Button::kL3);
}
bool PS4Controller::GetL3ButtonPressed() {
return GetRawButtonPressed(Button::kL3);
}
bool PS4Controller::GetL3ButtonReleased() {
return GetRawButtonReleased(Button::kL3);
}
BooleanEvent PS4Controller::L3(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetL3Button(); });
}
bool PS4Controller::GetR3Button() const {
return GetRawButton(Button::kR3);
}
bool PS4Controller::GetR3ButtonPressed() {
return GetRawButtonPressed(Button::kR3);
}
bool PS4Controller::GetR3ButtonReleased() {
return GetRawButtonReleased(Button::kR3);
}
BooleanEvent PS4Controller::R3(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetR3Button(); });
}
bool PS4Controller::GetPSButton() const {
return GetRawButton(Button::kPS);
}
bool PS4Controller::GetPSButtonPressed() {
return GetRawButtonPressed(Button::kPS);
}
bool PS4Controller::GetPSButtonReleased() {
return GetRawButtonReleased(Button::kPS);
}
BooleanEvent PS4Controller::PS(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetPSButton(); });
}
bool PS4Controller::GetTouchpad() const {
return GetRawButton(Button::kTouchpad);
}
bool PS4Controller::GetTouchpadPressed() {
return GetRawButtonPressed(Button::kTouchpad);
}
bool PS4Controller::GetTouchpadReleased() {
return GetRawButtonReleased(Button::kTouchpad);
}
BooleanEvent PS4Controller::Touchpad(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetTouchpad(); });
}

View File

@@ -1,263 +0,0 @@
// 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 "frc/PS5Controller.h"
#include <hal/FRCUsageReporting.h>
#include "frc/event/BooleanEvent.h"
using namespace frc;
PS5Controller::PS5Controller(int port) : GenericHID(port) {
// HAL_Report(HALUsageReporting::kResourceType_PS5Controller, port + 1);
}
double PS5Controller::GetLeftX() const {
return GetRawAxis(Axis::kLeftX);
}
double PS5Controller::GetRightX() const {
return GetRawAxis(Axis::kRightX);
}
double PS5Controller::GetLeftY() const {
return GetRawAxis(Axis::kLeftY);
}
double PS5Controller::GetRightY() const {
return GetRawAxis(Axis::kRightY);
}
double PS5Controller::GetL2Axis() const {
return GetRawAxis(Axis::kL2);
}
double PS5Controller::GetR2Axis() const {
return GetRawAxis(Axis::kR2);
}
bool PS5Controller::GetSquareButton() const {
return GetRawButton(Button::kSquare);
}
bool PS5Controller::GetSquareButtonPressed() {
return GetRawButtonPressed(Button::kSquare);
}
bool PS5Controller::GetSquareButtonReleased() {
return GetRawButtonReleased(Button::kSquare);
}
BooleanEvent PS5Controller::Square(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetSquareButton(); });
}
bool PS5Controller::GetCrossButton() const {
return GetRawButton(Button::kCross);
}
bool PS5Controller::GetCrossButtonPressed() {
return GetRawButtonPressed(Button::kCross);
}
bool PS5Controller::GetCrossButtonReleased() {
return GetRawButtonReleased(Button::kCross);
}
BooleanEvent PS5Controller::Cross(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetCrossButton(); });
}
bool PS5Controller::GetCircleButton() const {
return GetRawButton(Button::kCircle);
}
bool PS5Controller::GetCircleButtonPressed() {
return GetRawButtonPressed(Button::kCircle);
}
bool PS5Controller::GetCircleButtonReleased() {
return GetRawButtonReleased(Button::kCircle);
}
BooleanEvent PS5Controller::Circle(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetCircleButton(); });
}
bool PS5Controller::GetTriangleButton() const {
return GetRawButton(Button::kTriangle);
}
bool PS5Controller::GetTriangleButtonPressed() {
return GetRawButtonPressed(Button::kTriangle);
}
bool PS5Controller::GetTriangleButtonReleased() {
return GetRawButtonReleased(Button::kTriangle);
}
BooleanEvent PS5Controller::Triangle(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetTriangleButton(); });
}
bool PS5Controller::GetL1Button() const {
return GetRawButton(Button::kL1);
}
bool PS5Controller::GetL1ButtonPressed() {
return GetRawButtonPressed(Button::kL1);
}
bool PS5Controller::GetL1ButtonReleased() {
return GetRawButtonReleased(Button::kL1);
}
BooleanEvent PS5Controller::L1(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetL1Button(); });
}
bool PS5Controller::GetR1Button() const {
return GetRawButton(Button::kR1);
}
bool PS5Controller::GetR1ButtonPressed() {
return GetRawButtonPressed(Button::kR1);
}
bool PS5Controller::GetR1ButtonReleased() {
return GetRawButtonReleased(Button::kR1);
}
BooleanEvent PS5Controller::R1(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetR1Button(); });
}
bool PS5Controller::GetL2Button() const {
return GetRawButton(Button::kL2);
}
bool PS5Controller::GetL2ButtonPressed() {
return GetRawButtonPressed(Button::kL2);
}
bool PS5Controller::GetL2ButtonReleased() {
return GetRawButtonReleased(Button::kL2);
}
BooleanEvent PS5Controller::L2(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetL2Button(); });
}
bool PS5Controller::GetR2Button() const {
return GetRawButton(Button::kR2);
}
bool PS5Controller::GetR2ButtonPressed() {
return GetRawButtonPressed(Button::kR2);
}
bool PS5Controller::GetR2ButtonReleased() {
return GetRawButtonReleased(Button::kR2);
}
BooleanEvent PS5Controller::R2(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetR2Button(); });
}
bool PS5Controller::GetCreateButton() const {
return GetRawButton(Button::kCreate);
}
bool PS5Controller::GetCreateButtonPressed() {
return GetRawButtonPressed(Button::kCreate);
}
bool PS5Controller::GetCreateButtonReleased() {
return GetRawButtonReleased(Button::kCreate);
}
BooleanEvent PS5Controller::Create(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetCreateButton(); });
}
bool PS5Controller::GetOptionsButton() const {
return GetRawButton(Button::kOptions);
}
bool PS5Controller::GetOptionsButtonPressed() {
return GetRawButtonPressed(Button::kOptions);
}
bool PS5Controller::GetOptionsButtonReleased() {
return GetRawButtonReleased(Button::kOptions);
}
BooleanEvent PS5Controller::Options(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetOptionsButton(); });
}
bool PS5Controller::GetL3Button() const {
return GetRawButton(Button::kL3);
}
bool PS5Controller::GetL3ButtonPressed() {
return GetRawButtonPressed(Button::kL3);
}
bool PS5Controller::GetL3ButtonReleased() {
return GetRawButtonReleased(Button::kL3);
}
BooleanEvent PS5Controller::L3(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetL3Button(); });
}
bool PS5Controller::GetR3Button() const {
return GetRawButton(Button::kR3);
}
bool PS5Controller::GetR3ButtonPressed() {
return GetRawButtonPressed(Button::kR3);
}
bool PS5Controller::GetR3ButtonReleased() {
return GetRawButtonReleased(Button::kR3);
}
BooleanEvent PS5Controller::R3(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetR3Button(); });
}
bool PS5Controller::GetPSButton() const {
return GetRawButton(Button::kPS);
}
bool PS5Controller::GetPSButtonPressed() {
return GetRawButtonPressed(Button::kPS);
}
bool PS5Controller::GetPSButtonReleased() {
return GetRawButtonReleased(Button::kPS);
}
BooleanEvent PS5Controller::PS(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetPSButton(); });
}
bool PS5Controller::GetTouchpad() const {
return GetRawButton(Button::kTouchpad);
}
bool PS5Controller::GetTouchpadPressed() {
return GetRawButtonPressed(Button::kTouchpad);
}
bool PS5Controller::GetTouchpadReleased() {
return GetRawButtonReleased(Button::kTouchpad);
}
BooleanEvent PS5Controller::Touchpad(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetTouchpad(); });
}

View File

@@ -1,272 +0,0 @@
// 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 "frc/StadiaController.h"
#include <hal/FRCUsageReporting.h>
#include "frc/event/BooleanEvent.h"
using namespace frc;
StadiaController::StadiaController(int port) : GenericHID(port) {
// re-enable when StadiaController is added to Usage Reporting
// HAL_Report(HALUsageReporting::kResourceType_StadiaController, port + 1);
}
double StadiaController::GetLeftX() const {
return GetRawAxis(Axis::kLeftX);
}
double StadiaController::GetRightX() const {
return GetRawAxis(Axis::kRightX);
}
double StadiaController::GetLeftY() const {
return GetRawAxis(Axis::kLeftY);
}
double StadiaController::GetRightY() const {
return GetRawAxis(Axis::kRightY);
}
bool StadiaController::GetLeftBumper() const {
return GetRawButton(Button::kLeftBumper);
}
bool StadiaController::GetRightBumper() const {
return GetRawButton(Button::kRightBumper);
}
bool StadiaController::GetLeftBumperPressed() {
return GetRawButtonPressed(Button::kLeftBumper);
}
bool StadiaController::GetRightBumperPressed() {
return GetRawButtonPressed(Button::kRightBumper);
}
bool StadiaController::GetLeftBumperReleased() {
return GetRawButtonReleased(Button::kLeftBumper);
}
bool StadiaController::GetRightBumperReleased() {
return GetRawButtonReleased(Button::kRightBumper);
}
BooleanEvent StadiaController::LeftBumper(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetLeftBumper(); });
}
BooleanEvent StadiaController::RightBumper(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetRightBumper(); });
}
bool StadiaController::GetLeftStickButton() const {
return GetRawButton(Button::kLeftStick);
}
bool StadiaController::GetRightStickButton() const {
return GetRawButton(Button::kRightStick);
}
bool StadiaController::GetLeftStickButtonPressed() {
return GetRawButtonPressed(Button::kLeftStick);
}
bool StadiaController::GetRightStickButtonPressed() {
return GetRawButtonPressed(Button::kRightStick);
}
bool StadiaController::GetLeftStickButtonReleased() {
return GetRawButtonReleased(Button::kLeftStick);
}
bool StadiaController::GetRightStickButtonReleased() {
return GetRawButtonReleased(Button::kRightStick);
}
BooleanEvent StadiaController::LeftStick(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetLeftStickButton(); });
}
BooleanEvent StadiaController::RightStick(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetRightStickButton(); });
}
bool StadiaController::GetAButton() const {
return GetRawButton(Button::kA);
}
bool StadiaController::GetAButtonPressed() {
return GetRawButtonPressed(Button::kA);
}
bool StadiaController::GetAButtonReleased() {
return GetRawButtonReleased(Button::kA);
}
BooleanEvent StadiaController::A(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetAButton(); });
}
bool StadiaController::GetBButton() const {
return GetRawButton(Button::kB);
}
bool StadiaController::GetBButtonPressed() {
return GetRawButtonPressed(Button::kB);
}
bool StadiaController::GetBButtonReleased() {
return GetRawButtonReleased(Button::kB);
}
BooleanEvent StadiaController::B(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetBButton(); });
}
bool StadiaController::GetXButton() const {
return GetRawButton(Button::kX);
}
bool StadiaController::GetXButtonPressed() {
return GetRawButtonPressed(Button::kX);
}
bool StadiaController::GetXButtonReleased() {
return GetRawButtonReleased(Button::kX);
}
BooleanEvent StadiaController::X(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetXButton(); });
}
bool StadiaController::GetYButton() const {
return GetRawButton(Button::kY);
}
bool StadiaController::GetYButtonPressed() {
return GetRawButtonPressed(Button::kY);
}
bool StadiaController::GetYButtonReleased() {
return GetRawButtonReleased(Button::kY);
}
BooleanEvent StadiaController::Y(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetYButton(); });
}
bool StadiaController::GetEllipsesButton() const {
return GetRawButton(Button::kEllipses);
}
bool StadiaController::GetEllipsesButtonPressed() {
return GetRawButtonPressed(Button::kEllipses);
}
bool StadiaController::GetEllipsesButtonReleased() {
return GetRawButtonReleased(Button::kEllipses);
}
BooleanEvent StadiaController::Ellipses(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetEllipsesButton(); });
}
bool StadiaController::GetHamburgerButton() const {
return GetRawButton(Button::kHamburger);
}
bool StadiaController::GetHamburgerButtonPressed() {
return GetRawButtonPressed(Button::kHamburger);
}
bool StadiaController::GetHamburgerButtonReleased() {
return GetRawButtonReleased(Button::kHamburger);
}
BooleanEvent StadiaController::Hamburger(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetHamburgerButton(); });
}
bool StadiaController::GetStadiaButton() const {
return GetRawButton(Button::kStadia);
}
bool StadiaController::GetStadiaButtonPressed() {
return GetRawButtonPressed(Button::kStadia);
}
bool StadiaController::GetStadiaButtonReleased() {
return GetRawButtonReleased(Button::kStadia);
}
BooleanEvent StadiaController::Stadia(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetStadiaButton(); });
}
bool StadiaController::GetGoogleButton() const {
return GetRawButton(Button::kGoogle);
}
bool StadiaController::GetGoogleButtonPressed() {
return GetRawButtonPressed(Button::kGoogle);
}
bool StadiaController::GetGoogleButtonReleased() {
return GetRawButtonReleased(Button::kGoogle);
}
BooleanEvent StadiaController::Google(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetGoogleButton(); });
}
bool StadiaController::GetFrameButton() const {
return GetRawButton(Button::kFrame);
}
bool StadiaController::GetFrameButtonPressed() {
return GetRawButtonPressed(Button::kFrame);
}
bool StadiaController::GetFrameButtonReleased() {
return GetRawButtonReleased(Button::kFrame);
}
BooleanEvent StadiaController::Frame(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetFrameButton(); });
}
bool StadiaController::GetLeftTriggerButton() const {
return GetRawButton(Button::kLeftTrigger);
}
bool StadiaController::GetLeftTriggerButtonPressed() {
return GetRawButtonPressed(Button::kLeftTrigger);
}
bool StadiaController::GetLeftTriggerButtonReleased() {
return GetRawButtonReleased(Button::kLeftTrigger);
}
BooleanEvent StadiaController::LeftTrigger(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetLeftTriggerButton(); });
}
bool StadiaController::GetRightTriggerButton() const {
return GetRawButton(Button::kRightTrigger);
}
bool StadiaController::GetRightTriggerButtonPressed() {
return GetRawButtonPressed(Button::kRightTrigger);
}
bool StadiaController::GetRightTriggerButtonReleased() {
return GetRawButtonReleased(Button::kRightTrigger);
}
BooleanEvent StadiaController::RightTrigger(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetRightTriggerButton(); });
}

View File

@@ -1,221 +0,0 @@
// 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 "frc/XboxController.h"
#include <hal/FRCUsageReporting.h>
#include "frc/event/BooleanEvent.h"
using namespace frc;
XboxController::XboxController(int port) : GenericHID(port) {
HAL_Report(HALUsageReporting::kResourceType_XboxController, port + 1);
}
double XboxController::GetLeftX() const {
return GetRawAxis(Axis::kLeftX);
}
double XboxController::GetRightX() const {
return GetRawAxis(Axis::kRightX);
}
double XboxController::GetLeftY() const {
return GetRawAxis(Axis::kLeftY);
}
double XboxController::GetRightY() const {
return GetRawAxis(Axis::kRightY);
}
double XboxController::GetLeftTriggerAxis() const {
return GetRawAxis(Axis::kLeftTrigger);
}
double XboxController::GetRightTriggerAxis() const {
return GetRawAxis(Axis::kRightTrigger);
}
bool XboxController::GetLeftBumper() const {
return GetRawButton(Button::kLeftBumper);
}
bool XboxController::GetRightBumper() const {
return GetRawButton(Button::kRightBumper);
}
bool XboxController::GetLeftBumperPressed() {
return GetRawButtonPressed(Button::kLeftBumper);
}
bool XboxController::GetRightBumperPressed() {
return GetRawButtonPressed(Button::kRightBumper);
}
bool XboxController::GetLeftBumperReleased() {
return GetRawButtonReleased(Button::kLeftBumper);
}
bool XboxController::GetRightBumperReleased() {
return GetRawButtonReleased(Button::kRightBumper);
}
BooleanEvent XboxController::LeftBumper(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetLeftBumper(); });
}
BooleanEvent XboxController::RightBumper(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetRightBumper(); });
}
bool XboxController::GetLeftStickButton() const {
return GetRawButton(Button::kLeftStick);
}
bool XboxController::GetRightStickButton() const {
return GetRawButton(Button::kRightStick);
}
bool XboxController::GetLeftStickButtonPressed() {
return GetRawButtonPressed(Button::kLeftStick);
}
bool XboxController::GetRightStickButtonPressed() {
return GetRawButtonPressed(Button::kRightStick);
}
bool XboxController::GetLeftStickButtonReleased() {
return GetRawButtonReleased(Button::kLeftStick);
}
bool XboxController::GetRightStickButtonReleased() {
return GetRawButtonReleased(Button::kRightStick);
}
BooleanEvent XboxController::LeftStick(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetLeftStickButton(); });
}
BooleanEvent XboxController::RightStick(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetRightStickButton(); });
}
bool XboxController::GetAButton() const {
return GetRawButton(Button::kA);
}
bool XboxController::GetAButtonPressed() {
return GetRawButtonPressed(Button::kA);
}
bool XboxController::GetAButtonReleased() {
return GetRawButtonReleased(Button::kA);
}
BooleanEvent XboxController::A(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetAButton(); });
}
bool XboxController::GetBButton() const {
return GetRawButton(Button::kB);
}
bool XboxController::GetBButtonPressed() {
return GetRawButtonPressed(Button::kB);
}
bool XboxController::GetBButtonReleased() {
return GetRawButtonReleased(Button::kB);
}
BooleanEvent XboxController::B(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetBButton(); });
}
bool XboxController::GetXButton() const {
return GetRawButton(Button::kX);
}
bool XboxController::GetXButtonPressed() {
return GetRawButtonPressed(Button::kX);
}
bool XboxController::GetXButtonReleased() {
return GetRawButtonReleased(Button::kX);
}
BooleanEvent XboxController::X(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetXButton(); });
}
bool XboxController::GetYButton() const {
return GetRawButton(Button::kY);
}
bool XboxController::GetYButtonPressed() {
return GetRawButtonPressed(Button::kY);
}
bool XboxController::GetYButtonReleased() {
return GetRawButtonReleased(Button::kY);
}
BooleanEvent XboxController::Y(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetYButton(); });
}
bool XboxController::GetBackButton() const {
return GetRawButton(Button::kBack);
}
bool XboxController::GetBackButtonPressed() {
return GetRawButtonPressed(Button::kBack);
}
bool XboxController::GetBackButtonReleased() {
return GetRawButtonReleased(Button::kBack);
}
BooleanEvent XboxController::Back(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetBackButton(); });
}
bool XboxController::GetStartButton() const {
return GetRawButton(Button::kStart);
}
bool XboxController::GetStartButtonPressed() {
return GetRawButtonPressed(Button::kStart);
}
bool XboxController::GetStartButtonReleased() {
return GetRawButtonReleased(Button::kStart);
}
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);
}

View File

@@ -1,103 +0,0 @@
// 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 "frc/simulation/PS4ControllerSim.h"
#include "frc/PS4Controller.h"
using namespace frc;
using namespace frc::sim;
PS4ControllerSim::PS4ControllerSim(const PS4Controller& joystick)
: GenericHIDSim{joystick} {
SetAxisCount(6);
SetButtonCount(14);
SetPOVCount(1);
}
PS4ControllerSim::PS4ControllerSim(int port) : GenericHIDSim{port} {
SetAxisCount(6);
SetButtonCount(14);
SetPOVCount(1);
}
void PS4ControllerSim::SetLeftX(double value) {
SetRawAxis(PS4Controller::Axis::kLeftX, value);
}
void PS4ControllerSim::SetRightX(double value) {
SetRawAxis(PS4Controller::Axis::kRightX, value);
}
void PS4ControllerSim::SetLeftY(double value) {
SetRawAxis(PS4Controller::Axis::kLeftY, value);
}
void PS4ControllerSim::SetRightY(double value) {
SetRawAxis(PS4Controller::Axis::kRightY, value);
}
void PS4ControllerSim::SetL2Axis(double value) {
SetRawAxis(PS4Controller::Axis::kL2, value);
}
void PS4ControllerSim::SetR2Axis(double value) {
SetRawAxis(PS4Controller::Axis::kR2, value);
}
void PS4ControllerSim::SetSquareButton(bool value) {
SetRawButton(PS4Controller::Button::kSquare, value);
}
void PS4ControllerSim::SetCrossButton(bool value) {
SetRawButton(PS4Controller::Button::kCross, value);
}
void PS4ControllerSim::SetCircleButton(bool value) {
SetRawButton(PS4Controller::Button::kCircle, value);
}
void PS4ControllerSim::SetTriangleButton(bool value) {
SetRawButton(PS4Controller::Button::kTriangle, value);
}
void PS4ControllerSim::SetL1Button(bool value) {
SetRawButton(PS4Controller::Button::kL1, value);
}
void PS4ControllerSim::SetR1Button(bool value) {
SetRawButton(PS4Controller::Button::kR1, value);
}
void PS4ControllerSim::SetL2Button(bool value) {
SetRawButton(PS4Controller::Button::kL2, value);
}
void PS4ControllerSim::SetR2Button(bool value) {
SetRawButton(PS4Controller::Button::kR2, value);
}
void PS4ControllerSim::SetShareButton(bool value) {
SetRawButton(PS4Controller::Button::kShare, value);
}
void PS4ControllerSim::SetOptionsButton(bool value) {
SetRawButton(PS4Controller::Button::kOptions, value);
}
void PS4ControllerSim::SetL3Button(bool value) {
SetRawButton(PS4Controller::Button::kL3, value);
}
void PS4ControllerSim::SetR3Button(bool value) {
SetRawButton(PS4Controller::Button::kR3, value);
}
void PS4ControllerSim::SetPSButton(bool value) {
SetRawButton(PS4Controller::Button::kPS, value);
}
void PS4ControllerSim::SetTouchpad(bool value) {
SetRawButton(PS4Controller::Button::kTouchpad, value);
}

View File

@@ -1,103 +0,0 @@
// 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 "frc/simulation/PS5ControllerSim.h"
#include "frc/PS5Controller.h"
using namespace frc;
using namespace frc::sim;
PS5ControllerSim::PS5ControllerSim(const PS5Controller& joystick)
: GenericHIDSim{joystick} {
SetAxisCount(6);
SetButtonCount(14);
SetPOVCount(1);
}
PS5ControllerSim::PS5ControllerSim(int port) : GenericHIDSim{port} {
SetAxisCount(6);
SetButtonCount(14);
SetPOVCount(1);
}
void PS5ControllerSim::SetLeftX(double value) {
SetRawAxis(PS5Controller::Axis::kLeftX, value);
}
void PS5ControllerSim::SetRightX(double value) {
SetRawAxis(PS5Controller::Axis::kRightX, value);
}
void PS5ControllerSim::SetLeftY(double value) {
SetRawAxis(PS5Controller::Axis::kLeftY, value);
}
void PS5ControllerSim::SetRightY(double value) {
SetRawAxis(PS5Controller::Axis::kRightY, value);
}
void PS5ControllerSim::SetL2Axis(double value) {
SetRawAxis(PS5Controller::Axis::kL2, value);
}
void PS5ControllerSim::SetR2Axis(double value) {
SetRawAxis(PS5Controller::Axis::kR2, value);
}
void PS5ControllerSim::SetSquareButton(bool value) {
SetRawButton(PS5Controller::Button::kSquare, value);
}
void PS5ControllerSim::SetCrossButton(bool value) {
SetRawButton(PS5Controller::Button::kCross, value);
}
void PS5ControllerSim::SetCircleButton(bool value) {
SetRawButton(PS5Controller::Button::kCircle, value);
}
void PS5ControllerSim::SetTriangleButton(bool value) {
SetRawButton(PS5Controller::Button::kTriangle, value);
}
void PS5ControllerSim::SetL1Button(bool value) {
SetRawButton(PS5Controller::Button::kL1, value);
}
void PS5ControllerSim::SetR1Button(bool value) {
SetRawButton(PS5Controller::Button::kR1, value);
}
void PS5ControllerSim::SetL2Button(bool value) {
SetRawButton(PS5Controller::Button::kL2, value);
}
void PS5ControllerSim::SetR2Button(bool value) {
SetRawButton(PS5Controller::Button::kR2, value);
}
void PS5ControllerSim::SetCreateButton(bool value) {
SetRawButton(PS5Controller::Button::kCreate, value);
}
void PS5ControllerSim::SetOptionsButton(bool value) {
SetRawButton(PS5Controller::Button::kOptions, value);
}
void PS5ControllerSim::SetL3Button(bool value) {
SetRawButton(PS5Controller::Button::kL3, value);
}
void PS5ControllerSim::SetR3Button(bool value) {
SetRawButton(PS5Controller::Button::kR3, value);
}
void PS5ControllerSim::SetPSButton(bool value) {
SetRawButton(PS5Controller::Button::kPS, value);
}
void PS5ControllerSim::SetTouchpad(bool value) {
SetRawButton(PS5Controller::Button::kTouchpad, value);
}

View File

@@ -1,87 +0,0 @@
// 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 "frc/simulation/XboxControllerSim.h"
#include "frc/XboxController.h"
using namespace frc;
using namespace frc::sim;
XboxControllerSim::XboxControllerSim(const XboxController& joystick)
: GenericHIDSim{joystick} {
SetAxisCount(6);
SetButtonCount(10);
SetPOVCount(1);
}
XboxControllerSim::XboxControllerSim(int port) : GenericHIDSim{port} {
SetAxisCount(6);
SetButtonCount(10);
SetPOVCount(1);
}
void XboxControllerSim::SetLeftX(double value) {
SetRawAxis(XboxController::Axis::kLeftX, value);
}
void XboxControllerSim::SetRightX(double value) {
SetRawAxis(XboxController::Axis::kRightX, value);
}
void XboxControllerSim::SetLeftY(double value) {
SetRawAxis(XboxController::Axis::kLeftY, value);
}
void XboxControllerSim::SetRightY(double value) {
SetRawAxis(XboxController::Axis::kRightY, value);
}
void XboxControllerSim::SetLeftTriggerAxis(double value) {
SetRawAxis(XboxController::Axis::kLeftTrigger, value);
}
void XboxControllerSim::SetRightTriggerAxis(double value) {
SetRawAxis(XboxController::Axis::kRightTrigger, value);
}
void XboxControllerSim::SetLeftBumper(bool state) {
SetRawButton(XboxController::Button::kLeftBumper, state);
}
void XboxControllerSim::SetRightBumper(bool state) {
SetRawButton(XboxController::Button::kRightBumper, state);
}
void XboxControllerSim::SetLeftStickButton(bool state) {
SetRawButton(XboxController::Button::kLeftStick, state);
}
void XboxControllerSim::SetRightStickButton(bool state) {
SetRawButton(XboxController::Button::kRightStick, state);
}
void XboxControllerSim::SetAButton(bool state) {
SetRawButton(XboxController::Button::kA, state);
}
void XboxControllerSim::SetBButton(bool state) {
SetRawButton(XboxController::Button::kB, state);
}
void XboxControllerSim::SetXButton(bool state) {
SetRawButton(XboxController::Button::kX, state);
}
void XboxControllerSim::SetYButton(bool state) {
SetRawButton(XboxController::Button::kY, state);
}
void XboxControllerSim::SetBackButton(bool state) {
SetRawButton(XboxController::Button::kBack, state);
}
void XboxControllerSim::SetStartButton(bool state) {
SetRawButton(XboxController::Button::kStart, state);
}