Diff for /np2/macosx/mousemng.cpp between versions 1.3 and 1.6

version 1.3, 2003/10/20 10:14:27 version 1.6, 2003/11/12 19:56:50
Line 1 Line 1
 #if defined(NP2GCC)  
 #include        "compiler.h"  #include        "compiler.h"
 #include        "np2.h"  #include        "np2.h"
 #include        "mousemng.h"  #include        "mousemng.h"
   
   
 static  BYTE    mouserunning = 0;  typedef struct {
 static  BYTE    lastmouse = 0;          SINT16  x;
 static  short   mousex = 0;          SINT16  y;
 static  short   mousey = 0;          BYTE    btn;
 static  BYTE    mouseb = 0xa0;          UINT    flag;
   } MOUSEMNG;
   
   static  MOUSEMNG        mousemng;
   
 static void getmaincenter(Point *cp) {  
   
         Rect    rct;  BYTE mousemng_getstat(SINT16 *x, SINT16 *y, int clear) {
   
         GetWindowBounds(hWndMain, kWindowContentRgn, &rct);          *x = mousemng.x;
         cp->h = (rct.right + rct.left) / 2;          *y = mousemng.y;
         cp->v = (rct.bottom + rct.top) / 2;          if (clear) {
                   mousemng.x = 0;
                   mousemng.y = 0;
           }
           return(mousemng.btn);
 }  }
   
   // ----
   
 void mouseonoff(BYTE flg) {  static void SetMouse(const Point *cp) {
   
         Point   cp;          CGPoint pt;
   
         if ((lastmouse ^ flg) & 1) {          pt.x = (float)cp->h;
                 lastmouse = (flg & 1);          pt.y = (float)cp->v;
                 if (lastmouse & 1) {          CGWarpMouseCursorPosition(pt);
             HideCursor();  
                         getmaincenter(&cp);  
             CGWarpMouseCursorPosition(CGPointMake(cp.h, cp.v));  
                 }  
         else {  
             ShowCursor();  
         }  
         }  
 }  }
   
 // ---------------------------------------------------------------------------  static void getmaincenter(Point *cp) {
   
 BYTE mouse_flag(void) {          Rect    rct;
   
         return(mouserunning);          GetWindowBounds(hWndMain, kWindowContentRgn, &rct);
           cp->h = (rct.right + rct.left) / 2;
           cp->v = (rct.bottom + rct.top) / 2;
 }  }
   
   static void mousecapture(BOOL capture) {
   
 void mouse_running(BYTE flg) {          Point   cp;
   
         BYTE    mf = mouserunning;  
   
         switch(flg & 0xc0) {          if (capture) {
                 case 0x00:                  HideCursor();
                         mf &= ~(1 << (flg & 7));                  getmaincenter(&cp);
                         break;                  SetMouse(&cp);
                 case 0x40:  
                         mf ^= (1 << (flg & 7));  
                         break;  
                 default:  
                         mf |= (1 << (flg & 7));  
                         break;  
         }          }
         if ((mf ^ mouserunning) & MOUSE_MASK) {          else {
                 mouserunning = (mf & MOUSE_MASK);                  ShowCursor();
                 if (mouserunning == 1) {  
                         mouseonoff(1);  
                 }  
                 else {  
                         mouseonoff(0);  
                 }  
         }          }
 }  }
   
   void mousemng_initialize(void) {
   
           ZeroMemory(&mousemng, sizeof(mousemng));
           mousemng.btn = uPD8255A_LEFTBIT | uPD8255A_RIGHTBIT;
           mousemng.flag = (1 << MOUSEPROC_SYSTEM);
   }
   
 void mouse_callback(void) {  void mousemng_callback(HIPoint delta) {
   
         Point   cp;          Point   cp;
     CGMouseDelta        x,y;  
     static      CGMouseDelta    pastx=0,pasty=0;  
   
         if (lastmouse & 1) {          if (!mousemng.flag) {
         CGGetLastMouseDelta(&x, &y);          getmaincenter(&cp);
         if ((pastx!=x) && (pasty!=y)) {          mousemng.x += (SINT16)delta.x;
             mousex += (short)x;          mousemng.y += (SINT16)delta.y;
             mousey += (short)y;          SetMouse(&cp);
             pastx = x;  
             pasty = y;  
             getmaincenter(&cp);  
             CGWarpMouseCursorPosition(CGPointMake(cp.h, cp.v));  
        }  
         }          }
 }  }
   
   BOOL mousemng_buttonevent(UINT event) {
   
 BYTE mousemng_getstat(short *x, short *y, int clear) {          if (!mousemng.flag) {
                   switch(event) {
                           case MOUSEMNG_LEFTDOWN:
                                   mousemng.btn &= ~(uPD8255A_LEFTBIT);
                                   break;
   
         *x = mousex;                          case MOUSEMNG_LEFTUP:
         *y = mousey;                                  mousemng.btn |= uPD8255A_LEFTBIT;
         if (clear) {                                  break;
                 mousex = 0;  
                 mousey = 0;                          case MOUSEMNG_RIGHTDOWN:
                                   mousemng.btn &= ~(uPD8255A_RIGHTBIT);
                                   break;
   
                           case MOUSEMNG_RIGHTUP:
                                   mousemng.btn |= uPD8255A_RIGHTBIT;
                                   break;
                   }
                   return(TRUE);
           }
           else {
                   return(FALSE);
         }          }
         return(mouseb);  
 }  }
   
   void mousemng_enable(UINT proc) {
   
           UINT    bit;
   
 BYTE mouse_btn(BYTE btn) {          bit = 1 << proc;
           if (mousemng.flag & bit) {
         if (!(lastmouse & 1)) {                  mousemng.flag &= ~bit;
                 return(0);                  if (!mousemng.flag) {
         }                          mousecapture(TRUE);
         switch(btn) {                  }
                 case MOUSE_LEFTDOWN:  
                         mouseb &= 0x7f;  
                         break;  
                 case MOUSE_LEFTUP:  
                         mouseb |= 0x80;  
                         break;  
                 case MOUSE_RIGHTDOWN:  
                         mouseb &= 0xdf;  
                         break;  
                 case MOUSE_RIGHTUP:  
                         mouseb |= 0x20;  
                         break;  
         }          }
         return(1);  
 }  }
   
 #else  void mousemng_disable(UINT proc) {
 #include        "compiler.h"  
 #include        "mousemng.h"  
   
           if (!mousemng.flag) {
                   mousecapture(FALSE);
           }
           mousemng.flag |= (1 << proc);
   }
   
 BYTE mousemng_getstat(SINT16 *x, SINT16 *y, int clear) {  void mousemng_toggle(UINT proc) {
   
         *x = 0;          if (!mousemng.flag) {
         *y = 0;                  mousecapture(FALSE);
         (void)clear;          }
         return(0xa0);          mousemng.flag ^= (1 << proc);
           if (!mousemng.flag) {
                   mousecapture(TRUE);
           }
 }  }
   
 #endif  
   

Removed from v.1.3  
changed lines
  Added in v.1.6


RetroPC.NET-CVS <cvs@retropc.net>