[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);
}

View File

@@ -1,559 +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.
#pragma once
#include "frc/GenericHID.h"
namespace frc {
/**
* Handle input from PS4 controllers connected to the Driver Station.
*
* This class handles PS4 input that comes from the Driver Station. Each time
* a value is requested the most recent value is returned. There is a single
* class instance for each controller and the mapping of ports to hardware
* buttons depends on the code in the Driver Station.
*
* Only first party controllers from Sony are guaranteed to have the correct
* mapping, and only through the official NI DS. Sim is not guaranteed to have
* the same mapping, as well as any 3rd party controllers.
*/
class PS4Controller : public GenericHID {
public:
/**
* Construct an instance of an PS4 controller.
*
* The controller index is the USB port on the Driver Station.
*
* @param port The port on the Driver Station that the controller is plugged
* into (0-5).
*/
explicit PS4Controller(int port);
~PS4Controller() override = default;
PS4Controller(PS4Controller&&) = default;
PS4Controller& operator=(PS4Controller&&) = default;
/**
* Get the X axis value of left side of the controller.
*
* @return the axis value.
*/
double GetLeftX() const;
/**
* Get the X axis value of right side of the controller.
*
* @return the axis value.
*/
double GetRightX() const;
/**
* Get the Y axis value of left side of the controller.
*
* @return the axis value.
*/
double GetLeftY() const;
/**
* Get the Y axis value of right side of the controller.
*
* @return the axis value.
*/
double GetRightY() const;
/**
* Get the L2 axis value of the controller. Note that this axis is bound to
* the range of [0, 1] as opposed to the usual [-1, 1].
*
* @return the axis value.
*/
double GetL2Axis() const;
/**
* Get the R2 axis value of the controller. Note that this axis is bound to
* the range of [0, 1] as opposed to the usual [-1, 1].
*
* @return the axis value.
*/
double GetR2Axis() const;
/**
* Read the value of the Square button on the controller.
*
* @return The state of the button.
*/
bool GetSquareButton() const;
/**
* Whether the Square button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetSquareButtonPressed();
/**
* Whether the Square button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetSquareButtonReleased();
/**
* Constructs an event instance around the square button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the square button's digital signal
* attached to the given loop.
*/
BooleanEvent Square(EventLoop* loop) const;
/**
* Read the value of the Cross button on the controller.
*
* @return The state of the button.
*/
bool GetCrossButton() const;
/**
* Whether the Cross button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetCrossButtonPressed();
/**
* Whether the Cross button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetCrossButtonReleased();
/**
* Constructs an event instance around the cross button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the cross button's digital signal
* attached to the given loop.
*/
BooleanEvent Cross(EventLoop* loop) const;
/**
* Read the value of the Circle button on the controller.
*
* @return The state of the button.
*/
bool GetCircleButton() const;
/**
* Whether the Circle button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetCircleButtonPressed();
/**
* Whether the Circle button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetCircleButtonReleased();
/**
* Constructs an event instance around the circle button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the circle button's digital signal
* attached to the given loop.
*/
BooleanEvent Circle(EventLoop* loop) const;
/**
* Read the value of the Triangle button on the controller.
*
* @return The state of the button.
*/
bool GetTriangleButton() const;
/**
* Whether the Triangle button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetTriangleButtonPressed();
/**
* Whether the Triangle button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetTriangleButtonReleased();
/**
* Constructs an event instance around the triangle button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the triangle button's digital signal
* attached to the given loop.
*/
BooleanEvent Triangle(EventLoop* loop) const;
/**
* Read the value of the L1 button on the controller.
*
* @return The state of the button.
*/
bool GetL1Button() const;
/**
* Whether the L1 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetL1ButtonPressed();
/**
* Whether the L1 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetL1ButtonReleased();
/**
* Constructs an event instance around the L1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the L1 button's digital signal
* attached to the given loop.
*/
BooleanEvent L1(EventLoop* loop) const;
/**
* Read the value of the R1 button on the controller.
*
* @return The state of the button.
*/
bool GetR1Button() const;
/**
* Whether the R1 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetR1ButtonPressed();
/**
* Whether the R1 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetR1ButtonReleased();
/**
* Constructs an event instance around the R1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the R1 button's digital signal
* attached to the given loop.
*/
BooleanEvent R1(EventLoop* loop) const;
/**
* Read the value of the L2 button on the controller.
*
* @return The state of the button.
*/
bool GetL2Button() const;
/**
* Whether the L2 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetL2ButtonPressed();
/**
* Whether the L2 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetL2ButtonReleased();
/**
* Constructs an event instance around the L2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the L2 button's digital signal
* attached to the given loop.
*/
BooleanEvent L2(EventLoop* loop) const;
/**
* Read the value of the R2 button on the controller.
*
* @return The state of the button.
*/
bool GetR2Button() const;
/**
* Whether the R2 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetR2ButtonPressed();
/**
* Whether the R2 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetR2ButtonReleased();
/**
* Constructs an event instance around the R2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the R2 button's digital signal
* attached to the given loop.
*/
BooleanEvent R2(EventLoop* loop) const;
/**
* Read the value of the Share button on the controller.
*
* @return The state of the button.
*/
bool GetShareButton() const;
/**
* Whether the Share button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetShareButtonPressed();
/**
* Whether the Share button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetShareButtonReleased();
/**
* Constructs an event instance around the share button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the share button's digital signal
* attached to the given loop.
*/
BooleanEvent Share(EventLoop* loop) const;
/**
* Read the value of the Options button on the controller.
*
* @return The state of the button.
*/
bool GetOptionsButton() const;
/**
* Whether the Options button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetOptionsButtonPressed();
/**
* Whether the Options button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetOptionsButtonReleased();
/**
* Constructs an event instance around the options button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the options button's digital signal
* attached to the given loop.
*/
BooleanEvent Options(EventLoop* loop) const;
/**
* Read the value of the L3 button (pressing the left analog stick) on the
* controller.
*
* @return The state of the button.
*/
bool GetL3Button() const;
/**
* Whether the L3 (left stick) button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetL3ButtonPressed();
/**
* Whether the L3 (left stick) button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetL3ButtonReleased();
/**
* Constructs an event instance around the L3 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the L3 button's digital signal
* attached to the given loop.
*/
BooleanEvent L3(EventLoop* loop) const;
/**
* Read the value of the R3 button (pressing the right analog stick) on the
* controller.
*
* @return The state of the button.
*/
bool GetR3Button() const;
/**
* Whether the R3 (right stick) button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetR3ButtonPressed();
/**
* Whether the R3 (right stick) button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetR3ButtonReleased();
/**
* Constructs an event instance around the R3 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the R3 button's digital signal
* attached to the given loop.
*/
BooleanEvent R3(EventLoop* loop) const;
/**
* Read the value of the PS button on the controller.
*
* @return The state of the button.
*/
bool GetPSButton() const;
/**
* Whether the PS button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetPSButtonPressed();
/**
* Whether the PS button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetPSButtonReleased();
/**
* Constructs an event instance around the PS button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the PS button's digital signal
* attached to the given loop.
*/
BooleanEvent PS(EventLoop* loop) const;
/**
* Read the value of the touchpad button on the controller.
*
* @return The state of the button.
*/
bool GetTouchpad() const;
/**
* Whether the touchpad was pressed since the last check.
*
* @return Whether the touchpad was pressed since the last check.
*/
bool GetTouchpadPressed();
/**
* Whether the touchpad was released since the last check.
*
* @return Whether the touchpad was released since the last check.
*/
bool GetTouchpadReleased();
/**
* Constructs an event instance around the touchpad's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the touchpad's digital signal
* attached to the given loop.
*/
BooleanEvent Touchpad(EventLoop* loop) const;
/**
* Represents a digital button on a PS4Controller.
*/
struct Button {
/// Square button.
static constexpr int kSquare = 1;
/// X button.
static constexpr int kCross = 2;
/// Circle button.
static constexpr int kCircle = 3;
/// Triangle button.
static constexpr int kTriangle = 4;
/// Left Trigger 1 button.
static constexpr int kL1 = 5;
/// Right Trigger 1 button.
static constexpr int kR1 = 6;
/// Left Trigger 2 button.
static constexpr int kL2 = 7;
/// Right Trigger 2 button.
static constexpr int kR2 = 8;
/// Share button.
static constexpr int kShare = 9;
/// Option button.
static constexpr int kOptions = 10;
/// Left stick button.
static constexpr int kL3 = 11;
/// Right stick button.
static constexpr int kR3 = 12;
/// PlayStation button.
static constexpr int kPS = 13;
/// Touchpad click button.
static constexpr int kTouchpad = 14;
};
/**
* Represents an axis on a PS4Controller.
*/
struct Axis {
/// Left X axis.
static constexpr int kLeftX = 0;
/// Left Y axis.
static constexpr int kLeftY = 1;
/// Right X axis.
static constexpr int kRightX = 2;
/// Right Y axis.
static constexpr int kRightY = 5;
/// Left Trigger 2.
static constexpr int kL2 = 3;
/// Right Trigger 2.
static constexpr int kR2 = 4;
};
};
} // namespace frc

View File

@@ -1,559 +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.
#pragma once
#include "frc/GenericHID.h"
namespace frc {
/**
* Handle input from PS5 controllers connected to the Driver Station.
*
* This class handles PS5 input that comes from the Driver Station. Each time
* a value is requested the most recent value is returned. There is a single
* class instance for each controller and the mapping of ports to hardware
* buttons depends on the code in the Driver Station.
*
* Only first party controllers from Sony are guaranteed to have the correct
* mapping, and only through the official NI DS. Sim is not guaranteed to have
* the same mapping, as well as any 3rd party controllers.
*/
class PS5Controller : public GenericHID {
public:
/**
* Construct an instance of an PS5 controller.
*
* The controller index is the USB port on the Driver Station.
*
* @param port The port on the Driver Station that the controller is plugged
* into (0-5).
*/
explicit PS5Controller(int port);
~PS5Controller() override = default;
PS5Controller(PS5Controller&&) = default;
PS5Controller& operator=(PS5Controller&&) = default;
/**
* Get the X axis value of left side of the controller.
*
* @return the axis value.
*/
double GetLeftX() const;
/**
* Get the X axis value of right side of the controller.
*
* @return the axis value.
*/
double GetRightX() const;
/**
* Get the Y axis value of left side of the controller.
*
* @return the axis value.
*/
double GetLeftY() const;
/**
* Get the Y axis value of right side of the controller.
*
* @return the axis value.
*/
double GetRightY() const;
/**
* Get the L2 axis value of the controller. Note that this axis is bound to
* the range of [0, 1] as opposed to the usual [-1, 1].
*
* @return the axis value.
*/
double GetL2Axis() const;
/**
* Get the R2 axis value of the controller. Note that this axis is bound to
* the range of [0, 1] as opposed to the usual [-1, 1].
*
* @return the axis value.
*/
double GetR2Axis() const;
/**
* Read the value of the Square button on the controller.
*
* @return The state of the button.
*/
bool GetSquareButton() const;
/**
* Whether the Square button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetSquareButtonPressed();
/**
* Whether the Square button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetSquareButtonReleased();
/**
* Constructs an event instance around the square button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the square button's digital signal
* attached to the given loop.
*/
BooleanEvent Square(EventLoop* loop) const;
/**
* Read the value of the Cross button on the controller.
*
* @return The state of the button.
*/
bool GetCrossButton() const;
/**
* Whether the Cross button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetCrossButtonPressed();
/**
* Whether the Cross button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetCrossButtonReleased();
/**
* Constructs an event instance around the cross button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the cross button's digital signal
* attached to the given loop.
*/
BooleanEvent Cross(EventLoop* loop) const;
/**
* Read the value of the Circle button on the controller.
*
* @return The state of the button.
*/
bool GetCircleButton() const;
/**
* Whether the Circle button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetCircleButtonPressed();
/**
* Whether the Circle button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetCircleButtonReleased();
/**
* Constructs an event instance around the circle button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the circle button's digital signal
* attached to the given loop.
*/
BooleanEvent Circle(EventLoop* loop) const;
/**
* Read the value of the Triangle button on the controller.
*
* @return The state of the button.
*/
bool GetTriangleButton() const;
/**
* Whether the Triangle button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetTriangleButtonPressed();
/**
* Whether the Triangle button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetTriangleButtonReleased();
/**
* Constructs an event instance around the triangle button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the triangle button's digital signal
* attached to the given loop.
*/
BooleanEvent Triangle(EventLoop* loop) const;
/**
* Read the value of the L1 button on the controller.
*
* @return The state of the button.
*/
bool GetL1Button() const;
/**
* Whether the L1 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetL1ButtonPressed();
/**
* Whether the L1 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetL1ButtonReleased();
/**
* Constructs an event instance around the L1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the L1 button's digital signal
* attached to the given loop.
*/
BooleanEvent L1(EventLoop* loop) const;
/**
* Read the value of the R1 button on the controller.
*
* @return The state of the button.
*/
bool GetR1Button() const;
/**
* Whether the R1 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetR1ButtonPressed();
/**
* Whether the R1 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetR1ButtonReleased();
/**
* Constructs an event instance around the R1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the R1 button's digital signal
* attached to the given loop.
*/
BooleanEvent R1(EventLoop* loop) const;
/**
* Read the value of the L2 button on the controller.
*
* @return The state of the button.
*/
bool GetL2Button() const;
/**
* Whether the L2 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetL2ButtonPressed();
/**
* Whether the L2 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetL2ButtonReleased();
/**
* Constructs an event instance around the L2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the L2 button's digital signal
* attached to the given loop.
*/
BooleanEvent L2(EventLoop* loop) const;
/**
* Read the value of the R2 button on the controller.
*
* @return The state of the button.
*/
bool GetR2Button() const;
/**
* Whether the R2 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetR2ButtonPressed();
/**
* Whether the R2 button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetR2ButtonReleased();
/**
* Constructs an event instance around the R2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the R2 button's digital signal
* attached to the given loop.
*/
BooleanEvent R2(EventLoop* loop) const;
/**
* Read the value of the Create button on the controller.
*
* @return The state of the button.
*/
bool GetCreateButton() const;
/**
* Whether the Create button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetCreateButtonPressed();
/**
* Whether the Create button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetCreateButtonReleased();
/**
* Constructs an event instance around the Create button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Create button's digital signal
* attached to the given loop.
*/
BooleanEvent Create(EventLoop* loop) const;
/**
* Read the value of the Options button on the controller.
*
* @return The state of the button.
*/
bool GetOptionsButton() const;
/**
* Whether the Options button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetOptionsButtonPressed();
/**
* Whether the Options button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetOptionsButtonReleased();
/**
* Constructs an event instance around the options button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the options button's digital signal
* attached to the given loop.
*/
BooleanEvent Options(EventLoop* loop) const;
/**
* Read the value of the L3 button (pressing the left analog stick) on the
* controller.
*
* @return The state of the button.
*/
bool GetL3Button() const;
/**
* Whether the L3 (left stick) button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetL3ButtonPressed();
/**
* Whether the L3 (left stick) button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetL3ButtonReleased();
/**
* Constructs an event instance around the L3 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the L3 button's digital signal
* attached to the given loop.
*/
BooleanEvent L3(EventLoop* loop) const;
/**
* Read the value of the R3 button (pressing the right analog stick) on the
* controller.
*
* @return The state of the button.
*/
bool GetR3Button() const;
/**
* Whether the R3 (right stick) button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetR3ButtonPressed();
/**
* Whether the R3 (right stick) button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetR3ButtonReleased();
/**
* Constructs an event instance around the R3 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the R3 button's digital signal
* attached to the given loop.
*/
BooleanEvent R3(EventLoop* loop) const;
/**
* Read the value of the PS button on the controller.
*
* @return The state of the button.
*/
bool GetPSButton() const;
/**
* Whether the PS button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetPSButtonPressed();
/**
* Whether the PS button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetPSButtonReleased();
/**
* Constructs an event instance around the PS button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the PS button's digital signal
* attached to the given loop.
*/
BooleanEvent PS(EventLoop* loop) const;
/**
* Read the value of the touchpad button on the controller.
*
* @return The state of the button.
*/
bool GetTouchpad() const;
/**
* Whether the touchpad was pressed since the last check.
*
* @return Whether the touchpad was pressed since the last check.
*/
bool GetTouchpadPressed();
/**
* Whether the touchpad was released since the last check.
*
* @return Whether the touchpad was released since the last check.
*/
bool GetTouchpadReleased();
/**
* Constructs an event instance around the touchpad's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the touchpad's digital signal
* attached to the given loop.
*/
BooleanEvent Touchpad(EventLoop* loop) const;
/**
* Represents a digital button on a PS5Controller.
*/
struct Button {
/// Square button.
static constexpr int kSquare = 1;
/// X button.
static constexpr int kCross = 2;
/// Circle button.
static constexpr int kCircle = 3;
/// Triangle button.
static constexpr int kTriangle = 4;
/// Left trigger 1 button.
static constexpr int kL1 = 5;
/// Right trigger 1 button.
static constexpr int kR1 = 6;
/// Left trigger 2 button.
static constexpr int kL2 = 7;
/// Right trigger 2 button.
static constexpr int kR2 = 8;
/// Create button.
static constexpr int kCreate = 9;
/// Options button.
static constexpr int kOptions = 10;
/// Left stick button.
static constexpr int kL3 = 11;
/// Right stick button.
static constexpr int kR3 = 12;
/// PlayStation button.
static constexpr int kPS = 13;
/// Touchpad click button.
static constexpr int kTouchpad = 14;
};
/**
* Represents an axis on a PS5Controller.
*/
struct Axis {
/// Left X axis.
static constexpr int kLeftX = 0;
/// Left Y axis.
static constexpr int kLeftY = 1;
/// Right X axis.
static constexpr int kRightX = 2;
/// Right Y axis.
static constexpr int kRightY = 5;
/// Left Trigger 2.
static constexpr int kL2 = 3;
/// Right Trigger 2.
static constexpr int kR2 = 4;
};
};
} // namespace frc

View File

@@ -1,568 +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.
#pragma once
#include "frc/GenericHID.h"
namespace frc {
/**
* Handle input from Stadia controllers connected to the Driver
* Station.
*
* This class handles Stadia input that comes from the Driver Station. Each time
* a value is requested the most recent value is returned. There is a single
* class instance for each controller and the mapping of ports to hardware
* buttons depends on the code in the Driver Station.
*/
class StadiaController : public GenericHID {
public:
/**
* Construct an instance of a Stadia controller.
*
* The controller index is the USB port on the Driver Station.
*
* @param port The port on the Driver Station that the controller is plugged
* into (0-5).
*/
explicit StadiaController(int port);
~StadiaController() override = default;
StadiaController(StadiaController&&) = default;
StadiaController& operator=(StadiaController&&) = default;
/**
* Get the X axis value of left side of the controller.
*
* @return the axis value
*/
double GetLeftX() const;
/**
* Get the X axis value of right side of the controller.
*
* @return the axis value
*/
double GetRightX() const;
/**
* Get the Y axis value of left side of the controller.
*
* @return the axis value
*/
double GetLeftY() const;
/**
* Get the Y axis value of right side of the controller.
*
* @return the axis value
*/
double GetRightY() const;
/**
* Read the value of the left bumper (LB) button on the controller.
*
* @return the state of the button
*/
bool GetLeftBumper() const;
/**
* Read the value of the right bumper (RB) button on the controller.
*
* @return the state of the button
*/
bool GetRightBumper() const;
/**
* Whether the left bumper (LB) was pressed since the last check.
*
* @return Whether the button was pressed since the last check
*/
bool GetLeftBumperPressed();
/**
* Whether the right bumper (RB) was pressed since the last check.
*
* @return Whether the button was pressed since the last check
*/
bool GetRightBumperPressed();
/**
* Whether the left bumper (LB) was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetLeftBumperReleased();
/**
* Whether the right bumper (RB) was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetRightBumperReleased();
/**
* Constructs an event instance around the left bumper's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left bumper's digital signal
* attached to the given loop.
*/
BooleanEvent LeftBumper(EventLoop* loop) const;
/**
* Constructs an event instance around the right bumper's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right bumper's digital signal
* attached to the given loop.
*/
BooleanEvent RightBumper(EventLoop* loop) const;
/**
* Read the value of the left stick button (LSB) on the controller.
*
* @return the state of the button
*/
bool GetLeftStickButton() const;
/**
* Read the value of the right stick button (RSB) on the controller.
*
* @return the state of the button
*/
bool GetRightStickButton() const;
/**
* Whether the left stick button (LSB) was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetLeftStickButtonPressed();
/**
* Whether the right stick button (RSB) was pressed since the last check.
*
* @return Whether the button was pressed since the last check
*/
bool GetRightStickButtonPressed();
/**
* Whether the left stick button (LSB) was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetLeftStickButtonReleased();
/**
* Whether the right stick button (RSB) was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetRightStickButtonReleased();
/**
* Constructs an event instance around the left stick's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left stick's digital signal
* attached to the given loop.
*/
BooleanEvent LeftStick(EventLoop* loop) const;
/**
* Constructs an event instance around the right stick's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right stick's digital signal
* attached to the given loop.
*/
BooleanEvent RightStick(EventLoop* loop) const;
/**
* Read the value of the A button on the controller.
*
* @return The state of the button.
*/
bool GetAButton() const;
/**
* Whether the A button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetAButtonPressed();
/**
* Whether the A button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetAButtonReleased();
/**
* Constructs an event instance around the A button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the A button's digital signal
* attached to the given loop.
*/
BooleanEvent A(EventLoop* loop) const;
/**
* Read the value of the B button on the controller.
*
* @return The state of the button.
*/
bool GetBButton() const;
/**
* Whether the B button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetBButtonPressed();
/**
* Whether the B button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetBButtonReleased();
/**
* Constructs an event instance around the B button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the B button's digital signal
* attached to the given loop.
*/
BooleanEvent B(EventLoop* loop) const;
/**
* Read the value of the X button on the controller.
*
* @return The state of the button.
*/
bool GetXButton() const;
/**
* Whether the X button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetXButtonPressed();
/**
* Whether the X button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetXButtonReleased();
/**
* Constructs an event instance around the X button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the X button's digital signal
* attached to the given loop.
*/
BooleanEvent X(EventLoop* loop) const;
/**
* Read the value of the Y button on the controller.
*
* @return The state of the button.
*/
bool GetYButton() const;
/**
* Whether the Y button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetYButtonPressed();
/**
* Whether the Y button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetYButtonReleased();
/**
* Constructs an event instance around the Y button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Y button's digital signal
* attached to the given loop.
*/
BooleanEvent Y(EventLoop* loop) const;
/**
* Read the value of the ellipses button on the controller.
*
* @return The state of the button.
*/
bool GetEllipsesButton() const;
/**
* Whether the ellipses button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetEllipsesButtonPressed();
/**
* Whether the ellipses button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetEllipsesButtonReleased();
/**
* Constructs an event instance around the ellipses button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the ellipses button's digital signal
* attached to the given loop.
*/
BooleanEvent Ellipses(EventLoop* loop) const;
/**
* Read the value of the hamburger button on the controller.
*
* @return The state of the button.
*/
bool GetHamburgerButton() const;
/**
* Whether the hamburger button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetHamburgerButtonPressed();
/**
* Whether the hamburger button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetHamburgerButtonReleased();
/**
* Constructs an event instance around the hamburger button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the hamburger button's digital
* signal attached to the given loop.
*/
BooleanEvent Hamburger(EventLoop* loop) const;
/**
* Read the value of the stadia button on the controller.
*
* @return The state of the button.
*/
bool GetStadiaButton() const;
/**
* Whether the stadia button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetStadiaButtonPressed();
/**
* Whether the stadia button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetStadiaButtonReleased();
/**
* Constructs an event instance around the stadia button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the stadia button's digital signal
* attached to the given loop.
*/
BooleanEvent Stadia(EventLoop* loop) const;
/**
* Read the value of the google button on the controller.
*
* @return The state of the button.
*/
bool GetGoogleButton() const;
/**
* Whether the google button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetGoogleButtonPressed();
/**
* Whether the google button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetGoogleButtonReleased();
/**
* Constructs an event instance around the google button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the google button's digital signal
* attached to the given loop.
*/
BooleanEvent Google(EventLoop* loop) const;
/**
* Read the value of the frame button on the controller.
*
* @return The state of the button.
*/
bool GetFrameButton() const;
/**
* Whether the frame button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetFrameButtonPressed();
/**
* Whether the frame button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetFrameButtonReleased();
/**
* Constructs an event instance around the frame button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the frame button's digital signal
* attached to the given loop.
*/
BooleanEvent Frame(EventLoop* loop) const;
/**
* Read the value of the left trigger button on the controller.
*
* @return The state of the button.
*/
bool GetLeftTriggerButton() const;
/**
* Whether the left trigger button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetLeftTriggerButtonPressed();
/**
* Whether the left trigger button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetLeftTriggerButtonReleased();
/**
* Constructs an event instance around the left trigger button's digital
* signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left trigger button's digital
* signal attached to the given loop.
*/
BooleanEvent LeftTrigger(EventLoop* loop) const;
/**
* Read the value of the right trigger button on the controller.
*
* @return The state of the button.
*/
bool GetRightTriggerButton() const;
/**
* Whether the right trigger button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetRightTriggerButtonPressed();
/**
* Whether the right trigger button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetRightTriggerButtonReleased();
/**
* Constructs an event instance around the right trigger button's digital
* signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right trigger button's digital
* signal attached to the given loop.
*/
BooleanEvent RightTrigger(EventLoop* loop) const;
/**
* Represents a digital button on a StadiaController.
*/
struct Button {
/// A button.
static constexpr int kA = 1;
/// B button.
static constexpr int kB = 2;
/// X button.
static constexpr int kX = 3;
/// Y button.
static constexpr int kY = 4;
/// Left bumper button.
static constexpr int kLeftBumper = 5;
/// Right bumper button.
static constexpr int kRightBumper = 6;
/// Left stick button.
static constexpr int kLeftStick = 7;
/// Right stick button.
static constexpr int kRightStick = 8;
/// Ellipses button.
static constexpr int kEllipses = 9;
/// Hamburger button.
static constexpr int kHamburger = 10;
/// Stadia button.
static constexpr int kStadia = 11;
/// Right trigger button.
static constexpr int kRightTrigger = 12;
/// Left trigger button.
static constexpr int kLeftTrigger = 13;
/// Google button.
static constexpr int kGoogle = 14;
/// Frame button.
static constexpr int kFrame = 15;
};
/**
* Represents an axis on a StadiaController.
*/
struct Axis {
/// Left X axis.
static constexpr int kLeftX = 0;
/// Right X axis.
static constexpr int kRightX = 4;
/// Left Y axis.
static constexpr int kLeftY = 1;
/// Right Y axis.
static constexpr int kRightY = 5;
};
};
} // namespace frc

View File

@@ -1,470 +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.
#pragma once
#include "frc/GenericHID.h"
namespace frc {
/**
* Handle input from Xbox 360 or Xbox One controllers connected to the Driver
* Station.
*
* This class handles Xbox input that comes from the Driver Station. Each time a
* value is requested the most recent value is returned. There is a single class
* instance for each controller and the mapping of ports to hardware buttons
* depends on the code in the Driver Station.
*
* Only first party controllers from Microsoft are guaranteed to have the
* correct mapping, and only through the official NI DS. Sim is not guaranteed
* to have the same mapping, as well as any 3rd party controllers.
*/
class XboxController : public GenericHID {
public:
/**
* Construct an instance of an Xbox controller.
*
* The controller index is the USB port on the Driver Station.
*
* @param port The port on the Driver Station that the controller is plugged
* into (0-5).
*/
explicit XboxController(int port);
~XboxController() override = default;
XboxController(XboxController&&) = default;
XboxController& operator=(XboxController&&) = default;
/**
* Get the X axis value of left side of the controller.
*
* @return the axis value
*/
double GetLeftX() const;
/**
* Get the X axis value of right side of the controller.
*
* @return the axis value
*/
double GetRightX() const;
/**
* Get the Y axis value of left side of the controller.
*
* @return the axis value
*/
double GetLeftY() const;
/**
* Get the Y axis value of right side of the controller.
*
* @return the axis value
*/
double GetRightY() const;
/**
* Get the left trigger (LT) axis value of the controller. Note that this axis
* is bound to the range of [0, 1] as opposed to the usual [-1, 1].
*
* @return the axis value
*/
double GetLeftTriggerAxis() const;
/**
* Get the right trigger (RT) axis value of the controller. Note that this
* axis is bound to the range of [0, 1] as opposed to the usual [-1, 1].
*
* @return the axis value
*/
double GetRightTriggerAxis() const;
/**
* Read the value of the left bumper (LB) button on the controller.
*
* @return the state of the button
*/
bool GetLeftBumper() const;
/**
* Read the value of the right bumper (RB) button on the controller.
*
* @return the state of the button
*/
bool GetRightBumper() const;
/**
* Whether the left bumper (LB) was pressed since the last check.
*
* @return Whether the button was pressed since the last check
*/
bool GetLeftBumperPressed();
/**
* Whether the right bumper (RB) was pressed since the last check.
*
* @return Whether the button was pressed since the last check
*/
bool GetRightBumperPressed();
/**
* Whether the left bumper (LB) was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetLeftBumperReleased();
/**
* Whether the right bumper (RB) was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetRightBumperReleased();
/**
* Constructs an event instance around the left bumper's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left bumper's digital signal
* attached to the given loop.
*/
BooleanEvent LeftBumper(EventLoop* loop) const;
/**
* Constructs an event instance around the right bumper's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right bumper's digital signal
* attached to the given loop.
*/
BooleanEvent RightBumper(EventLoop* loop) const;
/**
* Read the value of the left stick button (LSB) on the controller.
*
* @return the state of the button
*/
bool GetLeftStickButton() const;
/**
* Read the value of the right stick button (RSB) on the controller.
*
* @return the state of the button
*/
bool GetRightStickButton() const;
/**
* Whether the left stick button (LSB) was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetLeftStickButtonPressed();
/**
* Whether the right stick button (RSB) was pressed since the last check.
*
* @return Whether the button was pressed since the last check
*/
bool GetRightStickButtonPressed();
/**
* Whether the left stick button (LSB) was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetLeftStickButtonReleased();
/**
* Whether the right stick button (RSB) was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetRightStickButtonReleased();
/**
* Constructs an event instance around the left stick's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left stick's digital signal
* attached to the given loop.
*/
BooleanEvent LeftStick(EventLoop* loop) const;
/**
* Constructs an event instance around the right stick's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right stick's digital signal
* attached to the given loop.
*/
BooleanEvent RightStick(EventLoop* loop) const;
/**
* Read the value of the A button on the controller.
*
* @return The state of the button.
*/
bool GetAButton() const;
/**
* Whether the A button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetAButtonPressed();
/**
* Whether the A button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetAButtonReleased();
/**
* Constructs an event instance around the A button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the A button's digital signal
* attached to the given loop.
*/
BooleanEvent A(EventLoop* loop) const;
/**
* Read the value of the B button on the controller.
*
* @return The state of the button.
*/
bool GetBButton() const;
/**
* Whether the B button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetBButtonPressed();
/**
* Whether the B button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetBButtonReleased();
/**
* Constructs an event instance around the B button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the B button's digital signal
* attached to the given loop.
*/
BooleanEvent B(EventLoop* loop) const;
/**
* Read the value of the X button on the controller.
*
* @return The state of the button.
*/
bool GetXButton() const;
/**
* Whether the X button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetXButtonPressed();
/**
* Whether the X button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetXButtonReleased();
/**
* Constructs an event instance around the X button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the X button's digital signal
* attached to the given loop.
*/
BooleanEvent X(EventLoop* loop) const;
/**
* Read the value of the Y button on the controller.
*
* @return The state of the button.
*/
bool GetYButton() const;
/**
* Whether the Y button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetYButtonPressed();
/**
* Whether the Y button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetYButtonReleased();
/**
* Constructs an event instance around the Y button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the Y button's digital signal
* attached to the given loop.
*/
BooleanEvent Y(EventLoop* loop) const;
/**
* Read the value of the back button on the controller.
*
* @return The state of the button.
*/
bool GetBackButton() const;
/**
* Whether the back button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetBackButtonPressed();
/**
* Whether the back button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetBackButtonReleased();
/**
* Constructs an event instance around the back button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the back button's digital signal
* attached to the given loop.
*/
BooleanEvent Back(EventLoop* loop) const;
/**
* Read the value of the start button on the controller.
*
* @return The state of the button.
*/
bool GetStartButton() const;
/**
* Whether the start button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetStartButtonPressed();
/**
* Whether the start button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetStartButtonReleased();
/**
* Constructs an event instance around the start button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the start button's digital signal
* attached to the given loop.
*/
BooleanEvent Start(EventLoop* loop) const;
/**
* Constructs an event instance around the axis value of the left trigger. The
* returned trigger will be true when the axis value is greater than {@code
* threshold}.
* @param threshold the minimum axis value for the returned event to be true.
* This value should be in the range [0, 1] where 0 is the unpressed state of
* the axis.
* @param loop the event loop instance to attach the event to.
* @return an event instance that is true when the left trigger's axis exceeds
* the provided threshold, attached to the given event loop
*/
BooleanEvent LeftTrigger(double threshold, EventLoop* loop) const;
/**
* Constructs an event instance around the axis value of the left trigger.
* The returned trigger will be true when the axis value is greater than 0.5.
* @param loop the event loop instance to attach the event to.
* @return an event instance that is true when the left trigger's axis
* exceeds 0.5, attached to the given event loop
*/
BooleanEvent LeftTrigger(EventLoop* loop) const;
/**
* Constructs an event instance around the axis value of the right trigger.
* The returned trigger will be true when the axis value is greater than
* {@code threshold}.
* @param threshold the minimum axis value for the returned event to be true.
* This value should be in the range [0, 1] where 0 is the unpressed state of
* the axis.
* @param loop the event loop instance to attach the event to.
* @return an event instance that is true when the right trigger's axis
* exceeds the provided threshold, attached to the given event loop
*/
BooleanEvent RightTrigger(double threshold, EventLoop* loop) const;
/**
* Constructs an event instance around the axis value of the right trigger.
* The returned trigger will be true when the axis value is greater than 0.5.
* @param loop the event loop instance to attach the event to.
* @return an event instance that is true when the right trigger's axis
* exceeds 0.5, attached to the given event loop
*/
BooleanEvent RightTrigger(EventLoop* loop) const;
/** Represents a digital button on an XboxController. */
struct Button {
/// Left bumper.
static constexpr int kLeftBumper = 5;
/// Right bumper.
static constexpr int kRightBumper = 6;
/// Left stick.
static constexpr int kLeftStick = 9;
/// Right stick.
static constexpr int kRightStick = 10;
/// A.
static constexpr int kA = 1;
/// B.
static constexpr int kB = 2;
/// X.
static constexpr int kX = 3;
/// Y.
static constexpr int kY = 4;
/// Back.
static constexpr int kBack = 7;
/// Start.
static constexpr int kStart = 8;
};
/** Represents an axis on an XboxController. */
struct Axis {
/// Left X.
static constexpr int kLeftX = 0;
/// Right X.
static constexpr int kRightX = 4;
/// Left Y.
static constexpr int kLeftY = 1;
/// Right Y.
static constexpr int kRightY = 5;
/// Left trigger.
static constexpr int kLeftTrigger = 2;
/// Right trigger.
static constexpr int kRightTrigger = 3;
};
};
} // namespace frc

View File

@@ -1,176 +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.
#pragma once
#include "frc/simulation/GenericHIDSim.h"
namespace frc {
class PS4Controller;
namespace sim {
/**
* Class to control a simulated PS4 controller.
*/
class PS4ControllerSim : public GenericHIDSim {
public:
/**
* Constructs from a PS4Controller object.
*
* @param joystick controller to simulate
*/
explicit PS4ControllerSim(const PS4Controller& joystick);
/**
* Constructs from a joystick port number.
*
* @param port port number
*/
explicit PS4ControllerSim(int port);
/**
* Change the X axis value of the controller's left stick.
*
* @param value the new value
*/
void SetLeftX(double value);
/**
* Change the X axis value of the controller's right stick.
*
* @param value the new value
*/
void SetRightX(double value);
/**
* Change the Y axis value of the controller's left stick.
*
* @param value the new value
*/
void SetLeftY(double value);
/**
* Change the Y axis value of the controller's right stick.
*
* @param value the new value
*/
void SetRightY(double value);
/**
* Change the L2 axis axis value of the controller.
*
* @param value the new value
*/
void SetL2Axis(double value);
/**
* Change the R2 axis value of the controller.
*
* @param value the new value
*/
void SetR2Axis(double value);
/**
* Change the value of the Square button on the controller.
*
* @param value the new value
*/
void SetSquareButton(bool value);
/**
* Change the value of the Cross button on the controller.
*
* @param value the new value
*/
void SetCrossButton(bool value);
/**
* Change the value of the Circle button on the controller.
*
* @param value the new value
*/
void SetCircleButton(bool value);
/**
* Change the value of the Triangle button on the controller.
*
* @param value the new value
*/
void SetTriangleButton(bool value);
/**
* Change the value of the L1 button on the controller.
*
* @param value the new value
*/
void SetL1Button(bool value);
/**
* Change the value of the R1 button on the controller.
*
* @param value the new value
*/
void SetR1Button(bool value);
/**
* Change the value of the L2 button on the controller.
*
* @param value the new value
*/
void SetL2Button(bool value);
/**
* Change the value of the R2 button on the controller.
*
* @param value the new value
*/
void SetR2Button(bool value);
/**
* Change the value of the Share button on the controller.
*
* @param value the new value
*/
void SetShareButton(bool value);
/**
* Change the value of the Options button on the controller.
*
* @param value the new value
*/
void SetOptionsButton(bool value);
/**
* Change the value of the L3 (left stick) button on the controller.
*
* @param value the new value
*/
void SetL3Button(bool value);
/**
* Change the value of the R3 (right stick) button on the controller.
*
* @param value the new value
*/
void SetR3Button(bool value);
/**
* Change the value of the PS button on the controller.
*
* @param value the new value
*/
void SetPSButton(bool value);
/**
* Change the value of the touchpad button on the controller.
*
* @param value the new value
*/
void SetTouchpad(bool value);
};
} // namespace sim
} // namespace frc

View File

@@ -1,176 +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.
#pragma once
#include "frc/simulation/GenericHIDSim.h"
namespace frc {
class PS5Controller;
namespace sim {
/**
* Class to control a simulated PS5 controller.
*/
class PS5ControllerSim : public GenericHIDSim {
public:
/**
* Constructs from a PS5Controller object.
*
* @param joystick controller to simulate
*/
explicit PS5ControllerSim(const PS5Controller& joystick);
/**
* Constructs from a joystick port number.
*
* @param port port number
*/
explicit PS5ControllerSim(int port);
/**
* Change the X axis value of the controller's left stick.
*
* @param value the new value
*/
void SetLeftX(double value);
/**
* Change the X axis value of the controller's right stick.
*
* @param value the new value
*/
void SetRightX(double value);
/**
* Change the Y axis value of the controller's left stick.
*
* @param value the new value
*/
void SetLeftY(double value);
/**
* Change the Y axis value of the controller's right stick.
*
* @param value the new value
*/
void SetRightY(double value);
/**
* Change the L2 axis axis value of the controller.
*
* @param value the new value
*/
void SetL2Axis(double value);
/**
* Change the R2 axis value of the controller.
*
* @param value the new value
*/
void SetR2Axis(double value);
/**
* Change the value of the Square button on the controller.
*
* @param value the new value
*/
void SetSquareButton(bool value);
/**
* Change the value of the Cross button on the controller.
*
* @param value the new value
*/
void SetCrossButton(bool value);
/**
* Change the value of the Circle button on the controller.
*
* @param value the new value
*/
void SetCircleButton(bool value);
/**
* Change the value of the Triangle button on the controller.
*
* @param value the new value
*/
void SetTriangleButton(bool value);
/**
* Change the value of the L1 button on the controller.
*
* @param value the new value
*/
void SetL1Button(bool value);
/**
* Change the value of the R1 button on the controller.
*
* @param value the new value
*/
void SetR1Button(bool value);
/**
* Change the value of the L2 button on the controller.
*
* @param value the new value
*/
void SetL2Button(bool value);
/**
* Change the value of the R2 button on the controller.
*
* @param value the new value
*/
void SetR2Button(bool value);
/**
* Change the value of the Create button on the controller.
*
* @param value the new value
*/
void SetCreateButton(bool value);
/**
* Change the value of the Options button on the controller.
*
* @param value the new value
*/
void SetOptionsButton(bool value);
/**
* Change the value of the L3 (left stick) button on the controller.
*
* @param value the new value
*/
void SetL3Button(bool value);
/**
* Change the value of the R3 (right stick) button on the controller.
*
* @param value the new value
*/
void SetR3Button(bool value);
/**
* Change the value of the PS button on the controller.
*
* @param value the new value
*/
void SetPSButton(bool value);
/**
* Change the value of the touchpad button on the controller.
*
* @param value the new value
*/
void SetTouchpad(bool value);
};
} // namespace sim
} // namespace frc

View File

@@ -1,148 +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.
#pragma once
#include "frc/simulation/GenericHIDSim.h"
namespace frc {
class XboxController;
namespace sim {
/**
* Class to control a simulated Xbox 360 or Xbox One controller.
*/
class XboxControllerSim : public GenericHIDSim {
public:
/**
* Constructs from a XboxController object.
*
* @param joystick controller to simulate
*/
explicit XboxControllerSim(const XboxController& joystick);
/**
* Constructs from a joystick port number.
*
* @param port port number
*/
explicit XboxControllerSim(int port);
/**
* Change the X axis value of the controller's left stick.
*
* @param value the new value
*/
void SetLeftX(double value);
/**
* Change the X axis value of the controller's right stick.
*
* @param value the new value
*/
void SetRightX(double value);
/**
* Change the Y axis value of the controller's left stick.
*
* @param value the new value
*/
void SetLeftY(double value);
/**
* Change the Y axis value of the controller's right stick.
*
* @param value the new value
*/
void SetRightY(double value);
/**
* Change the left trigger axis value of the joystick.
*
* @param value the new value
*/
void SetLeftTriggerAxis(double value);
/**
* Change the right trigger axis value of the joystick.
*
* @param value the new value
*/
void SetRightTriggerAxis(double value);
/**
* Change the left bumper value of the joystick.
*
* @param value the new value
*/
void SetLeftBumper(bool value);
/**
* Change the right bumper value of the joystick.
*
* @param value the new value
*/
void SetRightBumper(bool value);
/**
* Change the left button value of the joystick.
*
* @param value the new value
*/
void SetLeftStickButton(bool value);
/**
* Change the right button value of the joystick.
*
* @param value the new value
*/
void SetRightStickButton(bool value);
/**
* Change the value of the A button.
*
* @param value the new value
*/
void SetAButton(bool value);
/**
* Change the value of the B button.
*
* @param value the new value
*/
void SetBButton(bool value);
/**
* Change the value of the X button.
*
* @param value the new value
*/
void SetXButton(bool value);
/**
* Change the value of the Y button.
*
* @param value the new value
*/
void SetYButton(bool value);
/**
* Change the value of the Back button.
*
* @param value the new value
*/
void SetBackButton(bool value);
/**
* Change the value of the Start button.
*
* @param value the new value
*/
void SetStartButton(bool value);
};
} // namespace sim
} // namespace frc