mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[commands] GenericHIDController: use composition in C++ (#6296)
This commit is contained in:
@@ -7,30 +7,31 @@
|
||||
|
||||
#include "Trigger.h"
|
||||
#include "frc2/command/CommandScheduler.h"
|
||||
#include "frc2/command/button/CommandGenericHID.h"
|
||||
|
||||
namespace frc2 {
|
||||
/**
|
||||
* A version of {@link XboxController} with {@link Trigger} factories for
|
||||
* A version of {@link frc::XboxController} with {@link Trigger} factories for
|
||||
* command-based.
|
||||
*
|
||||
* @see XboxController
|
||||
* @see frc::XboxController
|
||||
*/
|
||||
class CommandXboxController : public frc::XboxController {
|
||||
class CommandXboxController : CommandGenericHID {
|
||||
public:
|
||||
using XboxController::XboxController;
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
*
|
||||
* @param port The port index on the Driver Station that the controller is
|
||||
* plugged into.
|
||||
*/
|
||||
explicit CommandXboxController(int port);
|
||||
|
||||
/**
|
||||
* Constructs an event instance around this button's digital signal.
|
||||
* Get the underlying GenericHID object.
|
||||
*
|
||||
* @param button the button index
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return an event instance representing the button's digital signal attached
|
||||
* to the given loop.
|
||||
* @return the wrapped GenericHID object
|
||||
*/
|
||||
Trigger Button(int button,
|
||||
frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
frc::XboxController& GetHID();
|
||||
|
||||
/**
|
||||
* Constructs an event instance around the left bumper's digital signal.
|
||||
@@ -176,5 +177,52 @@ class CommandXboxController : public frc::XboxController {
|
||||
double threshold = 0.5,
|
||||
frc::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) 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();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* Get the Y axis value of right side of the controller.
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
double GetRightY();
|
||||
|
||||
/**
|
||||
* Get the Y axis value of left side of the controller.
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
double GetLeftY();
|
||||
|
||||
/**
|
||||
* Get the X axis value of right side of the controller.
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
double GetRightX();
|
||||
|
||||
/**
|
||||
* Get the X axis value of left side of the controller.
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
double GetLeftX();
|
||||
|
||||
private:
|
||||
frc::XboxController m_hid;
|
||||
};
|
||||
} // namespace frc2
|
||||
|
||||
Reference in New Issue
Block a user