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

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,176 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include "frc/simulation/GenericHIDSim.h"
namespace frc {
class PS4Controller;
namespace sim {
/**
* Class to control a simulated PS4 controller.
*/
class PS4ControllerSim : public GenericHIDSim {
public:
/**
* Constructs from a PS4Controller object.
*
* @param joystick controller to simulate
*/
explicit PS4ControllerSim(const PS4Controller& joystick);
/**
* Constructs from a joystick port number.
*
* @param port port number
*/
explicit PS4ControllerSim(int port);
/**
* Change the X axis value of the controller's left stick.
*
* @param value the new value
*/
void SetLeftX(double value);
/**
* Change the X axis value of the controller's right stick.
*
* @param value the new value
*/
void SetRightX(double value);
/**
* Change the Y axis value of the controller's left stick.
*
* @param value the new value
*/
void SetLeftY(double value);
/**
* Change the Y axis value of the controller's right stick.
*
* @param value the new value
*/
void SetRightY(double value);
/**
* Change the L2 axis axis value of the controller.
*
* @param value the new value
*/
void SetL2Axis(double value);
/**
* Change the R2 axis value of the controller.
*
* @param value the new value
*/
void SetR2Axis(double value);
/**
* Change the value of the Square button on the controller.
*
* @param value the new value
*/
void SetSquareButton(bool value);
/**
* Change the value of the Cross button on the controller.
*
* @param value the new value
*/
void SetCrossButton(bool value);
/**
* Change the value of the Circle button on the controller.
*
* @param value the new value
*/
void SetCircleButton(bool value);
/**
* Change the value of the Triangle button on the controller.
*
* @param value the new value
*/
void SetTriangleButton(bool value);
/**
* Change the value of the L1 button on the controller.
*
* @param value the new value
*/
void SetL1Button(bool value);
/**
* Change the value of the R1 button on the controller.
*
* @param value the new value
*/
void SetR1Button(bool value);
/**
* Change the value of the L2 button on the controller.
*
* @param value the new value
*/
void SetL2Button(bool value);
/**
* Change the value of the R2 button on the controller.
*
* @param value the new value
*/
void SetR2Button(bool value);
/**
* Change the value of the Share button on the controller.
*
* @param value the new value
*/
void SetShareButton(bool value);
/**
* Change the value of the Options button on the controller.
*
* @param value the new value
*/
void SetOptionsButton(bool value);
/**
* Change the value of the L3 (left stick) button on the controller.
*
* @param value the new value
*/
void SetL3Button(bool value);
/**
* Change the value of the R3 (right stick) button on the controller.
*
* @param value the new value
*/
void SetR3Button(bool value);
/**
* Change the value of the PS button on the controller.
*
* @param value the new value
*/
void SetPSButton(bool value);
/**
* Change the value of the touchpad button on the controller.
*
* @param value the new value
*/
void SetTouchpad(bool value);
};
} // namespace sim
} // namespace frc

View File

@@ -1,176 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include "frc/simulation/GenericHIDSim.h"
namespace frc {
class PS5Controller;
namespace sim {
/**
* Class to control a simulated PS5 controller.
*/
class PS5ControllerSim : public GenericHIDSim {
public:
/**
* Constructs from a PS5Controller object.
*
* @param joystick controller to simulate
*/
explicit PS5ControllerSim(const PS5Controller& joystick);
/**
* Constructs from a joystick port number.
*
* @param port port number
*/
explicit PS5ControllerSim(int port);
/**
* Change the X axis value of the controller's left stick.
*
* @param value the new value
*/
void SetLeftX(double value);
/**
* Change the X axis value of the controller's right stick.
*
* @param value the new value
*/
void SetRightX(double value);
/**
* Change the Y axis value of the controller's left stick.
*
* @param value the new value
*/
void SetLeftY(double value);
/**
* Change the Y axis value of the controller's right stick.
*
* @param value the new value
*/
void SetRightY(double value);
/**
* Change the L2 axis axis value of the controller.
*
* @param value the new value
*/
void SetL2Axis(double value);
/**
* Change the R2 axis value of the controller.
*
* @param value the new value
*/
void SetR2Axis(double value);
/**
* Change the value of the Square button on the controller.
*
* @param value the new value
*/
void SetSquareButton(bool value);
/**
* Change the value of the Cross button on the controller.
*
* @param value the new value
*/
void SetCrossButton(bool value);
/**
* Change the value of the Circle button on the controller.
*
* @param value the new value
*/
void SetCircleButton(bool value);
/**
* Change the value of the Triangle button on the controller.
*
* @param value the new value
*/
void SetTriangleButton(bool value);
/**
* Change the value of the L1 button on the controller.
*
* @param value the new value
*/
void SetL1Button(bool value);
/**
* Change the value of the R1 button on the controller.
*
* @param value the new value
*/
void SetR1Button(bool value);
/**
* Change the value of the L2 button on the controller.
*
* @param value the new value
*/
void SetL2Button(bool value);
/**
* Change the value of the R2 button on the controller.
*
* @param value the new value
*/
void SetR2Button(bool value);
/**
* Change the value of the Create button on the controller.
*
* @param value the new value
*/
void SetCreateButton(bool value);
/**
* Change the value of the Options button on the controller.
*
* @param value the new value
*/
void SetOptionsButton(bool value);
/**
* Change the value of the L3 (left stick) button on the controller.
*
* @param value the new value
*/
void SetL3Button(bool value);
/**
* Change the value of the R3 (right stick) button on the controller.
*
* @param value the new value
*/
void SetR3Button(bool value);
/**
* Change the value of the PS button on the controller.
*
* @param value the new value
*/
void SetPSButton(bool value);
/**
* Change the value of the touchpad button on the controller.
*
* @param value the new value
*/
void SetTouchpad(bool value);
};
} // namespace sim
} // namespace frc

View File

@@ -1,148 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include "frc/simulation/GenericHIDSim.h"
namespace frc {
class XboxController;
namespace sim {
/**
* Class to control a simulated Xbox 360 or Xbox One controller.
*/
class XboxControllerSim : public GenericHIDSim {
public:
/**
* Constructs from a XboxController object.
*
* @param joystick controller to simulate
*/
explicit XboxControllerSim(const XboxController& joystick);
/**
* Constructs from a joystick port number.
*
* @param port port number
*/
explicit XboxControllerSim(int port);
/**
* Change the X axis value of the controller's left stick.
*
* @param value the new value
*/
void SetLeftX(double value);
/**
* Change the X axis value of the controller's right stick.
*
* @param value the new value
*/
void SetRightX(double value);
/**
* Change the Y axis value of the controller's left stick.
*
* @param value the new value
*/
void SetLeftY(double value);
/**
* Change the Y axis value of the controller's right stick.
*
* @param value the new value
*/
void SetRightY(double value);
/**
* Change the left trigger axis value of the joystick.
*
* @param value the new value
*/
void SetLeftTriggerAxis(double value);
/**
* Change the right trigger axis value of the joystick.
*
* @param value the new value
*/
void SetRightTriggerAxis(double value);
/**
* Change the left bumper value of the joystick.
*
* @param value the new value
*/
void SetLeftBumper(bool value);
/**
* Change the right bumper value of the joystick.
*
* @param value the new value
*/
void SetRightBumper(bool value);
/**
* Change the left button value of the joystick.
*
* @param value the new value
*/
void SetLeftStickButton(bool value);
/**
* Change the right button value of the joystick.
*
* @param value the new value
*/
void SetRightStickButton(bool value);
/**
* Change the value of the A button.
*
* @param value the new value
*/
void SetAButton(bool value);
/**
* Change the value of the B button.
*
* @param value the new value
*/
void SetBButton(bool value);
/**
* Change the value of the X button.
*
* @param value the new value
*/
void SetXButton(bool value);
/**
* Change the value of the Y button.
*
* @param value the new value
*/
void SetYButton(bool value);
/**
* Change the value of the Back button.
*
* @param value the new value
*/
void SetBackButton(bool value);
/**
* Change the value of the Start button.
*
* @param value the new value
*/
void SetStartButton(bool value);
};
} // namespace sim
} // namespace frc