home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / GUI100.ZIP / MOUSE.CPP < prev    next >
C/C++ Source or Header  |  1993-10-16  |  4KB  |  197 lines

  1. /************************************************************************
  2.  *                                                                      *
  3.  *                      MOUSE.CPP accompanies MOUSE.H                   *
  4.  *                              Version 1.00                            *
  5.  *                                                                      *
  6.  ************************************************************************
  7.  *                                                                      *
  8.  *                          Created by Dan Watling                      *
  9.  *                                                                      *
  10.  ************************************************************************
  11. /______________________________________________________________________*/
  12.  
  13.  
  14. #include <dos.h>
  15. #include <mouse.h>
  16.  
  17. #define MOUSE 0x33
  18.  
  19. int globax, globbx, globcx, globdx;
  20.  
  21. union REGS inregs, outregs;
  22.  
  23.  
  24. /* Initalize the Mouse Driver */
  25.  
  26. void reset_mouse(void)
  27. {
  28.  inregs.x.ax = 0;
  29.  
  30.  int86(MOUSE,&inregs,&inregs);
  31. }
  32.  
  33. /* Show the mouse */
  34.  
  35. void show_mouse(void)
  36. {
  37.  inregs.x.ax = 1;
  38.  
  39.  int86(MOUSE,&inregs,&inregs);
  40. }
  41.  
  42. /* Hide the mouse */
  43.  
  44. void hide_mouse(void)
  45. {
  46.  inregs.x.ax = 2;
  47.  
  48.  int86(MOUSE,&inregs,&inregs);
  49. }
  50.  
  51.  
  52. /* Monitors the status of the mouse */
  53.  
  54. int monitor_mouse(void)
  55. {
  56.  inregs.x.ax = 3;
  57.  
  58.  int86(MOUSE,&inregs,&outregs);
  59.  
  60.  globax = outregs.x.ax;
  61.  globbx = outregs.x.bx;
  62.  globcx = outregs.x.cx;
  63.  globdx = outregs.x.dx;
  64.  
  65.  return (globbx,globcx,globdx);
  66. }
  67.  
  68. /* Retrieves the amount of times a button has been pressed */
  69.  
  70. int push_button(void)
  71. {
  72.  inregs.x.ax = 5;
  73.  
  74.  int86(0x33,&inregs,&outregs);
  75.  
  76.  globax = outregs.x.ax;
  77.  globbx = outregs.x.bx;
  78.  globcx = outregs.x.cx;
  79.  globdx = outregs.x.dx;
  80.  
  81.  return(globbx,globcx,globdx);
  82. }
  83.  
  84. /* Retrieves the amount of times a button was released */
  85.  
  86. void release_button(int button, int hor, int ver)
  87. {
  88.   inregs.x.ax = 6;
  89.   inregs.x.bx = button;
  90.  
  91.   int86(MOUSE,&inregs,&outregs);
  92.  
  93.   globax = outregs.x.ax;
  94.   globbx = outregs.x.bx;
  95.   globcx = outregs.x.cx;
  96.   globdx = outregs.x.dx;
  97.  
  98.   ver = globcx;
  99.   hor = globdx;
  100. }
  101.  
  102. /* Moves the mouse to the position specified */
  103.  
  104. void put_mouse(int mousex, int mousey)
  105. {
  106.  inregs.x.ax = 4;
  107.  inregs.x.cx = mousey;
  108.  inregs.x.dx = mousex;
  109.  
  110.  int86(MOUSE,&inregs,&outregs);
  111.  
  112.  globax = outregs.x.ax;
  113.  globbx = outregs.x.bx;
  114.  globcx = outregs.x.cx;
  115.  globdx = outregs.x.dx;
  116. }
  117.  
  118. /* Sets the Maximum Horizontal positions */
  119.  
  120. void max_hor(int min, int max)
  121. {
  122.  inregs.x.ax = 7;
  123.  inregs.x.cx = min;
  124.  inregs.x.dx = max;
  125.  
  126.  int86(MOUSE,&inregs,&inregs);
  127. }
  128.  
  129. /* Sets the Maximum Vertical positions */
  130.  
  131. void max_ver(int min, int max)
  132. {
  133.  inregs.x.ax = 8;
  134.  inregs.x.cx = min;
  135.  inregs.x.dx = max;
  136.  
  137.  int86(MOUSE,&inregs,&inregs);
  138. }
  139.  
  140. /* Sets both the Maximum Vertical and Horizontal positions */
  141.  
  142. void max_ver_hor(int left, int top, int right, int bottom)
  143. {
  144.  max_hor(left,right);
  145.  max_ver(top,bottom);
  146. }
  147.  
  148. /* Defines the cursor to use for graphics modes */
  149.  
  150. void setcursor(int XHotSpot, int YHotSpot, int shape_tables, int seg_shape_tables)
  151. {
  152.  struct SREGS segregs;
  153.  
  154.  inregs.x.ax = 9;
  155.  inregs.x.bx = XHotSpot;
  156.  inregs.x.cx = YHotSpot;
  157.  inregs.x.dx = shape_tables;
  158.  segregs.es = seg_shape_tables;
  159.  
  160.  int86x(MOUSE,&inregs,&inregs,&segregs);
  161. }
  162.  
  163. /* Sets the movement ratio of the mouse */
  164.  
  165. void mouse_move_ratio(int ratio)
  166. {
  167.  inregs.x.ax = 15;
  168.  inregs.x.cx = ratio;
  169.  inregs.x.dx = ratio;
  170.  
  171.  int86(MOUSE,&inregs,&outregs);
  172.  
  173.  globax = outregs.x.ax;
  174.  globbx = outregs.x.bx;
  175.  globcx = outregs.x.cx;
  176.  globdx = outregs.x.dx;
  177. }
  178.  
  179. /* Defines a hidden area of the screen for the mouse; it won't show the
  180.    cursor in that rectangle or square */
  181.  
  182. void hidden_area(int left, int top, int right, int bottom)
  183. {
  184.  inregs.x.ax = 16;
  185.  inregs.x.cx = left;
  186.  inregs.x.dx = top;
  187.  inregs.x.si = right;
  188.  inregs.x.di = bottom;
  189.  
  190.  int86(MOUSE,&inregs,&outregs);
  191.  
  192.  globax = outregs.x.ax;
  193.  globbx = outregs.x.bx;
  194.  globcx = outregs.x.cx;
  195.  globdx = outregs.x.dx;
  196. }
  197.