mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +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:
@@ -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