Now you can download a copy of these docs so you can use them offline! Download now

#include <Joystick.h>

Inheritance diagram for Joystick:
Collaboration diagram for Joystick:

List of all members.

Public Types

enum  AxisType {
  kXAxis, kYAxis, kZAxis, kTwistAxis,
  kThrottleAxis, kNumAxisTypes
}
enum  ButtonType { kTriggerButton, kTopButton, kNumButtonTypes }

Public Member Functions

 Joystick (UINT32 port)
 Joystick (UINT32 port, UINT32 numAxisTypes, UINT32 numButtonTypes)
UINT32 GetAxisChannel (AxisType axis)
void SetAxisChannel (AxisType axis, UINT32 channel)
virtual float GetX (JoystickHand hand=kRightHand)
virtual float GetY (JoystickHand hand=kRightHand)
virtual float GetZ ()
virtual float GetTwist ()
virtual float GetThrottle ()
virtual float GetAxis (AxisType axis)
float GetRawAxis (UINT32 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 (UINT32 button)
virtual float GetMagnitude ()
virtual float GetDirectionRadians ()
virtual float GetDirectionDegrees ()

Static Public Member Functions

static JoystickGetStickForPort (UINT32 port)

Static Public Attributes

static const UINT32 kDefaultXAxis = 1
static const UINT32 kDefaultYAxis = 2
static const UINT32 kDefaultZAxis = 3
static const UINT32 kDefaultTwistAxis = 4
static const UINT32 kDefaultThrottleAxis = 3
static const UINT32 kDefaultTriggerButton = 1
static const UINT32 kDefaultTopButton = 2

Detailed Description

Handle input from standard Joysticks connected to the Driver Station. This class handles standard input that comes from the Driver Station. Each time a value is requested the most recent value is returned. There is a single class instance for each joystick and the mapping of ports to hardware buttons depends on the code in the driver station.

Definition at line 21 of file Joystick.h.


Constructor & Destructor Documentation

Joystick::Joystick ( UINT32  port  )  [explicit]

Construct an instance of a joystick. The joystick index is the usb port on the drivers station.

Parameters:
port The port on the driver station that the joystick is plugged into.

Definition at line 28 of file Joystick.cpp.

Joystick::Joystick ( UINT32  port,
UINT32  numAxisTypes,
UINT32  numButtonTypes 
)

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.

Parameters:
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.

Definition at line 56 of file Joystick.cpp.


Member Function Documentation

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()).

Parameters:
axis The axis to read.
Returns:
The value of the axis.

Definition at line 162 of file Joystick.cpp.

UINT32 Joystick::GetAxisChannel ( AxisType  axis  ) 

Get the channel currently associated with the specified axis.

Parameters:
axis The axis to look up the channel for.
Returns:
The channel fr the axis.

Definition at line 252 of file Joystick.cpp.

bool Joystick::GetBumper ( JoystickHand  hand = kRightHand  )  [virtual]

This is not supported for the Joystick. This method is only here to complete the GenericHID interface.

Definition at line 207 of file Joystick.cpp.

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.

Parameters:
button The type of button to read.
Returns:
The state of the button.

Definition at line 235 of file Joystick.cpp.

float Joystick::GetDirectionDegrees (  )  [virtual]

Get the direction of the vector formed by the joystick and its origin in degrees

uses acos(-1) to represent Pi due to absence of readily accessable Pi constant in C++

Returns:
The direction of the vector in degrees

Definition at line 297 of file Joystick.cpp.

float Joystick::GetDirectionRadians (  )  [virtual]

Get the direction of the vector formed by the joystick and its origin in radians

Returns:
The direction of the vector in radians

Definition at line 284 of file Joystick.cpp.

float Joystick::GetMagnitude (  )  [virtual]

Get the magnitude of the direction vector formed by the joystick's current position relative to its origin

Returns:
The magnitude of the direction vector

Definition at line 274 of file Joystick.cpp.

float Joystick::GetRawAxis ( UINT32  axis  ) 

Get the value of the axis.

Parameters:
axis The axis to read [1-6].
Returns:
The value of the axis.

Definition at line 148 of file Joystick.cpp.

bool Joystick::GetRawButton ( UINT32  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.

Parameters:
button The button number to be read.
Returns:
The state of the button.

Definition at line 222 of file Joystick.cpp.

float Joystick::GetThrottle (  )  [virtual]

Get the throttle value of the current joystick. This depends on the mapping of the joystick connected to the current port.

Definition at line 137 of file Joystick.cpp.

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.

Parameters:
hand This parameter is ignored for the Joystick class and is only here to complete the GenericHID interface.
Returns:
The state of the top button.

Definition at line 198 of file Joystick.cpp.

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.

Parameters:
hand This parameter is ignored for the Joystick class and is only here to complete the GenericHID interface.
Returns:
The state of the trigger.

Definition at line 185 of file Joystick.cpp.

float Joystick::GetTwist (  )  [virtual]

Get the twist value of the current joystick. This depends on the mapping of the joystick connected to the current port.

Definition at line 128 of file Joystick.cpp.

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.

Definition at line 101 of file Joystick.cpp.

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.

Definition at line 110 of file Joystick.cpp.

float Joystick::GetZ (  )  [virtual]

Get the Z value of the current joystick. This depends on the mapping of the joystick connected to the current port.

Definition at line 119 of file Joystick.cpp.

void Joystick::SetAxisChannel ( AxisType  axis,
UINT32  channel 
)

Set the channel associated with a specified axis.

Parameters:
axis The axis to set the channel for.
channel The channel to set the axis to.

Definition at line 263 of file Joystick.cpp.


The documentation for this class was generated from the following files:

Generated on Thu Jan 12 2012 22:35:32 for WPILibC++ by doxygen 1.7.1