home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 1.ddi / TOOLS.1 / INCLUDE / BMOUSE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  8.6 KB  |  224 lines

  1. /**
  2. *
  3. *  BMOUSE.H   Header file for Turbo C TOOLS Mouse Functions
  4. *
  5. *  Version 6.00 (C) Copyright Blaise Computing Inc. 1988
  6. *
  7. **/
  8.  
  9. #ifndef DEF_BMOUSE              /* Prevent second reading of    */
  10. #define DEF_BMOUSE 1              /* these definitions.          */
  11.  
  12. #include <bkeybrd.h>          /* For KEYSTATUS.               */
  13. #include <bintrupt.h>          /* For ISRCTRL.                  */
  14.  
  15.     /* General symbols.                           */
  16.  
  17. #define MO_LEFT        1      /* Left    mouse button.              */
  18. #define MO_RIGHT       2      /* Right    mouse button.              */
  19. #define MO_MIDDLE      4      /* Center mouse button, if any.          */
  20.                   /* (MO_LEFT, MO_RIGHT and MO_MIDDLE     */
  21.                   /*  must not conflict with MO_PRESS and */
  22.                   /*  MO_RELEASE.)                  */
  23. #define MO_ALLBUTTONS  (MO_LEFT | MO_RIGHT | MO_MIDDLE)
  24.  
  25. #define MO_INSTALL    0
  26. #define MO_REMOVE    1
  27.  
  28.     /* Error codes.                              */
  29.  
  30. #define MO_OK          0   /* Successful operation.              */
  31. #define MO_NOLINK    (-3)  /* Mouse functions not linked.          */
  32. #define MO_ABSENT    (-2)  /* Mouse driver not installed.          */
  33. #define MO_BAD_OPT      1   /* Unknown option.              */
  34. #define MO_RANGE      2   /* Value(s) out of range.           */
  35. #define MO_BAD_COMBO      3   /* Bad combination of options.          */
  36. #define MO_ALREADY      4   /* Can't do operation twice.            */
  37. #define MO_NOT_INSTALLED  5   /* MOCATCH not installed.           */
  38.  
  39.     /* Symbol for b_mouse.                          */
  40.  
  41. #define MO_UNKNOWN   (-1)     /* Mouse state not yet tested.          */
  42.  
  43.     /* Symbols for MORANGE.                          */
  44.  
  45. #define MO_HORIZ       0      /* Horizontal.                  */
  46. #define MO_VERT        3      /* Vertical.                  */
  47.  
  48.     /* Symbols for MOHIDE.                          */
  49.  
  50. #define MO_HIDE        1
  51. #define MO_SHOW        0
  52.  
  53.     /* Symbols for MOLITPEN.                          */
  54.  
  55. #define MO_PEN           1      /* Emulate light pen.  (Default          */
  56.                   /*  condition when mouse is reset.)     */
  57. #define MO_NO_PEN      0      /* Don't emulate light pen.             */
  58.  
  59.     /* Symbols for MOBUTTON and MOCHECK.                  */
  60.  
  61. #define MO_PRESS       8      /* Button events (must not conflict     */
  62. #define MO_RELEASE  0x10      /*  with MO_LEFT, MO_RIGHT, and          */
  63.                   /*  MO_MIDDLE).                  */
  64.  
  65. #define MO_CLEAR       0x0010
  66. #define MO_NOCLEAR     0x0020
  67.  
  68. #define MO_CLICK      0x0040
  69. #define MO_DCLICK     0x0080
  70.  
  71. #define MO_HOLD       0x0800
  72.  
  73. #define MO_RSHIFT     0x1000
  74. #define MO_LSHIFT     0x2000
  75. #define MO_CSHIFT     0x4000
  76. #define MO_ASHIFT     0x8000
  77.  
  78.     /* Mouse event masks for MOHANDLR.                      */
  79.  
  80. #define MO_MOVE       0x0001          /* Mouse moved.              */
  81. #define MO_L_PRESS    0x0002          /* Left    button depressed.     */
  82. #define MO_L_RELEASE  0x0004          /* Left    button released.      */
  83. #define MO_R_PRESS    0x0008          /* Right    button depressed.     */
  84. #define MO_R_RELEASE  0x0010          /* Right    button released.      */
  85. #define MO_M_PRESS    0x0020          /* Middle button depressed.     */
  86. #define MO_M_RELEASE  0x0040          /* Middle button released.      */
  87.  
  88.     /* Internal symbols.                          */
  89.  
  90. #define MO_HIST_LIMIT    5     /* Number of recent events recorded.    */
  91.                   /* Need at least 5 for double clicks.   */
  92.                   /* Must match MOCATCH.ASM.          */
  93.  
  94.                   /* Mouse events handled by MOCATCH.     */
  95. #define MOCATCH_MASK   (MO_L_PRESS | MO_L_RELEASE               \
  96.               | MO_R_PRESS | MO_R_RELEASE               \
  97.               | MO_M_PRESS | MO_M_RELEASE)
  98.  
  99.     /* Data types.                              */
  100.  
  101. typedef struct              /* MO_EVENT:  Mouse event in history    */
  102. {                  /*  array.  This must match MOCATCH.ASM */
  103.                   /*                      */
  104.     int       event;          /* MO_PRESS or MO_RELEASE.          */
  105.     long      time;          /* BIOS clock ticks since midnight.     */
  106.     unsigned  c_vert,c_horiz; /* Mouse cursor location in pixels.     */
  107.     int       vert,horiz;     /* Mouse location in mickeys.          */
  108.     KEYSTATUS kstat;          /* Shift key status at time of event.   */
  109.     int       relevant;       /* Bits to prevent rereading same event */
  110.                   /*  (MO_CLICK, MO_DCLICK, MO_PRESS,     */
  111.                   /*   MO_RELEASE).               */
  112. } MO_EVENT;
  113.  
  114.                   /* PMOHANDLER:  Address of mouse          */
  115.                   /*   interrupt handler function.          */
  116. typedef void cdecl (*PMOHANDLER)(const ALLREG *);
  117.  
  118.     /* Global variables.                          */
  119.  
  120. extern int b_mouse;          /* Mouse presence:  MO_UNKNOWN,          */
  121.                   /*   0 if absent, or number of buttons. */
  122.  
  123. extern long b_clicklimit;     /* Time limits for clicks and double    */
  124. extern long b_dclicklimit;    /* clicks (measured in clock ticks).    */
  125.  
  126.                   /* History of recent mouse events       */
  127.                   /*  maintained by MOCATCH.          */
  128.                   /*  First subscript is for each button  */
  129.                   /*   (0 = left, 1 = right, 2 = middle); */
  130.                   /*  second is for event number          */
  131.                   /*   (0 is most recent).              */
  132. extern volatile MO_EVENT b_mohist[3][MO_HIST_LIMIT];
  133.  
  134. extern void (far *b_mocatch)(void);   /* Pointer to MOCATCH if          */
  135.                       /*  installed, or 0 if not.     */
  136.                       /*                  */
  137. extern unsigned     b_momask;          /* Current MOCATCH event mask   */
  138.                       /*  (0 or MOCATCH_MASK).          */
  139.                       /*                  */
  140. extern ISRCTRL far *b_modispat;       /* Address of dispatcher that   */
  141.                       /*  invokes user interrupt      */
  142.                       /*  handler, or 0 if no handler */
  143.                       /*  installed.              */
  144.                       /*                  */
  145. extern unsigned     b_mohanmask;      /* Call mask for user mouse     */
  146.                       /*  interrupt handler (0 if     */
  147.                       /*  none).              */
  148.  
  149.     /* Routines implemented as macros.                      */
  150.  
  151. #define moreset()              /* Reset mouse driver.          */ \
  152.       ((b_mouse=MO_UNKNOWN),moequip())
  153.  
  154.     /* Function declarations.                          */
  155.  
  156.                   /* General mouse setup.              */
  157.  
  158. int cdecl moequip(void);          /* Mouse driver presence test.  */
  159.                       /*                  */
  160. int cdecl mogate(const DOSREG *,      /* General gateway.          */
  161.                DOSREG *);     /*                  */
  162.                       /*                  */
  163. int far cdecl mopreclk(int);          /* Install MOCATCH (so MOCHECK  */
  164.                       /*  can work).              */
  165.                       /*                  */
  166. int cdecl mohandlr(PMOHANDLER,          /* Install user's mouse         */
  167.     unsigned,char *,int,int);          /*  interrupt handler.          */
  168.                       /*                  */
  169. int cdecl mospeed(unsigned,unsigned); /* Set mouse sensitivity (speed */
  170.                       /*  of cursor motion).          */
  171.                       /*                  */
  172. int cdecl mojump(unsigned);          /* Set speed-jump threshold.    */
  173.                       /*                  */
  174. int cdecl molitpen(int);          /* Enable or disable light pen  */
  175.                       /*  emulation.              */
  176.  
  177.                   /* Mouse cursor appearance.          */
  178.  
  179. int far cdecl mohide(int);          /* Hide or show mouse cursor.   */
  180.                       /*                  */
  181. int far cdecl moavoid(unsigned,       /* Hide mouse cursor when in    */
  182.      unsigned,unsigned,unsigned); /*  specified region.          */
  183.                       /*                  */
  184. int cdecl mosoft(unsigned,unsigned);  /* Set software text cursor.    */
  185.                       /*                  */
  186. int cdecl mohard(int,int);          /* Set hardware text cursor.    */
  187.                       /*                  */
  188. int cdecl mograph(const unsigned *,   /* Set graphics-mode cursor.    */
  189.     int,int);                  /*                  */
  190.  
  191.                   /* Controlling mouse cursor movement.   */
  192.  
  193. int cdecl mocurmov(unsigned,unsigned);/* Move mouse cursor.          */
  194.                       /*                  */
  195. int cdecl morange(int,unsigned,       /* Set range limit (horizontal  */
  196.               unsigned);      /*  or vertical).           */
  197.                       /*                  */
  198.  
  199.                   /* Querying mouse status.           */
  200.  
  201. int cdecl mostat(unsigned *,          /* Report mouse position and    */
  202.          unsigned *,unsigned *);  /*  button status.          */
  203.                       /*                  */
  204. int cdecl mobutton(int,unsigned *,    /* Report mouse button press/   */
  205.    unsigned *,unsigned *,unsigned *); /*  release history.          */
  206.                       /*                  */
  207. int cdecl mogetmov(int *,int *);      /* Report relative physical     */
  208.                       /*  mouse motion since last     */
  209.                       /*  inquiry.              */
  210.                       /*                  */
  211. int far cdecl mocheck(unsigned long,  /* Check for recent mouse event.*/
  212.   unsigned long,int,              /*                  */
  213.   unsigned long *,unsigned *,          /*                  */
  214.   unsigned *);                  /*                  */
  215.  
  216.     /* Internal functions.                          */
  217.  
  218. void far mocatch(void);           /* Record mouse interrupts.     */
  219.                       /*                  */
  220. int cdecl moinst(void (far *)(void),  /* Install interrupt handler    */
  221.          unsigned);          /*  unconditionally.          */
  222.  
  223. #endif                      /* Ends "#ifndef DEF_BMOUSE"    */
  224.