mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
[wpilib] Add PS4Controller, remove Hand from GenericHID/XboxController (#3345)
- GenericHID is now concrete, and has only getRawAxis/Button(int) functionality - getXxx() has been moved into Joystick as that's the only place where it makes sense - Hand (and therefore getXxx(Hand)) has been removed, replaced by specific getLeft/RightXxx() methods in XboxController and the new PS4Controller class - C++ ::Button:: and ::Axis:: enums have been converted to identically-namespaced static constexpr ints
This commit is contained in:
@@ -13,7 +13,12 @@ namespace frc {
|
||||
class DriverStation;
|
||||
|
||||
/**
|
||||
* GenericHID Interface.
|
||||
* Handle input from standard HID devices connected to the Driver Station.
|
||||
*
|
||||
* <p>This class handles standard 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 device and the mapping of ports to hardware
|
||||
* buttons depends on the code in the Driver Station.
|
||||
*/
|
||||
class GenericHID {
|
||||
public:
|
||||
@@ -39,17 +44,12 @@ class GenericHID {
|
||||
kHID1stPerson = 24
|
||||
};
|
||||
|
||||
enum JoystickHand { kLeftHand = 0, kRightHand = 1 };
|
||||
|
||||
explicit GenericHID(int port);
|
||||
virtual ~GenericHID() = default;
|
||||
|
||||
GenericHID(GenericHID&&) = default;
|
||||
GenericHID& operator=(GenericHID&&) = default;
|
||||
|
||||
virtual double GetX(JoystickHand hand = kRightHand) const = 0;
|
||||
virtual double GetY(JoystickHand hand = kRightHand) const = 0;
|
||||
|
||||
/**
|
||||
* Get the button value (starting at button 1).
|
||||
*
|
||||
|
||||
@@ -119,24 +119,18 @@ class Joystick : public GenericHID {
|
||||
int GetThrottleChannel() const;
|
||||
|
||||
/**
|
||||
* Get the X value of the joystick.
|
||||
* Get the X value of the current joystick.
|
||||
*
|
||||
* This depends on the mapping of the joystick connected to the current port.
|
||||
*
|
||||
* @param hand This parameter is ignored for the Joystick class and is only
|
||||
* here to complete the GenericHID interface.
|
||||
*/
|
||||
double GetX(JoystickHand hand = kRightHand) const override;
|
||||
double GetX() const;
|
||||
|
||||
/**
|
||||
* Get the Y value of the joystick.
|
||||
* Get the Y value of the current joystick.
|
||||
*
|
||||
* This depends on the mapping of the joystick connected to the current port.
|
||||
*
|
||||
* @param hand This parameter is ignored for the Joystick class and is only
|
||||
* here to complete the GenericHID interface.
|
||||
*/
|
||||
double GetY(JoystickHand hand = kRightHand) const override;
|
||||
double GetY() const;
|
||||
|
||||
/**
|
||||
* Get the Z value of the current joystick.
|
||||
|
||||
403
wpilibc/src/main/native/include/frc/PS4Controller.h
Normal file
403
wpilibc/src/main/native/include/frc/PS4Controller.h
Normal file
@@ -0,0 +1,403 @@
|
||||
// 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.
|
||||
*
|
||||
* <p>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.
|
||||
*/
|
||||
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();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
struct Button {
|
||||
static constexpr int kSquare = 1;
|
||||
static constexpr int kCross = 2;
|
||||
static constexpr int kCircle = 3;
|
||||
static constexpr int kTriangle = 4;
|
||||
static constexpr int kL1 = 5;
|
||||
static constexpr int kR1 = 6;
|
||||
static constexpr int kL2 = 7;
|
||||
static constexpr int kR2 = 8;
|
||||
static constexpr int kShare = 9;
|
||||
static constexpr int kOptions = 10;
|
||||
static constexpr int kL3 = 11;
|
||||
static constexpr int kR3 = 12;
|
||||
static constexpr int kPS = 13;
|
||||
static constexpr int kTouchpad = 14;
|
||||
};
|
||||
|
||||
struct Axis {
|
||||
static constexpr int kLeftX = 0;
|
||||
static constexpr int kLeftY = 1;
|
||||
static constexpr int kRightX = 2;
|
||||
static constexpr int kRightY = 5;
|
||||
static constexpr int kL2 = 3;
|
||||
static constexpr int kR2 = 4;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
@@ -35,72 +35,96 @@ class XboxController : public GenericHID {
|
||||
XboxController& operator=(XboxController&&) = default;
|
||||
|
||||
/**
|
||||
* Get the X axis value of the controller.
|
||||
*
|
||||
* @param hand Side of controller whose value should be returned.
|
||||
* Get the X axis value of left side of the controller.
|
||||
*/
|
||||
double GetX(JoystickHand hand) const override;
|
||||
double GetLeftX() const;
|
||||
|
||||
/**
|
||||
* Get the Y axis value of the controller.
|
||||
*
|
||||
* @param hand Side of controller whose value should be returned.
|
||||
* Get the X axis value of right side of the controller.
|
||||
*/
|
||||
double GetY(JoystickHand hand) const override;
|
||||
double GetRightX() const;
|
||||
|
||||
/**
|
||||
* Get the trigger axis value of the controller.
|
||||
*
|
||||
* @param hand Side of controller whose value should be returned.
|
||||
* Get the Y axis value of left side of the controller.
|
||||
*/
|
||||
double GetTriggerAxis(JoystickHand hand) const;
|
||||
double GetLeftY() const;
|
||||
|
||||
/**
|
||||
* Read the value of the bumper button on the controller.
|
||||
*
|
||||
* @param hand Side of controller whose value should be returned.
|
||||
* Get the Y axis value of right side of the controller.
|
||||
*/
|
||||
bool GetBumper(JoystickHand hand) const;
|
||||
double GetRightY() const;
|
||||
|
||||
/**
|
||||
* Whether the bumper was pressed since the last check.
|
||||
*
|
||||
* @param hand Side of controller whose value should be returned.
|
||||
* @return Whether the button was pressed since the last check.
|
||||
* 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].
|
||||
*/
|
||||
bool GetBumperPressed(JoystickHand hand);
|
||||
double GetLeftTriggerAxis() const;
|
||||
|
||||
/**
|
||||
* Whether the bumper was released since the last check.
|
||||
*
|
||||
* @param hand Side of controller whose value should be returned.
|
||||
* @return Whether the button was released since the last check.
|
||||
* 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].
|
||||
*/
|
||||
bool GetBumperReleased(JoystickHand hand);
|
||||
double GetRightTriggerAxis() const;
|
||||
|
||||
/**
|
||||
* Read the value of the stick button on the controller.
|
||||
*
|
||||
* @param hand Side of controller whose value should be returned.
|
||||
* @return The state of the button.
|
||||
* Read the value of the left bumper (LB) button on the controller.
|
||||
*/
|
||||
bool GetStickButton(JoystickHand hand) const;
|
||||
bool GetLeftBumper() const;
|
||||
|
||||
/**
|
||||
* Whether the stick button was pressed since the last check.
|
||||
*
|
||||
* @param hand Side of controller whose value should be returned.
|
||||
* @return Whether the button was pressed since the last check.
|
||||
* Read the value of the right bumper (RB) button on the controller.
|
||||
*/
|
||||
bool GetStickButtonPressed(JoystickHand hand);
|
||||
bool GetRightBumper() const;
|
||||
|
||||
/**
|
||||
* Whether the stick button was released since the last check.
|
||||
*
|
||||
* @param hand Side of controller whose value should be returned.
|
||||
* @return Whether the button was released since the last check.
|
||||
* Whether the left bumper (LB) was pressed since the last check.
|
||||
*/
|
||||
bool GetStickButtonReleased(JoystickHand hand);
|
||||
bool GetLeftBumperPressed();
|
||||
|
||||
/**
|
||||
* Whether the right bumper (RB) was pressed since the last check.
|
||||
*/
|
||||
bool GetRightBumperPressed();
|
||||
|
||||
/**
|
||||
* Whether the left bumper (LB) was released since the last check.
|
||||
*/
|
||||
bool GetLeftBumperReleased();
|
||||
|
||||
/**
|
||||
* Whether the right bumper (RB) was released since the last check.
|
||||
*/
|
||||
bool GetRightBumperReleased();
|
||||
|
||||
/**
|
||||
* Read the value of the left stick button (LSB) on the controller.
|
||||
*/
|
||||
bool GetLeftStickButton() const;
|
||||
|
||||
/**
|
||||
* Read the value of the right stick button (RSB) on the controller.
|
||||
*/
|
||||
bool GetRightStickButton() const;
|
||||
|
||||
/**
|
||||
* Whether the left stick button (LSB) was pressed since the last check.
|
||||
*/
|
||||
bool GetLeftStickButtonPressed();
|
||||
|
||||
/**
|
||||
* Whether the right stick button (RSB) was pressed since the last check.
|
||||
*/
|
||||
bool GetRightStickButtonPressed();
|
||||
|
||||
/**
|
||||
* Whether the left stick button (LSB) was released since the last check.
|
||||
*/
|
||||
bool GetLeftStickButtonReleased();
|
||||
|
||||
/**
|
||||
* Whether the right stick button (RSB) was released since the last check.
|
||||
*/
|
||||
bool GetRightStickButtonReleased();
|
||||
|
||||
/**
|
||||
* Read the value of the A button on the controller.
|
||||
@@ -210,7 +234,6 @@ class XboxController : public GenericHID {
|
||||
/**
|
||||
* Read the value of the start button on the controller.
|
||||
*
|
||||
* @param hand Side of controller whose value should be returned.
|
||||
* @return The state of the button.
|
||||
*/
|
||||
bool GetStartButton() const;
|
||||
@@ -229,26 +252,26 @@ class XboxController : public GenericHID {
|
||||
*/
|
||||
bool GetStartButtonReleased();
|
||||
|
||||
enum class Button {
|
||||
kBumperLeft = 5,
|
||||
kBumperRight = 6,
|
||||
kStickLeft = 9,
|
||||
kStickRight = 10,
|
||||
kA = 1,
|
||||
kB = 2,
|
||||
kX = 3,
|
||||
kY = 4,
|
||||
kBack = 7,
|
||||
kStart = 8
|
||||
struct Button {
|
||||
static constexpr int kLeftBumper = 5;
|
||||
static constexpr int kRightBumper = 6;
|
||||
static constexpr int kLeftStick = 9;
|
||||
static constexpr int kRightStick = 10;
|
||||
static constexpr int kA = 1;
|
||||
static constexpr int kB = 2;
|
||||
static constexpr int kX = 3;
|
||||
static constexpr int kY = 4;
|
||||
static constexpr int kBack = 7;
|
||||
static constexpr int kStart = 8;
|
||||
};
|
||||
|
||||
enum class Axis {
|
||||
kLeftX = 0,
|
||||
kRightX = 4,
|
||||
kLeftY = 1,
|
||||
kRightY = 5,
|
||||
kLeftTrigger = 2,
|
||||
kRightTrigger = 3
|
||||
struct Axis {
|
||||
static constexpr int kLeftX = 0;
|
||||
static constexpr int kRightX = 4;
|
||||
static constexpr int kLeftY = 1;
|
||||
static constexpr int kRightY = 5;
|
||||
static constexpr int kLeftTrigger = 2;
|
||||
static constexpr int kRightTrigger = 3;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
// 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
|
||||
@@ -32,86 +32,116 @@ class XboxControllerSim : public GenericHIDSim {
|
||||
explicit XboxControllerSim(int port);
|
||||
|
||||
/**
|
||||
* Change the X value of the joystick.
|
||||
* Change the X axis value of the controller's left stick.
|
||||
*
|
||||
* @param hand the joystick hand
|
||||
* @param value the new value
|
||||
*/
|
||||
void SetX(GenericHID::JoystickHand hand, double value);
|
||||
void SetLeftX(double value);
|
||||
|
||||
/**
|
||||
* Change the Y value of the joystick.
|
||||
* Change the X axis value of the controller's right stick.
|
||||
*
|
||||
* @param hand the joystick hand
|
||||
* @param value the new value
|
||||
*/
|
||||
void SetY(GenericHID::JoystickHand hand, double value);
|
||||
void SetRightX(double value);
|
||||
|
||||
/**
|
||||
* Change the value of a trigger axis on the joystick.
|
||||
* Change the Y axis value of the controller's left stick.
|
||||
*
|
||||
* @param hand the joystick hand
|
||||
* @param value the new value
|
||||
*/
|
||||
void SetTriggerAxis(GenericHID::JoystickHand hand, double value);
|
||||
void SetLeftY(double value);
|
||||
|
||||
/**
|
||||
* Change the value of a bumper on the joystick.
|
||||
* Change the Y axis value of the controller's right stick.
|
||||
*
|
||||
* @param hand the joystick hand
|
||||
* @param state the new value
|
||||
* @param value the new value
|
||||
*/
|
||||
void SetBumper(GenericHID::JoystickHand hand, bool state);
|
||||
void SetRightY(double value);
|
||||
|
||||
/**
|
||||
* Change the value of a button on the joystick.
|
||||
* Change the left trigger axis value of the joystick.
|
||||
*
|
||||
* @param hand the joystick hand
|
||||
* @param state the new value
|
||||
* @param value the new value
|
||||
*/
|
||||
void SetStickButton(GenericHID::JoystickHand hand, bool state);
|
||||
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 state the new value
|
||||
* @param value the new value
|
||||
*/
|
||||
void SetAButton(bool state);
|
||||
void SetAButton(bool value);
|
||||
|
||||
/**
|
||||
* Change the value of the B button.
|
||||
*
|
||||
* @param state the new value
|
||||
* @param value the new value
|
||||
*/
|
||||
void SetBButton(bool state);
|
||||
void SetBButton(bool value);
|
||||
|
||||
/**
|
||||
* Change the value of the X button.
|
||||
*
|
||||
* @param state the new value
|
||||
* @param value the new value
|
||||
*/
|
||||
void SetXButton(bool state);
|
||||
void SetXButton(bool value);
|
||||
|
||||
/**
|
||||
* Change the value of the Y button.
|
||||
*
|
||||
* @param state the new value
|
||||
* @param value the new value
|
||||
*/
|
||||
void SetYButton(bool state);
|
||||
void SetYButton(bool value);
|
||||
|
||||
/**
|
||||
* Change the value of the Back button.
|
||||
*
|
||||
* @param state the new value
|
||||
* @param value the new value
|
||||
*/
|
||||
void SetBackButton(bool state);
|
||||
void SetBackButton(bool value);
|
||||
|
||||
/**
|
||||
* Change the value of the Start button.
|
||||
*
|
||||
* @param state the new value
|
||||
* @param value the new value
|
||||
*/
|
||||
void SetStartButton(bool state);
|
||||
void SetStartButton(bool value);
|
||||
};
|
||||
|
||||
} // namespace sim
|
||||
|
||||
Reference in New Issue
Block a user