15 #include "ErrorBase.h" 16 #include "JoystickBase.h" 31 static const int kDefaultXAxis = 0;
32 static const int kDefaultYAxis = 1;
33 static const int kDefaultZAxis = 2;
34 static const int kDefaultTwistAxis = 2;
35 static const int kDefaultThrottleAxis = 3;
46 static const int kDefaultTriggerButton = 1;
47 static const int kDefaultTopButton = 2;
49 typedef enum { kTriggerButton, kTopButton, kNumButtonTypes } ButtonType;
52 Joystick(
int port,
int numAxisTypes,
int numButtonTypes);
61 double GetX(JoystickHand hand = kRightHand)
const override;
62 double GetY(JoystickHand hand = kRightHand)
const override;
63 double GetZ(JoystickHand hand = kRightHand)
const override;
66 virtual double GetAxis(AxisType axis)
const;
68 bool GetTrigger(JoystickHand hand = kRightHand)
const override;
69 bool GetTop(JoystickHand hand = kRightHand)
const override;
71 static Joystick* GetStickForPort(
int port);
84 std::vector<int> m_axes;
85 std::vector<int> m_buttons;
virtual double GetAxis(AxisType axis) const
For the current joystick, return the axis determined by the argument.
Definition: Joystick.cpp:145
virtual double GetDirectionRadians() const
Get the direction of the vector formed by the joystick and its origin in radians. ...
Definition: Joystick.cpp:267
double GetX(JoystickHand hand=kRightHand) const override
Get the X value of the joystick.
Definition: Joystick.cpp:94
bool GetTrigger(JoystickHand hand=kRightHand) const override
Read the state of the trigger on the joystick.
Definition: Joystick.cpp:172
Joystick Interface.
Definition: JoystickBase.h:17
Joystick(int port)
Construct an instance of a joystick.
Definition: Joystick.cpp:37
void SetAxisChannel(AxisType axis, int channel)
Set the channel associated with a specified axis.
Definition: Joystick.cpp:247
Provide access to the network communication data to / from the Driver Station.
Definition: DriverStation.h:28
bool GetTop(JoystickHand hand=kRightHand) const override
Read the state of the top button on the joystick.
Definition: Joystick.cpp:185
int GetAxisType(int axis) const
Get the axis type of a joystick axis.
Definition: Joystick.cpp:220
virtual double GetDirectionDegrees() const
Get the direction of the vector formed by the joystick and its origin in degrees. ...
Definition: Joystick.cpp:280
virtual double GetMagnitude() const
Get the magnitude of the direction vector formed by the joystick's current position relative to its o...
Definition: Joystick.cpp:257
double GetTwist() const override
Get the twist value of the current joystick.
Definition: Joystick.cpp:124
Handle input from standard Joysticks connected to the Driver Station.
Definition: Joystick.h:29
double GetThrottle() const override
Get the throttle value of the current joystick.
Definition: Joystick.cpp:131
Base class for most objects.
Definition: ErrorBase.h:74
int GetButtonCount() const
Get the number of buttons for a joystick.
Definition: Joystick.cpp:229
double GetY(JoystickHand hand=kRightHand) const override
Get the Y value of the joystick.
Definition: Joystick.cpp:106
double GetZ(JoystickHand hand=kRightHand) const override
Get the Z value of the current joystick.
Definition: Joystick.cpp:115
int GetAxisCount() const
Get the number of axis for a joystick.
Definition: Joystick.cpp:213
bool GetButton(ButtonType button) const
Get buttons based on an enumerated type.
Definition: Joystick.cpp:197
int GetAxisChannel(AxisType axis) const
Get the channel currently associated with the specified axis.
Definition: Joystick.cpp:239