MRPT logo

mrpt::hwdrivers::CJoystick Class Reference

Access to joysticks and gamepads (read buttons and position), and request number of joysticks in the system. More...

#include <mrpt/hwdrivers/CJoystick.h>

List of all members.

Public Member Functions

 CJoystick ()
 Constructor.
virtual ~CJoystick ()
 Destructor.
bool getJoystickPosition (int nJoy, float &x, float &y, float &z, std::vector< bool > &buttons, int *raw_x_pos=NULL, int *raw_y_pos=NULL, int *raw_z_pos=NULL)
 Gets joystick information.
void setLimits (int x_min=-32767, int x_max=32767, int y_min=-32767, int y_max=32767, int z_min=-32767, int z_max=32767)
 Set the axis limit values, for computing a [-1,1] position index easily (Only required to calibrate analog joystick).

Static Public Member Functions

static int getJoysticksCount ()
 Returns the number of Joysticks in the computer.

Private Attributes

int m_x_min
 The axis limits:.
int m_x_max
int m_y_min
int m_y_max
int m_z_min
int m_z_max


Detailed Description

Access to joysticks and gamepads (read buttons and position), and request number of joysticks in the system.

Since MRPT 0.6.0 this class works in Windows and Linux.

Definition at line 45 of file CJoystick.h.


Constructor & Destructor Documentation

mrpt::hwdrivers::CJoystick::CJoystick (  ) 

Constructor.

virtual mrpt::hwdrivers::CJoystick::~CJoystick (  )  [virtual]

Destructor.


Member Function Documentation

bool mrpt::hwdrivers::CJoystick::getJoystickPosition ( int  nJoy,
float &  x,
float &  y,
float &  z,
std::vector< bool > &  buttons,
int *  raw_x_pos = NULL,
int *  raw_y_pos = NULL,
int *  raw_z_pos = NULL 
)

Gets joystick information.

This method will try first to open the joystick, so you can safely call it while the joystick is plugged and removed arbitrarly.

Parameters:
nJoy The index of the joystick to query: The first one is 0, the second 1, etc... See CJoystick::getJoysticksCount to discover the number of joysticks in the system.
x The x axis position, range [-1,1]
y The y axis position, range [-1,1]
z The z axis position, range [-1,1]
buttons Each element will hold true if buttons are pressed. The size of the vector will be set automatically to the number of buttons.
raw_x_pos If it is desired the raw integer measurement from JoyStick, set this pointer to a desired placeholder.
raw_y_pos If it is desired the raw integer measurement from JoyStick, set this pointer to a desired placeholder.
raw_z_pos If it is desired the raw integer measurement from JoyStick, set this pointer to a desired placeholder.
Returns:
Returns true if successfull, false on error, for example, if joystick is not present.
See also:
setLimits

static int mrpt::hwdrivers::CJoystick::getJoysticksCount (  )  [static]

Returns the number of Joysticks in the computer.

void mrpt::hwdrivers::CJoystick::setLimits ( int  x_min = -32767,
int  x_max = 32767,
int  y_min = -32767,
int  y_max = 32767,
int  z_min = -32767,
int  z_max = 32767 
)

Set the axis limit values, for computing a [-1,1] position index easily (Only required to calibrate analog joystick).

It seems that these values must been calibrated for each joystick model.

See also:
getJoystickPosition


Member Data Documentation

Definition at line 50 of file CJoystick.h.

The axis limits:.

Definition at line 50 of file CJoystick.h.

Definition at line 50 of file CJoystick.h.

Definition at line 50 of file CJoystick.h.

Definition at line 50 of file CJoystick.h.

Definition at line 50 of file CJoystick.h.




Page generated by Doxygen 1.5.8 for MRPT 0.6.5 SVN: at Sun Aug 9 21:47:23 CEST 2009