12 #include <support/deprecated.h> 14 #include "GenericHID.h" 28 static constexpr
int kDefaultXAxis = 0;
29 static constexpr
int kDefaultYAxis = 1;
30 static constexpr
int kDefaultZAxis = 2;
31 static constexpr
int kDefaultTwistAxis = 2;
32 static constexpr
int kDefaultThrottleAxis = 3;
33 static constexpr
int kMinNumAxes = 4;
35 enum AxisType { kXAxis, kYAxis, kZAxis, kTwistAxis, kThrottleAxis };
36 enum ButtonType { kTriggerButton, kTopButton };
50 WPI_DEPRECATED(
"Use the more specific axis channel setter functions.")
59 WPI_DEPRECATED(
"Use the more specific axis channel getter functions.")
60 int GetAxisChannel(AxisType axis)
const;
62 double GetX(JoystickHand hand = kRightHand)
const override;
63 double GetY(JoystickHand hand = kRightHand)
const override;
68 WPI_DEPRECATED(
"Use the more specific axis channel getter functions.")
69 double GetAxis(AxisType axis)
const;
79 WPI_DEPRECATED(
"Use Joystick instances instead.")
80 static Joystick* GetStickForPort(
int port);
82 WPI_DEPRECATED(
"Use the more specific button getter functions.")
90 enum class Axis { kX, kY, kZ, kTwist, kThrottle };
91 enum class Button { kTrigger = 1, kTop = 2 };
93 std::vector<int> m_axes;
double GetAxis(AxisType axis) const
For the current joystick, return the axis determined by the argument.
Definition: Joystick.cpp:201
double GetDirectionRadians() const
Get the direction of the vector formed by the joystick and its origin in radians. ...
Definition: Joystick.cpp:317
double GetX(JoystickHand hand=kRightHand) const override
Get the X value of the joystick.
Definition: Joystick.cpp:150
int GetTwistChannel() const
Get the channel currently associated with the twist axis.
Definition: Joystick.cpp:129
void SetTwistChannel(int channel)
Set the channel associated with the twist axis.
Definition: Joystick.cpp:89
int GetZChannel() const
Get the channel currently associated with the Z axis.
Definition: Joystick.cpp:122
int GetXChannel() const
Get the channel currently associated with the X axis.
Definition: Joystick.cpp:108
Joystick(int port)
Construct an instance of a joystick.
Definition: Joystick.cpp:33
bool GetTopReleased()
Whether the top button was released since the last check.
Definition: Joystick.cpp:273
void SetAxisChannel(AxisType axis, int channel)
Set the channel associated with a specified axis.
Definition: Joystick.cpp:50
int GetYChannel() const
Get the channel currently associated with the Y axis.
Definition: Joystick.cpp:115
void SetYChannel(int channel)
Set the channel associated with the Y axis.
Definition: Joystick.cpp:69
double GetTwist() const
Get the twist value of the current joystick.
Definition: Joystick.cpp:178
void SetXChannel(int channel)
Set the channel associated with the X axis.
Definition: Joystick.cpp:59
bool GetTopPressed()
Whether the top button was pressed since the last check.
Definition: Joystick.cpp:264
double GetThrottle() const
Get the throttle value of the current joystick.
Definition: Joystick.cpp:187
double GetDirectionDegrees() const
Get the direction of the vector formed by the joystick and its origin in degrees. ...
Definition: Joystick.cpp:330
double GetMagnitude() const
Get the magnitude of the direction vector formed by the joystick's current position relative to its o...
Definition: Joystick.cpp:307
Handle input from standard Joysticks connected to the Driver Station.
Definition: Joystick.h:26
int GetThrottleChannel() const
Get the channel currently associated with the throttle axis.
Definition: Joystick.cpp:138
void SetThrottleChannel(int channel)
Set the channel associated with the throttle axis.
Definition: Joystick.cpp:99
double GetY(JoystickHand hand=kRightHand) const override
Get the Y value of the joystick.
Definition: Joystick.cpp:162
bool GetTriggerReleased()
Whether the trigger was released since the last check.
Definition: Joystick.cpp:244
GenericHID Interface.
Definition: GenericHID.h:23
bool GetTop() const
Read the state of the top button on the joystick.
Definition: Joystick.cpp:255
bool GetTrigger() const
Read the state of the trigger on the joystick.
Definition: Joystick.cpp:226
bool GetButton(ButtonType button) const
Get buttons based on an enumerated type.
Definition: Joystick.cpp:296
bool GetTriggerPressed()
Whether the trigger was pressed since the last check.
Definition: Joystick.cpp:235
void SetZChannel(int channel)
Set the channel associated with the Z axis.
Definition: Joystick.cpp:79
double GetZ() const
Get the Z value of the current joystick.
Definition: Joystick.cpp:171