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

  1. /**
  2. *
  3. * Name        moequip -- Sense presence of Microsoft-compatible mouse
  4. *               driver
  5. *
  6. * Synopsis    result = moequip();
  7. *
  8. *        int result      Result code:
  9. *                  number of buttons if installed;
  10. *                  0 if mouse driver not installed.
  11. *
  12. * Description    This function senses the presence of
  13. *        Microsoft-compatible mouse driver software.  If the
  14. *        driver software is found, it is safe to conclude that
  15. *        the mouse is also installed, because the mouse driver
  16. *        searches for the mouse when starting.
  17. *
  18. *        The first time this function is called, it initializes
  19. *        the driver.
  20. *
  21. * Returns    result,b_mouse      Number of mouse buttons (0 if no driver).
  22. *
  23. * Version    6.00 (C)Copyright Blaise Computing Inc.  1989
  24. *
  25. **/
  26.  
  27. #include <dos.h>              /* For int86x(), REGS.          */
  28.  
  29. #include <bintrupt.h>
  30. #include <bmouse.h>
  31.  
  32. int b_mouse = MO_UNKNOWN;     /* Mouse presence:  MO_UNKNOWN,          */
  33.                   /*   0 if absent, or number of buttons. */
  34.  
  35. int moequip()
  36. {
  37.     const unsigned char far *pvector;
  38.     union REGS             inregs,outregs;
  39.  
  40.     if (b_mouse == MO_UNKNOWN)
  41.     {
  42.                       /* Check interrupt 0x33:          */
  43.                       /*   absent if NIL or IRET.     */
  44.     pvector = isgetvec(0x33);
  45.     if (pvector == FARNIL || *pvector == 0xcf)
  46.         b_mouse = MO_ABSENT;
  47.     else
  48.     {                  /* Test for driver presence by  */
  49.         inregs.x.ax = 0;          /* initializing the driver.     */
  50.         inregs.x.bx = 0;
  51.         int86(0x33,&inregs,&outregs);
  52.  
  53.         if (outregs.x.ax == 0)
  54.         b_mouse = 0;          /* AX unchanged if no driver.   */
  55.         else
  56.                       /* Number of buttons.          */
  57.         b_mouse = ((outregs.x.bx == 0xffff) ? 2 : outregs.x.bx);
  58.     }
  59.     }
  60.  
  61.     return b_mouse;
  62. }
  63.