Condition Class Reference

A part of class TTable entry to easy evaluate condition of generating transformation matrix;. More...

#include <ttable.h>

List of all members.

Public Member Functions

 Condition (int pressed=0, int released=0, float ctrl1=0, float ctrl2=0)
 Constructor.
 ~Condition ()
 destructor
bool Evaluate (int buttons, float ctr1, float ctr2)
 Evaluate the condition. Returns true if parameters comply with condition.
void Reset (int pressed=0, int released=0, float ctrl1=0, float ctrl2=0)
 Reset parameters of condition.
int PressedMask ()
 returns mask of pressed buttons
int ReleasedMask ()
 returns mask of released buttons
float Control1 ()
 returns treshold value
float Control2 ()
 return treshold value

Private Attributes

int pressedButtonsMask
 Buttons that have to be pressed.
int releasedButtonsMask
 Buttons that must not be pressed.
float control1
 Contro l treshold value1.
float control2
 Control 2 treshold value.


Detailed Description

A part of class TTable entry to easy evaluate condition of generating transformation matrix;.

Note that there are now only two devices using buttons and/or controls: Flystick1 or Flystick2. Each type of flystick can be mapped to other type. But if you use Flystick1 packets to transmit Flystick2 information, you may lose some informations. For more info see Dtrack Flystick documentation.
Each Flystick Device has at most 8 buttons now. But Flystick2 packets are able to transfer much more buttons and controls. Note that Condition class can evaluate state of at most 32 buttons and 2 analog controls.

Definition at line 15 of file ttable.h.


Constructor & Destructor Documentation

Condition::Condition ( int  pressed = 0,
int  released = 0,
float  ctrl1 = 0,
float  ctrl2 = 0 
)

Constructor.

If all parameters are set to null condition is allways evaluated as true

Parameters:
pressed Mask for buttons that have to be pressed.
released Mask for buttons that must not be pressed.
ctrl1 = a treshold value of control 1
ctrl2 = a treshold value of control 2

Definition at line 5 of file ttable.cpp.

00006 {
00007        Reset(pressed, released, ctrl1, ctrl2);
00008 }

Condition::~Condition (  ) 

destructor

Definition at line 9 of file ttable.cpp.

00010 {}


Member Function Documentation

bool Condition::Evaluate ( int  buttons,
float  ctr1,
float  ctr2 
)

Evaluate the condition. Returns true if parameters comply with condition.

Parameters:
buttons Mask of actual state of buttons
ctr1 Analog value of control 1 (Flystick2 joystick left-right)
ctr2 Analog value of control 2 (Flystick2 joystick up-down)

Definition at line 11 of file ttable.cpp.

00012 {
00013        if (((buttons & pressedButtonsMask) == pressedButtonsMask) && (releasedButtonsMask & buttons) == 0)
00014        {
00015               // buttons restrictions are satisfied
00016               if (((control1 < 0) &&  (ctr1 > control1)) || ((control1 >= 0) && (ctr1 < control1)))
00017               {
00018                      // control1 did not reched treshold
00019                      return false;
00020               }
00021               if (((control2 < 0) &&  (ctr2 > control2)) || ((control2 >= 0) && (ctr2 < control2)))
00022               {
00023                      return false;
00024               }
00025               return true; // all restrictions are satisfied
00026        }
00027        else
00028        {
00029               // buttons not satisfied
00030               return false;
00031        }
00032 }

void Condition::Reset ( int  pressed = 0,
int  released = 0,
float  ctrl1 = 0,
float  ctrl2 = 0 
)

Reset parameters of condition.

if all parameters are set to null (or no parameter is set) no restriction is set and condition will be allways evaluated as true

Definition at line 33 of file ttable.cpp.

00034 {
00035        pressedButtonsMask = pressed;
00036        releasedButtonsMask = released;
00037        control1 = ctrl1;
00038        control2 = ctrl2;
00039 }

int Condition::PressedMask (  ) 

returns mask of pressed buttons

Definition at line 40 of file ttable.cpp.

00040 {return pressedButtonsMask;}

int Condition::ReleasedMask (  ) 

returns mask of released buttons

Definition at line 41 of file ttable.cpp.

00041 {return releasedButtonsMask;}

float Condition::Control1 (  ) 

returns treshold value

Definition at line 42 of file ttable.cpp.

00042 {return control1;}

float Condition::Control2 (  ) 

return treshold value

Definition at line 43 of file ttable.cpp.

00043 {return control2;}


Member Data Documentation

Buttons that have to be pressed.

1 button = 1 bit
(pressedButtonsMask and releasedButtonMask both set to null means no restrictions on buttons)

Definition at line 22 of file ttable.h.

Buttons that must not be pressed.

1 button = 1 bit
if there is conflict between pressed and not_pressed button mask (i.e. (pressedButtonsMask & releasedButtonsMask) != 0) this mask will be sot to null (no restriction)
(pressedButtonsMask and releasedButtonMask both set to null means no restrictions on buttons)

Definition at line 29 of file ttable.h.

float Condition::control1 [private]

Contro l treshold value1.

Control can have values from -1 up to +1; If the treshold has negative value a, partial condition on this control is set to true if real control has at most value of the treshold a. If treshold is positive, partial condition on this control is set to true if real control has at least value of treshold. (If treshold is 0, no restriction on this control)

Definition at line 36 of file ttable.h.

float Condition::control2 [private]

Control 2 treshold value.

see control1...

Definition at line 40 of file ttable.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