• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

src/window/header/MouseDevice.h

Go to the documentation of this file.
00001 
00002 extern ::MouseMap mouseMap;
00003 
00004 NAMESPACE_START
00005 
00007 struct MouseInput {
00008         int dz,dx,dy,absX,absY;
00009         bool btnsUp[6];
00010 };
00011 
00013 class MouseDevice :
00014         public ::MouseDevice {
00015 public:
00016         MouseDevice();
00017         virtual ~MouseDevice();
00018 
00019         inline void addDz(int dz){input[writeTarget].dz += dz;}
00020         inline void addDx(int dx){input[writeTarget].dx += dx;}
00021         inline void addDy(int dy){input[writeTarget].dy += dy;}
00022 
00023         inline void setDz(int dz){input[writeTarget].dz = dz;}
00024         inline void setDx(int dx){input[writeTarget].dx = dx;}
00025         inline void setDy(int dy){input[writeTarget].dy = dy;}
00026         inline void setAbsX(int absX){input[writeTarget].absX = absX;}
00027         inline void setAbsY(int absY){input[writeTarget].absY = absY;}
00028         inline void setBtnsDown(::MOUSEBTN btn, bool b){this->btnsDown[btn] = b;}
00029         inline void setBtnsUp(::MOUSEBTN btn, bool b){input[writeTarget].btnsUp[btn] = b;}
00030         inline void setChanged(bool b){this->change = b;}
00031         
00032         inline int getDz(void){return input[readTarget].dz;}
00033         inline int getDx(void){return input[readTarget].dx;}
00034         inline int getDy(void){return input[readTarget].dy;}
00035         inline int getAbsX(void){return input[readTarget].absX;}
00036         inline int getAbsY(void){return input[readTarget].absY;}
00037         inline bool getBtnsDown(::MOUSEBTN btn){return this->btnsDown[btn];}
00038         inline bool getBtnsUp(::MOUSEBTN btn){return input[readTarget].btnsUp[btn];}
00039         inline bool getChanged(void){return this->change;}
00040 
00041         inline void reset(void){
00042                 input[readTarget].dz = 0;
00043                 input[readTarget].dx = 0;
00044                 input[readTarget].dy = 0;
00045                 input[readTarget].absX = 0;
00046                 input[readTarget].absY = 0;
00047                 input[readTarget].btnsUp[mouseMap.mouseL] = false;
00048                 input[readTarget].btnsUp[mouseMap.mouseM] = false;
00049                 input[readTarget].btnsUp[mouseMap.mouseR] = false;
00050                 input[readTarget].btnsUp[mouseMap.mouse4] = false;
00051                 input[readTarget].btnsUp[mouseMap.mouse5] = false;
00052         }
00053 
00054         inline void copy(void){
00055                 // copy input data
00056                 this->dz = getDz();
00057                 this->dx = getDx();
00058                 this->dy = getDy();
00059                 POINT point;
00060                 GetCursorPos(&point);
00061                 this->absX = point.x;
00062                 this->absY = point.y;
00063                 this->btnsUp[mouseMap.mouseL] = getBtnsUp(mouseMap.mouseL);
00064                 this->btnsUp[mouseMap.mouseM] = getBtnsUp(mouseMap.mouseM);
00065                 this->btnsUp[mouseMap.mouseR] = getBtnsUp(mouseMap.mouseR);
00066                 this->btnsUp[mouseMap.mouse4] = getBtnsUp(mouseMap.mouse4);
00067                 this->btnsUp[mouseMap.mouse5] = getBtnsUp(mouseMap.mouse5);
00068                 this->change = false;
00069         }
00070 
00071         void update(bool reset);
00072 
00073 	::pMouseDevice asMouseDevice(){return this;}
00074 
00075 private:
00076         MouseInput input[2];
00077         int writeTarget;
00078         int readTarget;
00079 };
00080 
00081 NAMESPACE_END

Generated on Fri Jun 18 2010 17:48:40 for Cannonball by  doxygen 1.7.0