Subversion Repositories Kolibri OS

Rev

Rev 5996 | Rev 7182 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #ifndef INCLUDE_MOUSE_H
  2. #define INCLUDE_MOUSE_H
  3.  
  4. //Button MOUSE
  5. #define MOUSE_LEFT   001b
  6. #define MOUSE_RIGHT  010b
  7. #define MOUSE_LR     011b
  8. #define MOUSE_CENTER 100b
  9.  
  10. /**
  11.  *  The structure of the MOUSE
  12.  *  x - coordinate X
  13.  *  y - coordinate Y
  14.  *  xx and yy - time coordinates
  15.  *  lkm - left MOUSE button
  16.  *  pkm - right MOUSE button
  17.  *  mkm - MOUSE wheel
  18.  *  key - keycode button
  19.  *  tmp - time keycode
  20.  *  down - key event press
  21.  *  up - key release events
  22.  *  move - event MOUSE movements
  23.  *  click - when clicked
  24.  *  dblclick - double-click get system value
  25.  *  drag - drag the element event
  26.  */
  27.  
  28. :dword __TMP_TIME,DOUBLE_CLICK_DELAY;
  29. :struct MOUSE
  30. {
  31.         signed x,y,xx,yy,lkm,mkm,pkm,key,tmp,tmp_time,hor,vert,down,up,move,click,dblclick,drag,left,top;
  32.         dword handle,_;
  33.         byte cmd;
  34.         void clearTime();
  35.         void get();
  36.         void set();
  37.         void center();
  38.         dword hide();
  39.         void slider();
  40.         void show();
  41. } mouse;
  42. :void MOUSE::clearTime()
  43. {
  44.         tmp_time = GetStartTime()+DOUBLE_CLICK_DELAY;
  45. }
  46. :void MOUSE::show()
  47. {
  48.         if(!handle)return;
  49.         ECX = handle;
  50.         EAX = 37;
  51.         EBX = 5;
  52.         $int 0x40;
  53. }
  54. :dword MOUSE::hide()
  55. {
  56.         if(!_)
  57.         {
  58.                 EAX = 68;
  59.                 EBX = 12;
  60.                 ECX = 32*32*4;
  61.                 $int 0x40
  62.                 ECX = EAX;
  63.                 _ = EAX;
  64.         } else ECX = _;
  65.         EAX = 37;
  66.         EBX = 4;
  67.         DX  = 2;
  68.         $int 0x40;
  69.         handle = EAX;
  70.         ECX = EAX;
  71.         EAX = 37;
  72.         EBX = 5;
  73.         $int 0x40;
  74.         handle = EAX;
  75. }
  76.  
  77. //set new attributes MOUSE
  78. :void MOUSE::set()
  79. {
  80.         if((xx!=x)||(yy!=y))
  81.         {
  82.                 EAX = 18;
  83.                 EBX = 19;
  84.                 ECX = 4;
  85.                 EDX = (x<<16)+y;
  86.                 $int 0x40
  87.                 //move = true;
  88.         }
  89.         if((key)||(lkm|mkm|pkm))&&(down|up|click|dblclick|move)
  90.         {
  91.                 if(lkm|mkm|pkm)key=(lkm)|(pkm<<1)|(2<<mkm);
  92.                 EAX = 18;
  93.                 EBX = 19;
  94.                 ECX = key;
  95.                 EDX = (x<<16)+y;
  96.                 $int 0x40
  97.         }
  98. }
  99.  
  100. :void MOUSE::center()
  101. {
  102.         EAX = 18;
  103.         EBX = 15;
  104.         $int 0x40
  105. }
  106.  
  107. //get new attributes MOUSE
  108. :void MOUSE::get()
  109. {
  110.         EAX = 37;
  111.         EBX = 1;
  112.         $int    0x40
  113.         $mov    ebx, eax
  114.         $shr    eax, 16
  115.         $and    ebx,0x0000FFFF
  116.         x = EAX;
  117.         y = EBX;
  118.         if (x>6000) x-=65535;
  119.         if (y>6000) y-=65535;
  120.         EAX = 37;
  121.         EBX = 2;
  122.         $int    0x40
  123.         $mov    ebx, eax
  124.         $mov    ecx, eax
  125.         key = EAX;
  126.         $and    eax, 0x00000001
  127.         $shr    ebx, 1
  128.         $and    ebx, 0x00000001
  129.         $shr    ecx, 2
  130.         $and    ecx, 0x00000001
  131.         lkm = EAX;
  132.         pkm = EBX;
  133.         mkm = ECX;
  134.        
  135.         //when you release the MOUSE button
  136.         // Mouse Move Event
  137.         if(xx!=x)||(yy!=y)
  138.         {
  139.                 move = true;
  140.                 xx = x;
  141.                 yy = y;
  142.         }
  143.         else move = false;
  144.         // Mouse Up Event
  145.         if(cmd)&&(!key){
  146.                 up   = true;
  147.                 down = false;
  148.                 drag = false;
  149.                 if(!move) click = true;
  150.                 __TMP_TIME = GetStartTime();
  151.                 if(__TMP_TIME-tmp_time<=DOUBLE_CLICK_DELAY)
  152.                 {
  153.                         dblclick = true;
  154.                         click    = false;
  155.                 }
  156.                 tmp_time = __TMP_TIME;
  157.                 //returns the key code
  158.                 key = tmp;
  159.                 lkm = 1&tmp;
  160.                 pkm = 2&tmp;
  161.                 pkm >>= 1;
  162.                 mkm = 4&tmp;
  163.                 mkm >>= 2;
  164.                 cmd = false;
  165.         }
  166.        
  167.         //when you press the MOUSE button
  168.         // Mouse Down Event/Move Event
  169.         else
  170.         {
  171.             up       = false;
  172.                 click    = false;
  173.                 dblclick = false;
  174.                 down     = false;
  175.                 // Mouse Move Event
  176.                 if(key)if(!cmd)
  177.                 {
  178.                         down = true;
  179.                         if(move)drag = true;
  180.                         cmd = true;
  181.                         tmp=key;
  182.                 }
  183.         }
  184.        
  185.         //scroll
  186.         EAX = 37;
  187.         EBX = 7;
  188.         $int    0x40
  189.         $mov    ebx, eax
  190.         $shr    eax, 16
  191.         $and    ebx,0x0000FFFF
  192.         //hor = EAX;
  193.         vert = EBX;
  194. }
  195.  
  196.  
  197.  
  198. :void MOUSE::slider()
  199. {
  200.         signed _x,_y;
  201.         if(!handle)hide();
  202.         get();
  203.         _x = x;_y = y;
  204.         pause(5);
  205.         get();
  206.         left = _x - x;
  207.         top  = _y - y;
  208.         center();
  209.         get();
  210.         _x = x;_y = y;
  211.         pause(5);
  212. }
  213.  
  214.  
  215. /*=====================================================================================
  216. ===========================                                 ===========================
  217. ===========================              SYSTEM             ===========================
  218. ===========================                                 ===========================
  219. =====================================================================================*/
  220.  
  221.  
  222. inline fastcall int GetMouseSpeed() {
  223.         $mov eax,18
  224.         $mov ebx,19
  225.         $mov ecx,0
  226.         $int 0x40
  227. }
  228.  
  229. inline fastcall void SetMouseSpeed(EDX) {
  230.         $mov eax,18
  231.         $mov ebx,19
  232.         $mov ecx,1
  233.         $int 0x40
  234. }
  235.  
  236. inline fastcall int GetMouseAcceleration() {
  237.         $mov eax,18
  238.         $mov ebx,19
  239.         $mov ecx,2
  240.         $int 0x40
  241. }
  242.  
  243. inline fastcall void SetMouseAcceleration(EDX) {
  244.         $mov eax,18
  245.         $mov ebx,19
  246.         $mov ecx,3
  247.         $int 0x40
  248. }
  249.  
  250. inline fastcall int GetMouseDoubleClickDelay() {
  251.         $mov eax,18
  252.         $mov ebx,19
  253.         $mov ecx,6
  254.         $int 0x40
  255. }
  256.  
  257. inline fastcall void SetMouseDoubleClickDelay(DL) {
  258.         $mov eax,18
  259.         $mov ebx,19
  260.         $mov ecx,7
  261.         $int 0x40
  262. }
  263.  
  264. #endif