home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name mobutton -- Report mouse button press/release history
- *
- * Synopsis ercode = mobutton(event,pbuttons,pcount,pvert,phoriz);
- *
- * int ercode Error return code:
- * MO_OK if successful;
- * MO_ABSENT if mouse not found;
- * MO_BAD_OPT if event code not
- * recognized.
- * int event Button event to report, specified
- * by two bit fields:
- *
- * MO_LEFT, MO_RIGHT, or MO_MIDDLE;
- * MO_PRESS or MO_RELEASE.
- *
- * unsigned *pbuttons
- * Returned status of buttons. Any
- * of these bits may be set to
- * indicate that a button is pressed:
- * MO_LEFT
- * MO_RIGHT
- * MO_MIDDLE (bit always clear if
- * no third button exists).
- * unsigned *pcount Returned number of specified events
- * on specified button since the last
- * request.
- * unsigned *pvert,*phoriz
- * Returned mouse position at the
- * time of the last specified event
- * on the specified button.
- *
- * Description This function reports the number of presses or releases
- * of a specified mouse button. It also reports the mouse
- * position at the time of the last specified event. The
- * counter for the specified event is then cleared.
- *
- * The number of events reported reflects the number of
- * occurrences since the last time the data was requested.
- * The number of events is then cleared. If another
- * program queries the same item, the number reported will
- * be smaller than the correct value, because the other
- * program's query will erase the record of some of the
- * occurrences.
- *
- * The mouse position is reported in pixels relative to
- * (0,0) at the upper left corner of the screen.
- *
- * Returns ercode Error return code:
- * MO_OK if successful;
- * MO_ABSENT if mouse not found;
- * MO_BAD_OPT if event code not
- * recognized or requested
- * button not present.
- * b_mouse Number of mouse buttons (0 if no driver).
- * *pbuttons Status of buttons. Any
- * of these bits may be set to
- * indicate that a button is pressed:
- * MO_LEFT
- * MO_RIGHT
- * MO_MIDDLE
- * *pcount Number of specified events
- * on specified button since the last
- * request.
- * *pvert,*phoriz Mouse position at the
- * time of the last specified event
- * on the specified button.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1989
- *
- **/
-
- #include <bmouse.h>
-
- int mobutton(event,pbuttons,pcount,pvert,phoriz)
- int event;
- unsigned *pbuttons,*pcount,*pvert,*phoriz;
- {
- int result;
- DOSREG regs;
-
- if (moequip() <= 0) /* Check mouse presence. */
- return MO_ABSENT;
-
- /* Check mouse function number. */
- switch (event & (MO_PRESS | MO_RELEASE))
- {
- case MO_PRESS: regs.ax = 5; break;
- case MO_RELEASE: regs.ax = 6; break;
- default: return MO_BAD_OPT;
- }
-
- switch (event & MO_ALLBUTTONS)
- {
- case MO_LEFT: regs.bx = 0; break;
- case MO_RIGHT: regs.bx = 1; break;
- case MO_MIDDLE: regs.bx = 2; break;
-
- default: return MO_BAD_OPT;
- }
-
- if (regs.bx > b_mouse)
- return MO_BAD_OPT; /* Requested button missing. */
-
- result = mogate(®s,®s);
-
- if (result == MO_OK)
- {
- *pbuttons = regs.ax;
- *pcount = regs.bx;
- *phoriz = regs.cx;
- *pvert = regs.dx;
- }
-
- return result;
- }