FlyStick2 Class Reference

Flystick2 Body format data structure. More...

#include <bodies.h>

Inheritance diagram for FlyStick2:

Body Body

List of all members.

Public Member Functions

 FlyStick2 (int id, float qu, int buttons, int controls, float *shift=NULL, float *rotation=NULL)
 Constructor.
 ~FlyStick2 ()
 Destructor.
void addButtons (int pos, int config)
 Add configuration of max 32 buttons.
void addControls (int pos, float value)
 Add analog control value to array.
virtual int Button (int num)
 Returns whether the button is switched on or off.
virtual int ButonsNumber ()
 Returns the number of buttons.
virtual int ButtonsMask32 ()
 returns mask of first 32 buttons
virtual int ControlsNuber ()
 Returns the number of analog controls.
virtual float Control (int num)
 Returns the value of specified analog control.
 FlyStick2 (int id, float qu, int buttons, int controls, float *shift=NULL, float *rotation=NULL)
 Constructor.
 ~FlyStick2 ()
 Destructor.
void addButtons (int pos, int config)
 Add configuration of max 32 buttons.
void addControls (int pos, float value)
 Add analog control value to array.
virtual int Button (int num)
 Returns whether the button is switched on or off.
virtual int ButonsNumber ()
 Returns the number of buttons.
virtual int ButtonsMask32 ()
 returns mask of first 32 buttons
virtual int ControlsNuber ()
 Returns the number of analog controls.
virtual float Control (int num)
 Returns the value of specified analog control.

Protected Attributes

int buttonsCount
 number of buttons (may be more then 32)
int controlCount
 number of analog controls
int * buttArray
 array with binary coded configuration of buttons
float * ctrlArray
 array with analog values of controls
int * buttArray
 array with binary coded configuration of buttons
float * ctrlArray
 array with analog values of controls


Detailed Description

Flystick2 Body format data structure.

Definition at line 256 of file bodies.h.


Constructor & Destructor Documentation

FlyStick2::FlyStick2 ( int  id,
float  qu,
int  buttons,
int  controls,
float *  shift = NULL,
float *  rotation = NULL 
)

Constructor.

Parameters:
id Device identificator.
qu Quality parameter of visibility
buttons Number of buttons.
controls Number of analog controls.
shift Shift vector (constructor makes a copy)
rotation Rotaiton matrix (constructor makes a copy)

Definition at line 171 of file bodies.cpp.

00172 : Body(id, qu, Body::B6DF2, shift, rotation)
00173 {
00174        buttonsCount = buttons;
00175        int arrsize = buttons / 32 + 1; // max 32 buttons in 1 configuration
00176        controlCount = controls;
00177        this->buttArray = new int[arrsize];
00178        this->ctrlArray = new float[controls];
00179 }

FlyStick2::~FlyStick2 (  ) 

Destructor.

Definition at line 180 of file bodies.cpp.

00181 {
00182        delete [] buttArray;
00183        delete [] ctrlArray;
00184 }

FlyStick2::FlyStick2 ( int  id,
float  qu,
int  buttons,
int  controls,
float *  shift = NULL,
float *  rotation = NULL 
)

Constructor.

Parameters:
id Device identificator.
qu Quality parameter of visibility
buttons Number of buttons.
controls Number of analog controls.
shift Shift vector (constructor makes a copy)
rotation Rotaiton matrix (constructor makes a copy)

FlyStick2::~FlyStick2 (  ) 

Destructor.


Member Function Documentation

void FlyStick2::addButtons ( int  pos,
int  config 
)

Add configuration of max 32 buttons.

One integer number (4Bytes == 32 bits) can carry 32 buttons. Method saves this 32 buttons configuration into an array on position specified with parameter

Parameters:
pos - Position where to store configuration (like index to array: range - from 0 to size - 1)
config - Configuration of max 32 buttons coded in binary format

Definition at line 185 of file bodies.cpp.

00186 {
00187        if ((0 <= pos) && (pos < buttonsCount ))
00188        {
00189               buttArray[pos] = config;
00190        }
00191 }

void FlyStick2::addControls ( int  pos,
float  value 
)

Add analog control value to array.

Parameters:
pos Position where to put a value into array (range - from 0 to size - 1)
value Value to be set to control

Definition at line 192 of file bodies.cpp.

00193 {
00194        if ((0 <= pos) && (pos < controlCount ))
00195        {
00196               ctrlArray[pos] = value;
00197        }
00198 }

int FlyStick2::Button ( int  num  )  [virtual]

Returns whether the button is switched on or off.

Returns 1 if button is pressed
Returns 0 if button is not pressed
returns -10 if button is not in scope or device is not equiped with buttons

Parameters:
num Number of button you want to find out its state

Reimplemented from Body.

Definition at line 212 of file bodies.cpp.

00213 {
00214        if ((0 <= num) && (num < buttonsCount))
00215        {
00216               int index = num / 32; // number of index to array
00217               int shift = num % 32; // shift of mask
00218               int mask = 0x01;
00219               mask = mask << shift;
00220               if ( 0 != (mask & buttArray[index])) return 1;
00221               else return 0;
00222        }
00223        else return - 10;
00224 }

int FlyStick2::ButonsNumber (  )  [virtual]

Returns the number of buttons.

Reimplemented from Body.

Definition at line 199 of file bodies.cpp.

00200 {
00201        return buttonsCount;
00202 }

int FlyStick2::ButtonsMask32 (  )  [virtual]

returns mask of first 32 buttons

Reimplemented from Body.

Definition at line 233 of file bodies.cpp.

00234 {
00235        return this->buttArray[0];
00236 }

int FlyStick2::ControlsNuber (  )  [virtual]

Returns the number of analog controls.

Reimplemented from Body.

Definition at line 203 of file bodies.cpp.

00204 {
00205        return controlCount;
00206 }

float FlyStick2::Control ( int  num  )  [virtual]

Returns the value of specified analog control.

Parameters:
num - The number of analog control if num is out of scope -10 returned

Reimplemented from Body.

Definition at line 207 of file bodies.cpp.

00208 {
00209        if ((0 <= num) && (num < controlCount))   return ctrlArray[num];
00210        else return -10.0;
00211 }

void FlyStick2::addButtons ( int  pos,
int  config 
)

Add configuration of max 32 buttons.

One integer number (4Bytes == 32 bits) can carry 32 buttons. Method saves this 32 buttons configuration into an array on position specified with parameter

Parameters:
pos - Position where to store configuration (like index to array: range - from 0 to size - 1)
config - Configuration of max 32 buttons coded in binary format

void FlyStick2::addControls ( int  pos,
float  value 
)

Add analog control value to array.

Parameters:
pos Position where to put a value into array (range - from 0 to size - 1)
value Value to be set to control

virtual int FlyStick2::Button ( int  num  )  [virtual]

Returns whether the button is switched on or off.

Returns 1 if button is pressed
Returns 0 if button is not pressed
returns -10 if button is not in scope or device is not equiped with buttons

Parameters:
num Number of button you want to find out its state

Reimplemented from Body.

virtual int FlyStick2::ButonsNumber (  )  [virtual]

Returns the number of buttons.

Reimplemented from Body.

virtual int FlyStick2::ButtonsMask32 (  )  [virtual]

returns mask of first 32 buttons

Reimplemented from Body.

virtual int FlyStick2::ControlsNuber (  )  [virtual]

Returns the number of analog controls.

Reimplemented from Body.

virtual float FlyStick2::Control ( int  num  )  [virtual]

Returns the value of specified analog control.

Parameters:
num - The number of analog control if num is out of scope -10 returned

Reimplemented from Body.


Member Data Documentation

int FlyStick2::buttonsCount [protected]

number of buttons (may be more then 32)

Definition at line 260 of file bodies.h.

int FlyStick2::controlCount [protected]

number of analog controls

Definition at line 262 of file bodies.h.

int* FlyStick2::buttArray [protected]

array with binary coded configuration of buttons

Definition at line 264 of file bodies.h.

float* FlyStick2::ctrlArray [protected]

array with analog values of controls

Definition at line 266 of file bodies.h.

int* FlyStick2::buttArray [protected]

array with binary coded configuration of buttons

Definition at line 264 of file bodies.h.

float* FlyStick2::ctrlArray [protected]

array with analog values of controls

Definition at line 266 of file bodies.h.


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

Generated on Tue Mar 10 14:41:38 2009 for VRUT by  doxygen 1.5.5