JoyStick Class Reference

Driver for a Linux joystick. More...

#include <Devices/JoyStick.H>

Inheritance diagram for JoyStick:
Inheritance graph
[legend]
Collaboration diagram for JoyStick:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 JoyStick (OptionManager &mgr, const std::string &descrName="JoyStick", const std::string &tagName="JoyStick", const char *dev="/dev/input/js0")
 Constructor.
void setListener (rutz::shared_ptr< JoyStickListener > &listener)
 Add a listener.
 ~JoyStick ()
 Destructor.
uint getNumAxes () const
 Get number of axes.
uint getNumButtons () const
 Get number of buttons.
int16 getAxisValue (const uint num) const
 Get value of a given axis.
bool getButtonState (const uint num) const
 Get state of a given button.
void run ()
 Should not call this directly -- running in a thread.
bool joystickPlugged ()

Protected Member Functions

void start1 ()
 get started
void stop1 ()
 get stopped

Protected Attributes

NModelParam< std::stringitsDevName
 Name of our device.
int itsFd
 file descriptor for our device
bool itsPlugged
bool itsKeepGoing
 tell our thread to keep going
std::vector< int16itsAxes
 data from our axes
std::vector< bool > itsButtons
 data from our buttons

Detailed Description

Driver for a Linux joystick.

This is a simple driver for a Linux joystick. There are basically two modes of operation: you can either get the current JoyStick status at any time using getAxisValue() and getButtonState(), or you can register a JoyStickListener using setListener, and the listener will be called each time some change occurs in any of the axes or buttons. Beware that your listener will be called from a thread running in parallel with your main thread.

Definition at line 84 of file JoyStick.H.


Constructor & Destructor Documentation

JoyStick::JoyStick ( OptionManager mgr,
const std::string descrName = "JoyStick",
const std::string tagName = "JoyStick",
const char *  dev = "/dev/input/js0" 
)

Constructor.

Definition at line 62 of file JoyStick.C.

JoyStick::~JoyStick (  ) 

Destructor.

Definition at line 78 of file JoyStick.C.


Member Function Documentation

int16 JoyStick::getAxisValue ( const uint  num  )  const

Get value of a given axis.

Definition at line 122 of file JoyStick.C.

References itsAxes.

bool JoyStick::getButtonState ( const uint  num  )  const

Get state of a given button.

Definition at line 135 of file JoyStick.C.

References itsButtons.

uint JoyStick::getNumAxes (  )  const

Get number of axes.

Definition at line 114 of file JoyStick.C.

References itsAxes.

uint JoyStick::getNumButtons (  )  const

Get number of buttons.

Definition at line 118 of file JoyStick.C.

References itsButtons.

void JoyStick::run (  ) 

Should not call this directly -- running in a thread.

Definition at line 148 of file JoyStick.C.

References rutz::shared_ptr< T >::get(), itsAxes, itsButtons, itsFd, and itsKeepGoing.

void JoyStick::setListener ( rutz::shared_ptr< JoyStickListener > &  listener  ) 

Add a listener.

Definition at line 74 of file JoyStick.C.

void JoyStick::start1 (  )  [protected, virtual]

get started

Reimplemented from ModelComponent.

Definition at line 82 of file JoyStick.C.

References NModelParam< T >::getVal(), itsAxes, itsButtons, itsDevName, itsFd, and itsKeepGoing.

void JoyStick::stop1 (  )  [protected, virtual]

get stopped

Reimplemented from ModelComponent.

Definition at line 106 of file JoyStick.C.

References itsFd, and itsKeepGoing.


Member Data Documentation

data from our axes

Definition at line 128 of file JoyStick.H.

Referenced by getAxisValue(), getNumAxes(), run(), and start1().

std::vector<bool> JoyStick::itsButtons [protected]

data from our buttons

Definition at line 129 of file JoyStick.H.

Referenced by getButtonState(), getNumButtons(), run(), and start1().

Name of our device.

Definition at line 120 of file JoyStick.H.

Referenced by start1().

int JoyStick::itsFd [protected]

file descriptor for our device

Definition at line 125 of file JoyStick.H.

Referenced by run(), start1(), and stop1().

bool JoyStick::itsKeepGoing [protected]

tell our thread to keep going

Definition at line 127 of file JoyStick.H.

Referenced by run(), start1(), and stop1().


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:43:24 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3