14 #include "GenericHID.h"
15 #include "ErrorBase.h"
29 static const uint32_t kDefaultXAxis = 0;
30 static const uint32_t kDefaultYAxis = 1;
31 static const uint32_t kDefaultZAxis = 2;
32 static const uint32_t kDefaultTwistAxis = 2;
33 static const uint32_t kDefaultThrottleAxis = 3;
42 static const uint32_t kDefaultTriggerButton = 1;
43 static const uint32_t kDefaultTopButton = 2;
44 typedef enum { kTriggerButton, kTopButton, kNumButtonTypes } ButtonType;
45 typedef enum { kLeftRumble, kRightRumble } RumbleType;
51 kXInputArcadeStick = 3,
52 kXInputFlightStick = 4,
58 kXInputArcadePad = 19,
66 Joystick(uint32_t port, uint32_t numAxisTypes, uint32_t numButtonTypes);
75 virtual float GetX(JoystickHand hand = kRightHand)
const override;
76 virtual float GetY(JoystickHand hand = kRightHand)
const override;
77 virtual float GetZ()
const override;
78 virtual float GetTwist()
const override;
80 virtual float GetAxis(AxisType axis)
const;
81 float GetRawAxis(uint32_t axis)
const override;
83 virtual bool GetTrigger(JoystickHand hand = kRightHand)
const override;
84 virtual bool GetTop(JoystickHand hand = kRightHand)
const override;
85 virtual bool GetBumper(JoystickHand hand = kRightHand)
const override;
86 virtual bool GetRawButton(uint32_t button)
const override;
87 virtual int GetPOV(uint32_t pov = 0)
const override;
89 static Joystick *GetStickForPort(uint32_t port);
96 Joystick::HIDType
GetType()
const;
98 int GetAxisType(uint8_t axis)
const;
104 void SetRumble(RumbleType type,
float value);
105 void SetOutput(uint8_t outputNumber,
bool value);
111 std::vector<uint32_t> m_axes;
112 std::vector<uint32_t> m_buttons;
113 uint32_t m_outputs = 0;
114 uint16_t m_leftRumble = 0;
115 uint16_t m_rightRumble = 0;
virtual float GetMagnitude() const
Get the magnitude of the direction vector formed by the joystick's current position relative to its o...
Definition: Joystick.cpp:312
bool GetButton(ButtonType button) const
Get buttons based on an enumerated type.
Definition: Joystick.cpp:226
void SetOutputs(uint32_t value)
Set all HID output values for the joystick.
Definition: Joystick.cpp:373
virtual float GetY(JoystickHand hand=kRightHand) const override
Get the Y value of the joystick.
Definition: Joystick.cpp:97
int GetButtonCount() const
Get the number of axis for a joystick.
Definition: Joystick.cpp:277
virtual int GetPOV(uint32_t pov=0) const override
Get the state of a POV on the joystick.
Definition: Joystick.cpp:214
std::string GetName() const
Get the name of the joystick.
Definition: Joystick.cpp:265
bool GetIsXbox() const
Get the value of isXbox for the joystick.
Definition: Joystick.cpp:249
Base class for most objects.
Definition: ErrorBase.h:66
virtual float GetDirectionDegrees() const
Get the direction of the vector formed by the joystick and its origin in degrees. ...
Definition: Joystick.cpp:333
virtual float GetTwist() const override
Get the twist value of the current joystick.
Definition: Joystick.cpp:111
void SetRumble(RumbleType type, float value)
Set the rumble output for the joystick.
Definition: Joystick.cpp:344
int GetPOVCount() const
Get the number of axis for a joystick.
Definition: Joystick.cpp:286
Joystick::HIDType GetType() const
Get the HID type of the controller.
Definition: Joystick.cpp:256
virtual bool GetTrigger(JoystickHand hand=kRightHand) const override
Read the state of the trigger on the joystick.
Definition: Joystick.cpp:168
Joystick(uint32_t port)
Construct an instance of a joystick.
Definition: Joystick.cpp:31
virtual float GetX(JoystickHand hand=kRightHand) const override
Get the X value of the joystick.
Definition: Joystick.cpp:87
virtual bool GetRawButton(uint32_t button) const override
Get the button value (starting at button 1)
Definition: Joystick.cpp:204
Handle input from standard Joysticks connected to the Driver Station.
Definition: Joystick.h:27
int GetAxisCount() const
Get the number of axis for a joystick.
Definition: Joystick.cpp:242
virtual float GetZ() const override
Get the Z value of the current joystick.
Definition: Joystick.cpp:105
void SetOutput(uint8_t outputNumber, bool value)
Set a single HID output value for the joystick.
Definition: Joystick.cpp:362
uint32_t GetAxisChannel(AxisType axis) const
Get the channel currently associated with the specified axis.
Definition: Joystick.cpp:294
virtual float GetThrottle() const override
Get the throttle value of the current joystick.
Definition: Joystick.cpp:117
virtual bool GetTop(JoystickHand hand=kRightHand) const override
Read the state of the top button on the joystick.
Definition: Joystick.cpp:181
virtual float GetAxis(AxisType axis) const
For the current joystick, return the axis determined by the argument.
Definition: Joystick.cpp:141
virtual bool GetBumper(JoystickHand hand=kRightHand) const override
This is not supported for the Joystick.
Definition: Joystick.cpp:189
virtual float GetDirectionRadians() const
Get the direction of the vector formed by the joystick and its origin in radians. ...
Definition: Joystick.cpp:322
GenericHID Interface.
Definition: GenericHID.h:14
void SetAxisChannel(AxisType axis, uint32_t channel)
Set the channel associated with a specified axis.
Definition: Joystick.cpp:302
float GetRawAxis(uint32_t axis) const override
Get the value of the axis.
Definition: Joystick.cpp:127
Provide access to the network communication data to / from the Driver Station.
Definition: DriverStation.h:27