home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / dm14.lzh / mouse.c < prev    next >
Text File  |  1996-08-03  |  2KB  |  81 lines

  1. /* mouse.c function for DISKMASTER.C          */
  2. /* copyright (c) 1995 by Bob Devries          */
  3. /* email: bdevries@gil.ipswichcity.qld.gov.au */
  4.  
  5. /* adds mouse support to DiskMaster           */
  6.  
  7. #include "diskmaster.h"
  8.  
  9. int
  10. readmouse(pos, ch)
  11. int *pos;
  12. int *ch;
  13. {
  14.        int leftbut, rightbut, xpos, ypos;
  15.  
  16. #ifndef MM1
  17.        if(!MsReady()) {
  18.            return 0;
  19.        }
  20. #endif
  21. #ifdef MM1
  22. #include <mouse.h>
  23.        MSRET ms;
  24.        _gs_mouse(STDOUT,&ms);
  25.        if (ms.pt_valid == 0) {
  26.            return(0);
  27.        }
  28. #endif
  29.        
  30.        *ch = 0;
  31.        
  32. #ifdef MM1
  33.        leftbut = (int)ms.pt_cbsa;
  34.        rightbut = (int)ms.pt_cbsc;
  35.        xpos = ms.pt_acx/8+1;    /* MM1 has 8*8 fonts? */
  36.        ypos = ms.pt_acy/8+1  ;  /*      "    "        */
  37. #else
  38.        MsRdAbs(&leftbut, &rightbut, &xpos, &ypos);
  39.        gotoxy(xpos,ypos);
  40. #endif
  41.  
  42.        if(leftbut == 1) {
  43.               if((xpos > 1) && (xpos < 48)) {
  44.                      if((ypos > 2) && (ypos < 23)) {
  45.                             *pos = ypos - 3;
  46.                      }
  47.               }
  48.               if (ypos == 24) {
  49.                      if ((xpos >  1) && (xpos <  6)) *ch = 'a';
  50.                      if ((xpos >  6) && (xpos < 11)) *ch = 'c';
  51.                      if ((xpos > 11) && (xpos < 18)) *ch = 'r';
  52.                      if ((xpos > 18) && (xpos < 22)) *ch = 'd';
  53.                      if ((xpos > 22) && (xpos < 29)) *ch = 'n';
  54.                      if ((xpos > 29) && (xpos < 36)) *ch = 'm';
  55.                      if ((xpos > 36) && (xpos < 41)) *ch = 'o';
  56.                      if ((xpos > 41) && (xpos < 51)) *ch = 't';
  57.                      if ((xpos > 51) && (xpos < 56)) *ch = 'l';
  58.                      if ((xpos > 56) && (xpos < 62)) *ch = 'u';
  59.                      if ((xpos > 62) && (xpos < 67)) *ch = 'h';
  60.                      if ((xpos > 67) && (xpos < 72)) *ch = 'q';
  61.                      if ((xpos > 72) && (xpos < 78)) *ch = 's';
  62.               }
  63.        }
  64.        if(rightbut == 1) {
  65.               if((xpos > 1) && (xpos < 48)) {
  66.                      if((ypos > 2) && (ypos < 23)) {
  67.                             *pos = ypos - 3;
  68.                             *ch = '\n';
  69.                      } else {
  70.                             if (ypos == 2) {
  71.                                    *ch = PgUp;
  72.                             } else if (ypos == 23) {
  73.                                    *ch = PgDn;
  74.                             }
  75.                      }
  76.               }
  77.        }
  78. }
  79.  
  80. /* EOF mouse.c */
  81.