Wingman3D Class Reference

The class Wingman3D provides an interface to the following Logitech (Vendor ID: 0x046D) USB HID compliant joysticks:. More...

#include <Wingman3D.hpp>

List of all members.

Public Member Functions

 Wingman3D (int devNum=0)
 ~Wingman3D ()
int getX () const
int getMaxX () const
int getY () const
int getMaxY () const
int getTwist () const
int getMaxTwist () const
int getNumButtons () const
bool isButtonPressed (int button) const
int getSliderValue () const
int getMaxSliderValue () const
int getHatSwitchStatus () const
bool isStatusOk () const
char * getStatusMessage () const
void printDeviceInfo (int verbosity=1) const

Protected Member Functions

wingman_data_t getWingmanData () const
wingman_data_t getWingmanMaxData () const


Detailed Description

The class Wingman3D provides an interface to the following Logitech (Vendor ID: 0x046D) USB HID compliant joysticks:.

To use the joystick please ensure that the USB manager (devu-uhci or devu-ohci) and manager for HID devices (io-hid) are running. Your application will also need to be linked with the HID library libhiddi.so and the library created by this class. You will need to be root to use this class. Here are the commands to start the device managers (as root) :

 /sbin/devu-uhci & (or /sbin/devu-ohci &)
 /sbin/io-hid &
 mount -Tio-hid devh-usb.so &

Example Program:

//========================================================================
// Wingman3D.t.cpp  : Example program for Logitech Wingman HID Joystick     
//
// Author           : Vilas Kumar Chitrakaran <cvilas@ces.clemson.edu>     
// Date             : March 2, 2004
// Compiler         : GNU GCC 2.95.3qnx-nto
// Operating System : QNX Momentics 6.2.1                                
//========================================================================

#include "Wingman3D.hpp"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main()
{
 Wingman3D joystick(0);

 if( !joystick.isStatusOk() ) {
  fprintf(stderr, "%s\n", joystick.getStatusMessage());
  return EXIT_FAILURE;
 }
 sleep(1);
 joystick.printDeviceInfo(3);

 while(1)
 {
  fprintf(stdout, "\nx: %03d y: %03d z: %03d slide: %03d hat: %03d buttons: ", 
   joystick.getX(), joystick.getY(), joystick.getTwist(),
   joystick.getSliderValue(), joystick.getHatSwitchStatus());
 
  for(int i = 1; i < joystick.getNumButtons(); i++)
   if( joystick.isButtonPressed(i) )
    fprintf(stdout, "%01d ", i);

  if( !joystick.isStatusOk() )
   return -1;
  
 }

 return EXIT_SUCCESS;
}


Constructor & Destructor Documentation

Wingman3D::Wingman3D int  devNum = 0  ) 
 

The default constructor. Establishes connection with the HID driver.

Parameters:
devNum The address of the joystick device to connect to (default = 0).

Wingman3D::~Wingman3D  ) 
 

The default destructor disconnects from the HID driver and cleans up.


Member Function Documentation

int Wingman3D::getX  )  const
 

Returns:
The X position

int Wingman3D::getMaxX  )  const
 

Returns:
The maximum output from X axis.

int Wingman3D::getY  )  const
 

Returns:
The Y position

int Wingman3D::getMaxY  )  const
 

Returns:
The maximum output from Y axis.

int Wingman3D::getTwist  )  const
 

Returns:
The twist handle position.

int Wingman3D::getMaxTwist  )  const
 

Returns:
The maximum output from twist axis.

int Wingman3D::getNumButtons  )  const
 

Returns:
The number of programmable buttons available

bool Wingman3D::isButtonPressed int  button  )  const
 

Returns:
true if button button is pressed, else false

int Wingman3D::getSliderValue  )  const
 

Returns:
The slider/throttle position. Range [0 - 255].

int Wingman3D::getMaxSliderValue  )  const
 

Returns:
The maximum output from slider.

int Wingman3D::getHatSwitchStatus  )  const
 

Returns:
A value indicating position of the hat switch. Range [1 - 8].

bool Wingman3D::isStatusOk  )  const
 

Returns:
true if no error, else false.

char* Wingman3D::getStatusMessage  )  const
 

Returns:
A string carrying current status of the device. This string also carries error messages when isStatusOk() returns false.

void Wingman3D::printDeviceInfo int  verbosity = 1  )  const
 

Print information about the device to stdout. Higher values of verbosity mean more detailed information.

wingman_data_t Wingman3D::getWingmanData  )  const [protected]
 

Returns:
The whole data structure for device with current joystick data

wingman_data_t Wingman3D::getWingmanMaxData  )  const [protected]
 

Returns:
The whole data structure for device with max limits for joystick data


The documentation for this class was generated from the following file:
Created for project Logitech Wingman 3D Class Driver on Mon Aug 28 15:21:10 EDT 2006
for Vilas Kumar Chitrakaran (cvilas(@)ces.clemson.edu).
Documentation generated using Doxygen .