home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / MOPRECLK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  2.2 KB  |  92 lines

  1. /**
  2. *
  3. * Name        mopreclk -- Install or remove MOCATCH to catch mouse
  4. *                button presses and releases.
  5. *
  6. * Synopsis    ercode = mopreclk(option);
  7. *
  8. *        int ercode      Error return code:
  9. *                    MO_OK if successful;
  10. *                    MO_ABSENT if mouse not found;
  11. *                    MO_ALREADY if already installed
  12. *                      and MO_INSTALL is specified;
  13. *                    MO_NOT_INSTALLED if not installed
  14. *                      and MO_REMOVE is specified;
  15. *                    MO_BAD_OPT if option code
  16. *                      not recognized.
  17. *
  18. *        int option      MO_INSTALL or MO_REMOVE.
  19. *
  20. * Description    This function installs or removes MOCATCH.  (MOCATCH
  21. *        monitors mouse button presses and releases and maintains
  22. *        b_mohist[], the history of button events.)
  23. *
  24. * Returns    ercode          Error return code:
  25. *                    MO_OK if successful;
  26. *                    MO_ABSENT if mouse not found;
  27. *                    MO_ALREADY if already installed
  28. *                      and MO_INSTALL is specified;
  29. *                    MO_NOT_INSTALLED if not installed
  30. *                      and MO_REMOVE is specified;
  31. *                    MO_BAD_OPT if option not
  32. *                      recognized.
  33. *        b_mouse       Number of mouse buttons (0 if no driver).
  34. *        b_mocatch      Address of MOCATCH if MOCATCH installed,
  35. *                    zero if not installed.
  36. *        b_momask      MOCATCH's call mask if MOCATCH installed,
  37. *                    zero if not installed.
  38. *
  39. * Version    6.00 (C)Copyright Blaise Computing Inc.  1989
  40. *
  41. **/
  42.  
  43. #include <bmouse.h>
  44.  
  45. int far mopreclk(option)
  46. int option;
  47. {
  48.     int result;
  49.  
  50.     switch (option)
  51.     {
  52.     case MO_INSTALL:
  53.         if (b_mocatch)
  54.         result = MO_ALREADY;
  55.         else
  56.         {
  57.                   /* Use combined call mask that          */
  58.                   /* encompasses MOCATCH and user          */
  59.                   /* interrupt handler, if any.          */
  60.         result = moinst(mocatch,MOCATCH_MASK | b_mohanmask);
  61.         if (result == MO_OK)
  62.         {
  63.             b_mocatch = mocatch;
  64.             b_momask  = MOCATCH_MASK;
  65.         }
  66.         }
  67.         break;
  68.  
  69.     case MO_REMOVE:
  70.         if (b_mocatch)
  71.         {
  72.                   /* Reinstall user handler (if any).     */
  73.         result = moinst((void (far *)(void)) b_modispat,
  74.                 b_mohanmask);
  75.         if (result == MO_OK)
  76.         {
  77.             b_mocatch = 0;
  78.             b_momask  = 0;
  79.         }
  80.         }
  81.         else
  82.         result = MO_NOT_INSTALLED;
  83.         break;
  84.  
  85.     default:
  86.         result = MO_BAD_OPT;
  87.         break;
  88.     }
  89.  
  90.     return result;
  91. }
  92.