home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name moequip -- Sense presence of Microsoft-compatible mouse
- * driver
- *
- * Synopsis result = moequip();
- *
- * int result Result code:
- * number of buttons if installed;
- * 0 if mouse driver not installed.
- *
- * Description This function senses the presence of
- * Microsoft-compatible mouse driver software. If the
- * driver software is found, it is safe to conclude that
- * the mouse is also installed, because the mouse driver
- * searches for the mouse when starting.
- *
- * The first time this function is called, it initializes
- * the driver.
- *
- * Returns result,b_mouse Number of mouse buttons (0 if no driver).
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1989
- *
- **/
-
- #include <dos.h> /* For int86x(), REGS. */
-
- #include <bintrupt.h>
- #include <bmouse.h>
-
- int b_mouse = MO_UNKNOWN; /* Mouse presence: MO_UNKNOWN, */
- /* 0 if absent, or number of buttons. */
-
- int moequip()
- {
- const unsigned char far *pvector;
- union REGS inregs,outregs;
-
- if (b_mouse == MO_UNKNOWN)
- {
- /* Check interrupt 0x33: */
- /* absent if NIL or IRET. */
- pvector = isgetvec(0x33);
- if (pvector == FARNIL || *pvector == 0xcf)
- b_mouse = MO_ABSENT;
- else
- { /* Test for driver presence by */
- inregs.x.ax = 0; /* initializing the driver. */
- inregs.x.bx = 0;
- int86(0x33,&inregs,&outregs);
-
- if (outregs.x.ax == 0)
- b_mouse = 0; /* AX unchanged if no driver. */
- else
- /* Number of buttons. */
- b_mouse = ((outregs.x.bx == 0xffff) ? 2 : outregs.x.bx);
- }
- }
-
- return b_mouse;
- }