[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

@@ -0,0 +1,277 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY
#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::GetLeftY() const {
return GetRawAxis(Axis::kLeftY);
}
double PS4Controller::GetRightX() const {
return GetRawAxis(Axis::kRightX);
}
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::GetTouchpadButton() const {
return GetRawButton(Button::kTouchpad);
}
bool PS4Controller::GetTouchpadButtonPressed() {
return GetRawButtonPressed(Button::kTouchpad);
}
bool PS4Controller::GetTouchpadButtonReleased() {
return GetRawButtonReleased(Button::kTouchpad);
}
BooleanEvent PS4Controller::Touchpad(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetTouchpadButton(); });
}
bool PS4Controller::GetTouchpad() const {
return GetRawButton(Button::kTouchpad);
}
bool PS4Controller::GetTouchpadPressed() {
return GetRawButtonPressed(Button::kTouchpad);
}
bool PS4Controller::GetTouchpadReleased() {
return GetRawButtonReleased(Button::kTouchpad);
}

View File

@@ -0,0 +1,277 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY
#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::GetLeftY() const {
return GetRawAxis(Axis::kLeftY);
}
double PS5Controller::GetRightX() const {
return GetRawAxis(Axis::kRightX);
}
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::GetTouchpadButton() const {
return GetRawButton(Button::kTouchpad);
}
bool PS5Controller::GetTouchpadButtonPressed() {
return GetRawButtonPressed(Button::kTouchpad);
}
bool PS5Controller::GetTouchpadButtonReleased() {
return GetRawButtonReleased(Button::kTouchpad);
}
BooleanEvent PS5Controller::Touchpad(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetTouchpadButton(); });
}
bool PS5Controller::GetTouchpad() const {
return GetRawButton(Button::kTouchpad);
}
bool PS5Controller::GetTouchpadPressed() {
return GetRawButtonPressed(Button::kTouchpad);
}
bool PS5Controller::GetTouchpadReleased() {
return GetRawButtonReleased(Button::kTouchpad);
}

View File

@@ -0,0 +1,297 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY
#include "frc/StadiaController.h"
#include <hal/FRCUsageReporting.h>
#include "frc/event/BooleanEvent.h"
using namespace frc;
StadiaController::StadiaController(int port) : GenericHID(port) {
// 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::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::GetLeftBumperButton() const {
return GetRawButton(Button::kLeftBumper);
}
bool StadiaController::GetLeftBumperButtonPressed() {
return GetRawButtonPressed(Button::kLeftBumper);
}
bool StadiaController::GetLeftBumperButtonReleased() {
return GetRawButtonReleased(Button::kLeftBumper);
}
BooleanEvent StadiaController::LeftBumper(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetLeftBumperButton(); });
}
bool StadiaController::GetRightBumperButton() const {
return GetRawButton(Button::kRightBumper);
}
bool StadiaController::GetRightBumperButtonPressed() {
return GetRawButtonPressed(Button::kRightBumper);
}
bool StadiaController::GetRightBumperButtonReleased() {
return GetRawButtonReleased(Button::kRightBumper);
}
BooleanEvent StadiaController::RightBumper(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetRightBumperButton(); });
}
bool StadiaController::GetLeftStickButton() const {
return GetRawButton(Button::kLeftStick);
}
bool StadiaController::GetLeftStickButtonPressed() {
return GetRawButtonPressed(Button::kLeftStick);
}
bool StadiaController::GetLeftStickButtonReleased() {
return GetRawButtonReleased(Button::kLeftStick);
}
BooleanEvent StadiaController::LeftStick(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetLeftStickButton(); });
}
bool StadiaController::GetRightStickButton() const {
return GetRawButton(Button::kRightStick);
}
bool StadiaController::GetRightStickButtonPressed() {
return GetRawButtonPressed(Button::kRightStick);
}
bool StadiaController::GetRightStickButtonReleased() {
return GetRawButtonReleased(Button::kRightStick);
}
BooleanEvent StadiaController::RightStick(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetRightStickButton(); });
}
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::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(); });
}
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::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::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);
}

View File

@@ -0,0 +1,241 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY
#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);
}
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);
}
double XboxController::GetRightTriggerAxis() const {
return GetRawAxis(Axis::kRightTrigger);
}
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);
}
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::GetLeftBumperButton() const {
return GetRawButton(Button::kLeftBumper);
}
bool XboxController::GetLeftBumperButtonPressed() {
return GetRawButtonPressed(Button::kLeftBumper);
}
bool XboxController::GetLeftBumperButtonReleased() {
return GetRawButtonReleased(Button::kLeftBumper);
}
BooleanEvent XboxController::LeftBumper(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetLeftBumperButton(); });
}
bool XboxController::GetRightBumperButton() const {
return GetRawButton(Button::kRightBumper);
}
bool XboxController::GetRightBumperButtonPressed() {
return GetRawButtonPressed(Button::kRightBumper);
}
bool XboxController::GetRightBumperButtonReleased() {
return GetRawButtonReleased(Button::kRightBumper);
}
BooleanEvent XboxController::RightBumper(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetRightBumperButton(); });
}
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(); });
}
bool XboxController::GetLeftStickButton() const {
return GetRawButton(Button::kLeftStick);
}
bool XboxController::GetLeftStickButtonPressed() {
return GetRawButtonPressed(Button::kLeftStick);
}
bool XboxController::GetLeftStickButtonReleased() {
return GetRawButtonReleased(Button::kLeftStick);
}
BooleanEvent XboxController::LeftStick(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetLeftStickButton(); });
}
bool XboxController::GetRightStickButton() const {
return GetRawButton(Button::kRightStick);
}
bool XboxController::GetRightStickButtonPressed() {
return GetRawButtonPressed(Button::kRightStick);
}
bool XboxController::GetRightStickButtonReleased() {
return GetRawButtonReleased(Button::kRightStick);
}
BooleanEvent XboxController::RightStick(EventLoop* loop) const {
return BooleanEvent(loop, [this]() { return this->GetRightStickButton(); });
}
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);
}

View File

@@ -0,0 +1,105 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY
#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::SetLeftY(double value) {
SetRawAxis(PS4Controller::Axis::kLeftY, value);
}
void PS4ControllerSim::SetRightX(double value) {
SetRawAxis(PS4Controller::Axis::kRightX, 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::SetTouchpadButton(bool value) {
SetRawButton(PS4Controller::Button::kTouchpad, value);
}

View File

@@ -0,0 +1,105 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY
#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::SetLeftY(double value) {
SetRawAxis(PS5Controller::Axis::kLeftY, value);
}
void PS5ControllerSim::SetRightX(double value) {
SetRawAxis(PS5Controller::Axis::kRightX, 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::SetTouchpadButton(bool value) {
SetRawButton(PS5Controller::Button::kTouchpad, value);
}

View File

@@ -0,0 +1,101 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY
#include "frc/simulation/StadiaControllerSim.h"
#include "frc/StadiaController.h"
using namespace frc;
using namespace frc::sim;
StadiaControllerSim::StadiaControllerSim(const StadiaController& joystick)
: GenericHIDSim{joystick} {
SetAxisCount(4);
SetButtonCount(15);
SetPOVCount(1);
}
StadiaControllerSim::StadiaControllerSim(int port) : GenericHIDSim{port} {
SetAxisCount(4);
SetButtonCount(15);
SetPOVCount(1);
}
void StadiaControllerSim::SetLeftX(double value) {
SetRawAxis(StadiaController::Axis::kLeftX, value);
}
void StadiaControllerSim::SetRightX(double value) {
SetRawAxis(StadiaController::Axis::kRightX, value);
}
void StadiaControllerSim::SetLeftY(double value) {
SetRawAxis(StadiaController::Axis::kLeftY, value);
}
void StadiaControllerSim::SetRightY(double value) {
SetRawAxis(StadiaController::Axis::kRightY, value);
}
void StadiaControllerSim::SetAButton(bool value) {
SetRawButton(StadiaController::Button::kA, value);
}
void StadiaControllerSim::SetBButton(bool value) {
SetRawButton(StadiaController::Button::kB, value);
}
void StadiaControllerSim::SetXButton(bool value) {
SetRawButton(StadiaController::Button::kX, value);
}
void StadiaControllerSim::SetYButton(bool value) {
SetRawButton(StadiaController::Button::kY, value);
}
void StadiaControllerSim::SetLeftBumperButton(bool value) {
SetRawButton(StadiaController::Button::kLeftBumper, value);
}
void StadiaControllerSim::SetRightBumperButton(bool value) {
SetRawButton(StadiaController::Button::kRightBumper, value);
}
void StadiaControllerSim::SetLeftStickButton(bool value) {
SetRawButton(StadiaController::Button::kLeftStick, value);
}
void StadiaControllerSim::SetRightStickButton(bool value) {
SetRawButton(StadiaController::Button::kRightStick, value);
}
void StadiaControllerSim::SetEllipsesButton(bool value) {
SetRawButton(StadiaController::Button::kEllipses, value);
}
void StadiaControllerSim::SetHamburgerButton(bool value) {
SetRawButton(StadiaController::Button::kHamburger, value);
}
void StadiaControllerSim::SetStadiaButton(bool value) {
SetRawButton(StadiaController::Button::kStadia, value);
}
void StadiaControllerSim::SetRightTriggerButton(bool value) {
SetRawButton(StadiaController::Button::kRightTrigger, value);
}
void StadiaControllerSim::SetLeftTriggerButton(bool value) {
SetRawButton(StadiaController::Button::kLeftTrigger, value);
}
void StadiaControllerSim::SetGoogleButton(bool value) {
SetRawButton(StadiaController::Button::kGoogle, value);
}
void StadiaControllerSim::SetFrameButton(bool value) {
SetRawButton(StadiaController::Button::kFrame, value);
}

View File

@@ -0,0 +1,89 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY
#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::SetAButton(bool value) {
SetRawButton(XboxController::Button::kA, value);
}
void XboxControllerSim::SetBButton(bool value) {
SetRawButton(XboxController::Button::kB, value);
}
void XboxControllerSim::SetXButton(bool value) {
SetRawButton(XboxController::Button::kX, value);
}
void XboxControllerSim::SetYButton(bool value) {
SetRawButton(XboxController::Button::kY, value);
}
void XboxControllerSim::SetLeftBumperButton(bool value) {
SetRawButton(XboxController::Button::kLeftBumper, value);
}
void XboxControllerSim::SetRightBumperButton(bool value) {
SetRawButton(XboxController::Button::kRightBumper, value);
}
void XboxControllerSim::SetBackButton(bool value) {
SetRawButton(XboxController::Button::kBack, value);
}
void XboxControllerSim::SetStartButton(bool value) {
SetRawButton(XboxController::Button::kStart, value);
}
void XboxControllerSim::SetLeftStickButton(bool value) {
SetRawButton(XboxController::Button::kLeftStick, value);
}
void XboxControllerSim::SetRightStickButton(bool value) {
SetRawButton(XboxController::Button::kRightStick, value);
}

View File

@@ -0,0 +1,592 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY
#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 a 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 Y axis value of left side of the controller.
*
* @return the axis value.
*/
double GetLeftY() 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 right side of the controller.
*
* @return the axis value.
*/
double GetRightY() const;
/**
* Get the left trigger 2 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 right trigger 2 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 left trigger 1 button on the controller.
*
* @return The state of the button.
*/
bool GetL1Button() const;
/**
* Whether the left trigger 1 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetL1ButtonPressed();
/**
* Whether the left trigger 1 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 left trigger 1 button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left trigger 1 button's
* digital signal attached to the given loop.
*/
BooleanEvent L1(EventLoop* loop) const;
/**
* Read the value of the right trigger 1 button on the controller.
*
* @return The state of the button.
*/
bool GetR1Button() const;
/**
* Whether the right trigger 1 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetR1ButtonPressed();
/**
* Whether the right trigger 1 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 right trigger 1 button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right trigger 1 button's
* digital signal attached to the given loop.
*/
BooleanEvent R1(EventLoop* loop) const;
/**
* Read the value of the left trigger 2 button on the controller.
*
* @return The state of the button.
*/
bool GetL2Button() const;
/**
* Whether the left trigger 2 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetL2ButtonPressed();
/**
* Whether the left trigger 2 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 left trigger 2 button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left trigger 2 button's
* digital signal attached to the given loop.
*/
BooleanEvent L2(EventLoop* loop) const;
/**
* Read the value of the right trigger 2 button on the controller.
*
* @return The state of the button.
*/
bool GetR2Button() const;
/**
* Whether the right trigger 2 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetR2ButtonPressed();
/**
* Whether the right trigger 2 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 right trigger 2 button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right trigger 2 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 (left stick) button 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 (left stick) button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the L3 (left stick) button's
* digital signal attached to the given loop.
*/
BooleanEvent L3(EventLoop* loop) const;
/**
* Read the value of the R3 (right stick) button 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 (right stick) button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the R3 (right stick) button's
* digital signal attached to the given loop.
*/
BooleanEvent R3(EventLoop* loop) const;
/**
* Read the value of the PlayStation button on the controller.
*
* @return The state of the button.
*/
bool GetPSButton() const;
/**
* Whether the PlayStation button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetPSButtonPressed();
/**
* Whether the PlayStation 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 PlayStation button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the PlayStation 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 GetTouchpadButton() const;
/**
* Whether the touchpad button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetTouchpadButtonPressed();
/**
* Whether the touchpad button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetTouchpadButtonReleased();
/**
* Constructs an event instance around the touchpad button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the touchpad button's
* digital signal attached to the given loop.
*/
BooleanEvent Touchpad(EventLoop* loop) const;
/**
* Read the value of the touchpad button on the controller.
*
* @return The state of the button.
*/
[[deprecated("Use GetTouchpadButton instead")]]
bool GetTouchpad() const;
/**
* Whether the touchpad was pressed since the last check.
*
* @return Whether the touchpad was pressed since the last check.
*/
[[deprecated("Use GetTouchpadButtonPressed instead")]]
bool GetTouchpadPressed();
/**
* Whether the touchpad was released since the last check.
*
* @return Whether the touchpad was released since the last check.
*/
[[deprecated("Use GetTouchpadButtonReleased instead")]]
bool GetTouchpadReleased();
/** Represents a digital button on an PS4Controller. */
struct Button {
/// Square button.
static constexpr int kSquare = 1;
/// Cross 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;
/// Options button.
static constexpr int kOptions = 10;
/// L3 (left stick) button.
static constexpr int kL3 = 11;
/// R3 (right stick) button.
static constexpr int kR3 = 12;
/// PlayStation button.
static constexpr int kPS = 13;
/// Touchpad button.
static constexpr int kTouchpad = 14;
};
/** Represents an axis on an 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

@@ -0,0 +1,592 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY
#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 a 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 Y axis value of left side of the controller.
*
* @return the axis value.
*/
double GetLeftY() 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 right side of the controller.
*
* @return the axis value.
*/
double GetRightY() const;
/**
* Get the left trigger 2 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 right trigger 2 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 left trigger 1 button on the controller.
*
* @return The state of the button.
*/
bool GetL1Button() const;
/**
* Whether the left trigger 1 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetL1ButtonPressed();
/**
* Whether the left trigger 1 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 left trigger 1 button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left trigger 1 button's
* digital signal attached to the given loop.
*/
BooleanEvent L1(EventLoop* loop) const;
/**
* Read the value of the right trigger 1 button on the controller.
*
* @return The state of the button.
*/
bool GetR1Button() const;
/**
* Whether the right trigger 1 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetR1ButtonPressed();
/**
* Whether the right trigger 1 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 right trigger 1 button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right trigger 1 button's
* digital signal attached to the given loop.
*/
BooleanEvent R1(EventLoop* loop) const;
/**
* Read the value of the left trigger 2 button on the controller.
*
* @return The state of the button.
*/
bool GetL2Button() const;
/**
* Whether the left trigger 2 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetL2ButtonPressed();
/**
* Whether the left trigger 2 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 left trigger 2 button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left trigger 2 button's
* digital signal attached to the given loop.
*/
BooleanEvent L2(EventLoop* loop) const;
/**
* Read the value of the right trigger 2 button on the controller.
*
* @return The state of the button.
*/
bool GetR2Button() const;
/**
* Whether the right trigger 2 button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetR2ButtonPressed();
/**
* Whether the right trigger 2 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 right trigger 2 button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right trigger 2 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 (left stick) button 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 (left stick) button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the L3 (left stick) button's
* digital signal attached to the given loop.
*/
BooleanEvent L3(EventLoop* loop) const;
/**
* Read the value of the R3 (right stick) button 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 (right stick) button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the R3 (right stick) button's
* digital signal attached to the given loop.
*/
BooleanEvent R3(EventLoop* loop) const;
/**
* Read the value of the PlayStation button on the controller.
*
* @return The state of the button.
*/
bool GetPSButton() const;
/**
* Whether the PlayStation button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetPSButtonPressed();
/**
* Whether the PlayStation 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 PlayStation button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the PlayStation 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 GetTouchpadButton() const;
/**
* Whether the touchpad button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetTouchpadButtonPressed();
/**
* Whether the touchpad button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetTouchpadButtonReleased();
/**
* Constructs an event instance around the touchpad button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the touchpad button's
* digital signal attached to the given loop.
*/
BooleanEvent Touchpad(EventLoop* loop) const;
/**
* Read the value of the touchpad button on the controller.
*
* @return The state of the button.
*/
[[deprecated("Use GetTouchpadButton instead")]]
bool GetTouchpad() const;
/**
* Whether the touchpad was pressed since the last check.
*
* @return Whether the touchpad was pressed since the last check.
*/
[[deprecated("Use GetTouchpadButtonPressed instead")]]
bool GetTouchpadPressed();
/**
* Whether the touchpad was released since the last check.
*
* @return Whether the touchpad was released since the last check.
*/
[[deprecated("Use GetTouchpadButtonReleased instead")]]
bool GetTouchpadReleased();
/** Represents a digital button on an PS5Controller. */
struct Button {
/// Square button.
static constexpr int kSquare = 1;
/// Cross 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;
/// L3 (left stick) button.
static constexpr int kL3 = 11;
/// R3 (right stick) button.
static constexpr int kR3 = 12;
/// PlayStation button.
static constexpr int kPS = 13;
/// Touchpad button.
static constexpr int kTouchpad = 14;
};
/** Represents an axis on an 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

@@ -0,0 +1,630 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY
#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.
*
* Only first party controllers from Google 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 StadiaController : public GenericHID {
public:
/**
* Construct an instance of a 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 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 left bumper button on the controller.
*
* @return The state of the button.
*/
bool GetLeftBumperButton() const;
/**
* Whether the left bumper button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetLeftBumperButtonPressed();
/**
* Whether the left bumper button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetLeftBumperButtonReleased();
/**
* Constructs an event instance around the left bumper button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left bumper button's
* digital signal attached to the given loop.
*/
BooleanEvent LeftBumper(EventLoop* loop) const;
/**
* Read the value of the right bumper button on the controller.
*
* @return The state of the button.
*/
bool GetRightBumperButton() const;
/**
* Whether the right bumper button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetRightBumperButtonPressed();
/**
* Whether the right bumper button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetRightBumperButtonReleased();
/**
* Constructs an event instance around the right bumper button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right bumper button's
* digital signal attached to the given loop.
*/
BooleanEvent RightBumper(EventLoop* loop) const;
/**
* Read the value of the left stick button on the controller.
*
* @return The state of the button.
*/
bool GetLeftStickButton() const;
/**
* Whether the left stick button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetLeftStickButtonPressed();
/**
* Whether the left stick button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetLeftStickButtonReleased();
/**
* Constructs an event instance around the left stick button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left stick button's
* digital signal attached to the given loop.
*/
BooleanEvent LeftStick(EventLoop* loop) const;
/**
* Read the value of the right stick button on the controller.
*
* @return The state of the button.
*/
bool GetRightStickButton() const;
/**
* Whether the right stick button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetRightStickButtonPressed();
/**
* Whether the right stick button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetRightStickButtonReleased();
/**
* Constructs an event instance around the right stick button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right stick button's
* digital signal attached to the given loop.
*/
BooleanEvent RightStick(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 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;
/**
* 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 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 bumper (LB) button on the controller.
*
* @return the state of the button
*/
[[deprecated("Use GetLeftBumperButton instead")]]
bool GetLeftBumper() const;
/**
* Read the value of the right bumper (RB) button on the controller.
*
* @return the state of the button
*/
[[deprecated("Use GetRightBumperButton instead")]]
bool GetRightBumper() const;
/**
* Whether the left bumper (LB) was pressed since the last check.
*
* @return Whether the button was pressed since the last check
*/
[[deprecated("Use GetLeftBumperButtonPressed instead")]]
bool GetLeftBumperPressed();
/**
* Whether the right bumper (RB) was pressed since the last check.
*
* @return Whether the button was pressed since the last check
*/
[[deprecated("Use GetRightBumperButtonPressed instead")]]
bool GetRightBumperPressed();
/**
* Whether the left bumper (LB) was released since the last check.
*
* @return Whether the button was released since the last check.
*/
[[deprecated("Use GetLeftBumperButtonReleased instead")]]
bool GetLeftBumperReleased();
/**
* Whether the right bumper (RB) was released since the last check.
*
* @return Whether the button was released since the last check.
*/
[[deprecated("Use GetRightBumperButtonReleased instead")]]
bool GetRightBumperReleased();
/** Represents a digital button on an 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 an StadiaController. */
struct Axis {
/// Left X axis.
static constexpr int kLeftX = 0;
/// Right X axis.
static constexpr int kRightX = 3;
/// Left Y axis.
static constexpr int kLeftY = 1;
/// Right Y axis.
static constexpr int kRightY = 4;
};
};
} // namespace frc

View File

@@ -0,0 +1,529 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY
#pragma once
#include "frc/GenericHID.h"
namespace frc {
/**
* Handle input from Xbox 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 a 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 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;
/**
* 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;
/**
* Get the right trigger 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;
/**
* 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;
/**
* 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 left bumper button on the controller.
*
* @return The state of the button.
*/
bool GetLeftBumperButton() const;
/**
* Whether the left bumper button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetLeftBumperButtonPressed();
/**
* Whether the left bumper button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetLeftBumperButtonReleased();
/**
* Constructs an event instance around the left bumper button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left bumper button's
* digital signal attached to the given loop.
*/
BooleanEvent LeftBumper(EventLoop* loop) const;
/**
* Read the value of the right bumper button on the controller.
*
* @return The state of the button.
*/
bool GetRightBumperButton() const;
/**
* Whether the right bumper button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetRightBumperButtonPressed();
/**
* Whether the right bumper button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetRightBumperButtonReleased();
/**
* Constructs an event instance around the right bumper button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right bumper button's
* digital signal attached to the given loop.
*/
BooleanEvent RightBumper(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;
/**
* Read the value of the left stick button on the controller.
*
* @return The state of the button.
*/
bool GetLeftStickButton() const;
/**
* Whether the left stick button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetLeftStickButtonPressed();
/**
* Whether the left stick button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetLeftStickButtonReleased();
/**
* Constructs an event instance around the left stick button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the left stick button's
* digital signal attached to the given loop.
*/
BooleanEvent LeftStick(EventLoop* loop) const;
/**
* Read the value of the right stick button on the controller.
*
* @return The state of the button.
*/
bool GetRightStickButton() const;
/**
* Whether the right stick button was pressed since the last check.
*
* @return Whether the button was pressed since the last check.
*/
bool GetRightStickButtonPressed();
/**
* Whether the right stick button was released since the last check.
*
* @return Whether the button was released since the last check.
*/
bool GetRightStickButtonReleased();
/**
* Constructs an event instance around the right stick button's
* digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the right stick button's
* digital signal attached to the given loop.
*/
BooleanEvent RightStick(EventLoop* loop) const;
/**
* Read the value of the left bumper (LB) button on the controller.
*
* @return the state of the button
*/
[[deprecated("Use GetLeftBumperButton instead")]]
bool GetLeftBumper() const;
/**
* Read the value of the right bumper (RB) button on the controller.
*
* @return the state of the button
*/
[[deprecated("Use GetRightBumperButton instead")]]
bool GetRightBumper() const;
/**
* Whether the left bumper (LB) was pressed since the last check.
*
* @return Whether the button was pressed since the last check
*/
[[deprecated("Use GetLeftBumperButtonPressed instead")]]
bool GetLeftBumperPressed();
/**
* Whether the right bumper (RB) was pressed since the last check.
*
* @return Whether the button was pressed since the last check
*/
[[deprecated("Use GetRightBumperButtonPressed instead")]]
bool GetRightBumperPressed();
/**
* Whether the left bumper (LB) was released since the last check.
*
* @return Whether the button was released since the last check.
*/
[[deprecated("Use GetLeftBumperButtonReleased instead")]]
bool GetLeftBumperReleased();
/**
* Whether the right bumper (RB) was released since the last check.
*
* @return Whether the button was released since the last check.
*/
[[deprecated("Use GetRightBumperButtonReleased instead")]]
bool GetRightBumperReleased();
/** Represents a digital button on an XboxController. */
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;
/// Back button.
static constexpr int kBack = 7;
/// Start button.
static constexpr int kStart = 8;
/// Left stick button.
static constexpr int kLeftStick = 9;
/// Right stick button.
static constexpr int kRightStick = 10;
};
/** Represents an axis on an XboxController. */
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;
/// Left trigger.
static constexpr int kLeftTrigger = 2;
/// Right trigger.
static constexpr int kRightTrigger = 3;
};
};
} // namespace frc

View File

@@ -0,0 +1,187 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY
#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 left X value of the controller's joystick.
*
* @param value the new value
*/
void SetLeftX(double value);
/**
* Change the left Y value of the controller's joystick.
*
* @param value the new value
*/
void SetLeftY(double value);
/**
* Change the right X value of the controller's joystick.
*
* @param value the new value
*/
void SetRightX(double value);
/**
* Change the right Y value of the controller's joystick.
*
* @param value the new value
*/
void SetRightY(double value);
/**
* Change the value of the left trigger 2 axis on the controller.
*
* @param value the new value
*/
void SetL2Axis(double value);
/**
* Change the value of the right trigger 2 axis on 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 left trigger 1 button on the controller.
*
* @param value the new value
*/
void SetL1Button(bool value);
/**
* Change the value of the right trigger 1 button on the controller.
*
* @param value the new value
*/
void SetR1Button(bool value);
/**
* Change the value of the left trigger 2 button on the controller.
*
* @param value the new value
*/
void SetL2Button(bool value);
/**
* Change the value of the right trigger 2 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 PlayStation 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 SetTouchpadButton(bool value);
/**
* Change the value of the touchpad button on the controller.
*
* @param value the new value
*/
[[deprecated("Use SetTouchpadButton instead")]]
void SetTouchpad(bool value);
};
} // namespace sim
} // namespace frc

View File

@@ -0,0 +1,187 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY
#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 left X value of the controller's joystick.
*
* @param value the new value
*/
void SetLeftX(double value);
/**
* Change the left Y value of the controller's joystick.
*
* @param value the new value
*/
void SetLeftY(double value);
/**
* Change the right X value of the controller's joystick.
*
* @param value the new value
*/
void SetRightX(double value);
/**
* Change the right Y value of the controller's joystick.
*
* @param value the new value
*/
void SetRightY(double value);
/**
* Change the value of the left trigger 2 axis on the controller.
*
* @param value the new value
*/
void SetL2Axis(double value);
/**
* Change the value of the right trigger 2 axis on 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 left trigger 1 button on the controller.
*
* @param value the new value
*/
void SetL1Button(bool value);
/**
* Change the value of the right trigger 1 button on the controller.
*
* @param value the new value
*/
void SetR1Button(bool value);
/**
* Change the value of the left trigger 2 button on the controller.
*
* @param value the new value
*/
void SetL2Button(bool value);
/**
* Change the value of the right trigger 2 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 PlayStation 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 SetTouchpadButton(bool value);
/**
* Change the value of the touchpad button on the controller.
*
* @param value the new value
*/
[[deprecated("Use SetTouchpadButton instead")]]
void SetTouchpad(bool value);
};
} // namespace sim
} // namespace frc

View File

@@ -0,0 +1,172 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY
#pragma once
#include "frc/simulation/GenericHIDSim.h"
namespace frc {
class StadiaController;
namespace sim {
/**
* Class to control a simulated Stadia controller.
*/
class StadiaControllerSim : public GenericHIDSim {
public:
/**
* Constructs from a StadiaController object.
*
* @param joystick controller to simulate
*/
explicit StadiaControllerSim(const StadiaController& joystick);
/**
* Constructs from a joystick port number.
*
* @param port port number
*/
explicit StadiaControllerSim(int port);
/**
* Change the left X value of the controller's joystick.
*
* @param value the new value
*/
void SetLeftX(double value);
/**
* Change the right X value of the controller's joystick.
*
* @param value the new value
*/
void SetRightX(double value);
/**
* Change the left Y value of the controller's joystick.
*
* @param value the new value
*/
void SetLeftY(double value);
/**
* Change the right Y value of the controller's joystick.
*
* @param value the new value
*/
void SetRightY(double value);
/**
* Change the value of the A button on the controller.
*
* @param value the new value
*/
void SetAButton(bool value);
/**
* Change the value of the B button on the controller.
*
* @param value the new value
*/
void SetBButton(bool value);
/**
* Change the value of the X button on the controller.
*
* @param value the new value
*/
void SetXButton(bool value);
/**
* Change the value of the Y button on the controller.
*
* @param value the new value
*/
void SetYButton(bool value);
/**
* Change the value of the left bumper button on the controller.
*
* @param value the new value
*/
void SetLeftBumperButton(bool value);
/**
* Change the value of the right bumper button on the controller.
*
* @param value the new value
*/
void SetRightBumperButton(bool value);
/**
* Change the value of the left stick button on the controller.
*
* @param value the new value
*/
void SetLeftStickButton(bool value);
/**
* Change the value of the right stick button on the controller.
*
* @param value the new value
*/
void SetRightStickButton(bool value);
/**
* Change the value of the ellipses button on the controller.
*
* @param value the new value
*/
void SetEllipsesButton(bool value);
/**
* Change the value of the hamburger button on the controller.
*
* @param value the new value
*/
void SetHamburgerButton(bool value);
/**
* Change the value of the stadia button on the controller.
*
* @param value the new value
*/
void SetStadiaButton(bool value);
/**
* Change the value of the right trigger button on the controller.
*
* @param value the new value
*/
void SetRightTriggerButton(bool value);
/**
* Change the value of the left trigger button on the controller.
*
* @param value the new value
*/
void SetLeftTriggerButton(bool value);
/**
* Change the value of the google button on the controller.
*
* @param value the new value
*/
void SetGoogleButton(bool value);
/**
* Change the value of the frame button on the controller.
*
* @param value the new value
*/
void SetFrameButton(bool value);
};
} // namespace sim
} // namespace frc

View File

@@ -0,0 +1,167 @@
// 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.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY
#pragma once
#include "frc/simulation/GenericHIDSim.h"
namespace frc {
class XboxController;
namespace sim {
/**
* Class to control a simulated Xbox 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 left X value of the controller's joystick.
*
* @param value the new value
*/
void SetLeftX(double value);
/**
* Change the right X value of the controller's joystick.
*
* @param value the new value
*/
void SetRightX(double value);
/**
* Change the left Y value of the controller's joystick.
*
* @param value the new value
*/
void SetLeftY(double value);
/**
* Change the right Y value of the controller's joystick.
*
* @param value the new value
*/
void SetRightY(double value);
/**
* Change the value of the left trigger axis on the controller.
*
* @param value the new value
*/
void SetLeftTriggerAxis(double value);
/**
* Change the value of the right trigger axis on the controller.
*
* @param value the new value
*/
void SetRightTriggerAxis(double value);
/**
* Change the value of the A button on the controller.
*
* @param value the new value
*/
void SetAButton(bool value);
/**
* Change the value of the B button on the controller.
*
* @param value the new value
*/
void SetBButton(bool value);
/**
* Change the value of the X button on the controller.
*
* @param value the new value
*/
void SetXButton(bool value);
/**
* Change the value of the Y button on the controller.
*
* @param value the new value
*/
void SetYButton(bool value);
/**
* Change the value of the left bumper button on the controller.
*
* @param value the new value
*/
void SetLeftBumperButton(bool value);
/**
* Change the value of the right bumper button on the controller.
*
* @param value the new value
*/
void SetRightBumperButton(bool value);
/**
* Change the value of the back button on the controller.
*
* @param value the new value
*/
void SetBackButton(bool value);
/**
* Change the value of the start button on the controller.
*
* @param value the new value
*/
void SetStartButton(bool value);
/**
* Change the value of the left stick button on the controller.
*
* @param value the new value
*/
void SetLeftStickButton(bool value);
/**
* Change the value of the right stick button on the controller.
*
* @param value the new value
*/
void SetRightStickButton(bool value);
/**
* Change the left bumper value of the joystick.
*
* @param value the new value
*/
[[deprecated("Use SetLeftBumperButton instead")]]
void SetLeftBumper(bool value);
/**
* Change the right bumper value of the joystick.
*
* @param value the new value
*/
[[deprecated("Use SetRightBumperButton instead")]]
void SetRightBumper(bool value);
};
} // namespace sim
} // namespace frc