home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / PROGRAMM / CPPMOUSE.ZIP / MOUSE.CPP < prev    next >
Text File  |  1990-12-01  |  7KB  |  224 lines

  1. /* Translated by Kevin Brooks from C routines written Ken Porter */
  2. /* December 11, 1990 */
  3.  
  4. #include <dos.h>
  5.  
  6. #include "mouse.hpp"
  7.  
  8. extern
  9. const int HARDWARE = 1;                                /* cursor types */
  10. extern
  11. const int SOFTWARE = 0;
  12.  
  13. /* Following are implementations of the Microsoft mouse functions  */
  14.  
  15. resetRec&
  16. Mouse::Reset ()
  17. /* Resets mouse to default state. Returns pointer to a structure   */
  18. /* indicating whether or not mouse is installed and, if so, how    */
  19. /* many buttons it has.                                            */
  20. /* Always call this function during program initialization.        */
  21. {
  22.  
  23.   inreg.x.ax = 0;                                    /* function 0 */
  24.   callMDD();
  25.   exists = outreg.x.ax;
  26.   nButtons = outreg.x.bx;
  27.   resetRec resetrec(exists, nButtons);
  28.   return resetrec;
  29.  
  30. void 
  31. Mouse::Show()
  32. /* Makes the mouse cursor visible. Don't call if cursor is already */
  33. /* visible, and alternate with calls to mHide.                     */
  34. {
  35.   inreg.x.ax = 1;                                    /* function 1 */
  36.   callMDD();
  37.  
  38. void 
  39. Mouse::Hide()
  40. /* Makes mouse cursor invisible. Movement and button activity are  */
  41. /* still tracked. Do not call if cursor is already hidden, and     */
  42. /* alternate with calls to mShow                                   */
  43. {
  44.   inreg.x.ax = 2;                                    /* function 2 */
  45.   callMDD();
  46. }
  47.  
  48. locRec&
  49. Mouse::Pos()
  50. /* Gets mouse cursor position and button status, returns pointer   */
  51. /* to structure containing this info                               */
  52. {
  53.   inreg.x.ax = 3;                                    /* function 3 */
  54.   callMDD();
  55.   buttonStatus = outreg.x.bx;                   /* button status */
  56.   column = outreg.x.cx;                        /* horiz position */
  57.   row = outreg.x.dx;                            /* vert position */
  58.   locRec locrec(buttonStatus, 1, column, row);
  59.   return locrec;
  60. }
  61.  
  62. void  
  63. Mouse::Moveto(int newCol, int newRow)
  64. /* Move mouse cursor to new position */
  65. {
  66.   inreg.x.ax = 4;                                    /* function 4 */
  67.   inreg.x.cx = newCol;
  68.   inreg.x.dx = newRow;
  69.   callMDD();
  70. }
  71.  
  72. locRec&
  73. Mouse::Pressed(Button button)
  74. /* Gets pressed info about named button: current status (up/down), */
  75. /* times pressed since last call, position at most recent press.   */
  76. /* Resets count and position info. Button 0 is left, 1 is right on */
  77. /* Microsoft mouse.                                                */
  78. /* Returns pointer to locRec structure containing info.            */
  79. {
  80.  
  81.   inreg.x.ax = 5;                                    /* function 5 */
  82.   inreg.x.bx = button;              /* request for specific button */
  83.   callMDD();
  84.   buttonStatus = outreg.x.ax;
  85.   opCount = outreg.x.bx;
  86.   column  = outreg.x.cx;
  87.   row     = outreg.x.dx;
  88.   locRec locrec(buttonStatus, opCount, column, row);
  89.   return locrec;
  90. }
  91.  
  92. locRec&
  93. Mouse::Released(Button button)
  94. /* Same as mPressed, except gets released info about button */
  95. {
  96.  
  97.   inreg.x.ax = 6;                                    /* function 6 */
  98.   inreg.x.bx = button;              /* request for specific button */
  99.   callMDD();
  100.   buttonStatus = outreg.x.ax;
  101.   opCount = outreg.x.bx;
  102.   column  = outreg.x.cx;
  103.   row     = outreg.x.dx;
  104.  
  105.   // the 1 as the 2nd argument is a dummy
  106.   locRec locrec(buttonStatus, 1, column, row);
  107.   return locrec;
  108. }
  109.  
  110. void  
  111. Mouse::SetColRange(int hmin, int hmax)
  112. /* Sets min and max horizontal range for mouse cursor. Moves   */
  113. /* cursor inside range if outside when called. Swaps values if */
  114. /* hmin and hmax are reversed.                                 */
  115. {
  116.   inreg.x.ax = 7;                                /* function 7 */
  117.   inreg.x.cx = hmin;
  118.   inreg.x.dx = hmax;
  119.   callMDD();
  120. }
  121.  
  122. void
  123. Mouse::SetRowRange(int vmin, int vmax)
  124. /* Same as mHminmax, except sets vertical boundaries. */
  125. {
  126.   inreg.x.ax = 8;                                    /* function 8 */
  127.   inreg.x.cx = vmin;
  128.   inreg.x.dx = vmax;
  129.   callMDD();
  130. }
  131.  
  132. void  
  133. Mouse::GraphCursor (int hHot, int vHot, unsigned maskSeg,
  134.                     unsigned maskOfs)
  135. /* Sets graphic cursor shape */
  136. {
  137.   struct SREGS  seg;
  138.  
  139.   inreg.x.ax = 9;                                    /* function 9 */
  140.   inreg.x.bx = hHot;                /* cursor hot spot: horizontal */
  141.   inreg.x.cx = vHot;                  /* cursor hot spot: vertical */
  142.   inreg.x.dx = maskOfs;
  143.   seg.es = maskSeg;
  144.   int86x (0x33, &inreg, &outreg, &seg);
  145.  
  146. void  
  147. Mouse::TextCursor (int curstype, unsigned arg1, unsigned arg2)
  148. /* Sets text cursor type, where 0 = software and 1 = hardware)     */
  149. /* For software cursor, arg1 and arg2 are the screen and cursor    */
  150. /*   masks.                                                        */
  151. /* For hardware cursor, arg1 and arg2 specify scan line start/stop */
  152. /*   i.e. cursor shape.                                            */
  153. {
  154.   inreg.x.ax = 10;                                  /* function 10 */
  155.   inreg.x.bx = curstype;
  156.   inreg.x.cx = arg1;
  157.   inreg.x.dx = arg2;
  158.   callMDD();
  159.  
  160. moveRec&
  161. Mouse::Motion()
  162. /* Reports net motion of cursor since last call to this function   */
  163. {
  164.  
  165.   inreg.x.ax = 11;                                  /* function 11 */
  166.   callMDD();
  167.  
  168.   // moverec.hCount = _CX;                                /* net horizontal */
  169.   // moverec.vCount = _DX;                                  /* net vertical */
  170.  
  171.   hCount = outreg.x.cx;                                /* net horizontal */
  172.   vCount = outreg.x.dx;                                  /* net vertical */
  173.  
  174.   moveRec moverec(hCount, vCount);
  175.   return moverec;
  176. }
  177.  
  178. void 
  179. Mouse::InstTask (unsigned mask, unsigned taskSeg, unsigned taskOfs)
  180. /* Installs a user-defined task to be executed upon one or more    */
  181. /*   mouse events specified by mask.                               */
  182. {
  183.   struct SREGS  seg;
  184.  
  185.   inreg.x.ax = 12;                                  /* function 12 */
  186.   inreg.x.cx = mask;
  187.   inreg.x.dx = taskOfs;
  188.   seg.es = taskSeg;
  189.   int86x (0x33, &inreg, &outreg, &seg);
  190.  
  191. void 
  192. Mouse::LpenOn()
  193. /* Turns on light pen emulation. This is the default condition.    */
  194. {
  195.   inreg.x.ax = 13;                                  /* function 13 */
  196.   callMDD();
  197. }
  198.  
  199. void 
  200. Mouse::LpenOff()
  201. /* Turns off light pen emulation. */
  202. {
  203.   inreg.x.ax = 14;                                  /* function 14 */
  204.   callMDD();
  205. }
  206.  
  207. void 
  208. Mouse::Ratio(int horiz, int vert)
  209. /* Sets mickey-to-pixel ratio, where ratio is R/8. Default is 16   */
  210. /*   for vertical, 8 for horizontal */
  211. {
  212.   inreg.x.ax = 15;                                  /* function 15 */
  213.   inreg.x.cx = horiz;
  214.   inreg.x.dx = vert;
  215.   callMDD();
  216. }
  217.  
  218.  
  219.