Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

dev.C

Go to the documentation of this file.
00001 // dev.C
00002 
00003 #include "dev.H"
00004 
00005 using namespace mlib;
00006 
00007 DEVmod_desc_list   DEVmod_gen::_mods;
00008 DEVmod_gen        *DEVmod_gen::_gen         = 0;
00009 Evd::DEVmod        DEVmod_gen::_forced_mods = Evd::EMPTY;
00010 
00011 DEVice_2d *DEVice_2d::last = 0;
00012 
00013 // Wtransf DEVice::booth_to_room;
00014 // Wtransf DEVice::room_to_booth;
00015 
00016 void
00017 DEVice_2d_absrel::up(
00018    )
00019 {
00020   _down_flag = false;
00021 }
00022 
00023 void
00024 DEVice_2d_absrel::down(
00025    )
00026 {
00027   _down_flag  = true;
00028   _first_down = true;
00029 }
00030 
00031 void
00032 DEVice_2d_absrel::_event(
00033    CXYpt        &p,
00034    Evd::DEVmod  mod
00035    )
00036 {
00037   _cur_abs_pos = p;
00038 
00039   if (_first_down) { // hack since tablet doesn't report events when just 
00040                      // above the surface..
00041     _first_down  = false;
00042     _old_abs_pos = _cur_abs_pos;
00043   }
00044 
00045   if ( _rel_flag && _down_flag) {
00046      _logical_pos += (_cur_abs_pos - _old_abs_pos);
00047      _old_abs_pos = _cur_abs_pos;
00048   }
00049 
00050   if (!_rel_flag)
00051     _logical_pos  = _cur_abs_pos;
00052 
00053   DEVice_2d::_event(_logical_pos, mod);
00054 }
00055 
00056 void
00057 print_bits( char *buf, int num_bytes )
00058 {
00059   for(int i=0;i<num_bytes;i++) {
00060     for(int b=0;b<8;b++)
00061       cerr << (((1 << b) & ((int)buf[i])) ? 1 : 0);
00062     cerr << " ";
00063   }
00064   cerr << endl;
00065 }
00066 
00067 
00068 Evd::DEVmod
00069 DEVmod_gen::mods()
00070 {
00071    Evd::DEVmod mods = Evd::EMPTY;
00072 
00073    for (int m = 0; m < _mods.num(); m++) {
00074       DEVice_buttons *btns = _mods[m].ice();
00075       if (btns->get(_mods[m].btn_ind()))
00076          mods = Evd::DEVmod(((int)mods) | (int)(_mods[m].mod()));
00077    }
00078 
00079    Evd::DEVmod gmods = Evd::EMPTY;
00080    if (_gen)
00081       gmods = _gen->gen_mods();
00082 
00083    mods = Evd::DEVmod(((int)mods) | ((int)gmods) | ((int)_forced_mods));
00084 
00085    if (mods == Evd::EMPTY)
00086       mods = Evd::NONE;
00087 
00088    return mods;
00089 }

Generated on Mon Sep 18 11:39:29 2006 for jot by  doxygen 1.4.4