Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

trackball.H

Go to the documentation of this file.
00001 #ifndef GLUE_TRACKBALL_H
00002 #define GLUE_TRACKBALL_H
00003 
00004 #include "event/event.H"
00005 #include "dev/dev.H"
00006 #include "dev/room6d.H"
00007 #include "dev/dev2d.H"
00008 
00009 extern DllImpExp cWtransf &Identity;
00010 
00011 class DEV2d_6d_agg: public EVENTfilter {
00012   str_ptr        _tname, _tball_name;
00013   DEVice_room6d *_tkr;
00014   DEVice        *_tball;     // possible real source of button events
00015   EVENTsource    _tball_src; // cached description of button event source
00016   
00017   //Trackball event
00018   //Check to see if trackball exists, and return true if event source exists
00019   bool     tball_evt(cEVENTptr &evt) { 
00020     if (!_tball && !(_tball = DEVice::lookup(_tball_name)) 
00021     && evt->debug_on())
00022       cerr <<"DEVbtn_tracker_agg: can't find Trackball device "
00023        << _tball_name << endl;
00024     return _tball_src.test(*evt->source()) && EVENT2d::isa(evt); 
00025   }
00026   
00027 
00028   //Returns the matrix for the tracker
00029   cWtransf &cur_tracker(bool dbg) { 
00030     if (!_tkr&&!(_tkr=(DEVice_room6d*)DEVice::lookup(_tname))&&dbg)
00031       cerr << "DEVbtn_tracker_agg: can't find tracker device "
00032        << _tname << endl; 
00033     return _tkr ? _tkr->cur() : Identity; 
00034   }
00035 
00036 public:
00037   DEV2d_6d_agg(Cstr_ptr &t, Cstr_ptr &b): 
00038     _tname(t),_tball_name(b),_tkr(0),_tball(0),
00039     _tball_src(_tball_name,0)    { }
00040   virtual ~DEV2d_6d_agg()    { }
00041   
00042   EVENTptr filter(cEVENTptr &evt) {
00043     if (tball_evt(evt)) {
00044       EVENT2dptr  tballevt = EVENT2d::cast(evt);
00045       return new EVENT2d_6d((DEVice_2d *)(tballevt->source()),
00046                 tballevt->old(),
00047                 tballevt->cur(),
00048                 cur_tracker(evt->debug_on()));
00049     }
00050     return evt;
00051   }
00052 };
00053 
00054 #endif

Generated on Mon Sep 15 16:25:57 2003 for gluebase by doxygen1.2.18