#include <Joystick.h>
Inherits GenericHID.
Public Member Functions | |
Joystick (unsigned port) | |
virtual float | GetX (JoystickHand hand=kRightHand) |
virtual float | GetY (JoystickHand hand=kRightHand) |
virtual float | GetZ (void) |
virtual float | GetTwist (void) |
virtual float | GetThrottle (void) |
virtual float | GetAxis (AxisType axis) |
float | GetRawAxis (unsigned axis) |
virtual bool | GetTrigger (JoystickHand hand=kRightHand) |
virtual bool | GetTop (JoystickHand hand=kRightHand) |
virtual bool | GetBumper (JoystickHand hand=kRightHand) |
virtual bool | GetButton (ButtonType button) |
bool | GetRawButton (unsigned button) |
Protected Member Functions | |
Joystick (unsigned port, unsigned numAxisTypes, unsigned numButtonTypes) |
Joystick::Joystick | ( | unsigned | port | ) |
Construct an instance of a joystick. The joystick index is the usb port on the drivers station.
port | The port on the driver station that the joystick is plugged into. |
Joystick::Joystick | ( | unsigned | port, | |
unsigned | numAxisTypes, | |||
unsigned | numButtonTypes | |||
) | [protected] |
Protected version of the constructor to be called by sub-classes.
This constructor allows the subclass to configure the number of constants for axes and buttons.
port | The port on the driver station that the joystick is plugged into. | |
numAxisTypes | The number of axis types in the enum. | |
numButtonTypes | The number of button types in the enum. |
float Joystick::GetX | ( | JoystickHand | hand = kRightHand |
) | [virtual] |
Get the X value of the joystick. This depends on the mapping of the joystick connected to the current port.
float Joystick::GetY | ( | JoystickHand | hand = kRightHand |
) | [virtual] |
Get the Y value of the joystick. This depends on the mapping of the joystick connected to the current port.
float Joystick::GetZ | ( | void | ) | [virtual] |
Get the Z value of the current joystick. This depends on the mapping of the joystick connected to the current port.
float Joystick::GetTwist | ( | void | ) | [virtual] |
Get the twist value of the current joystick. This depends on the mapping of the joystick connected to the current port.
float Joystick::GetThrottle | ( | void | ) | [virtual] |
Get the throttle value of the current joystick. This depends on the mapping of the joystick connected to the current port.
float Joystick::GetAxis | ( | AxisType | axis | ) | [virtual] |
For the current joystick, return the axis determined by the argument.
This is for cases where the joystick axis is returned programatically, otherwise one of the previous functions would be preferable (for example GetX()).
axis | The axis to read. |
float Joystick::GetRawAxis | ( | unsigned | axis | ) |
Get the value of the axis.
axis | The axis to read [1-6]. |
bool Joystick::GetTrigger | ( | JoystickHand | hand = kRightHand |
) | [virtual] |
Read the state of the trigger on the joystick.
Look up which button has been assigned to the trigger and read its state.
hand | This parameter is ignored for the Joystick class and is only here to complete the GenericHID interface. |
bool Joystick::GetTop | ( | JoystickHand | hand = kRightHand |
) | [virtual] |
Read the state of the top button on the joystick.
Look up which button has been assigned to the top and read its state.
hand | This parameter is ignored for the Joystick class and is only here to complete the GenericHID interface. |
bool Joystick::GetBumper | ( | JoystickHand | hand = kRightHand |
) | [virtual] |
This is not supported for the Joystick. This method is only here to complete the GenericHID interface.
bool Joystick::GetButton | ( | ButtonType | button | ) | [virtual] |
Get buttons based on an enumerated type.
The button type will be looked up in the list of buttons and then read.
button | The type of button to read. |
bool Joystick::GetRawButton | ( | unsigned | button | ) |
Get the button value for buttons 1 through 12.
The buttons are returned in a single 16 bit value with one bit representing the state of each button. The appropriate button is returned as a boolean value.
button | The button number to be read. |