home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / mouse / tcmouse / mouse.doc < prev    next >
Encoding:
Text File  |  1987-10-15  |  8.6 KB  |  218 lines

  1. NOTES ON USING MOUSERTN.OBJ AND MOUSE.H
  2.  
  3. First a little backgound on the mouse.  According to the Microsoft mouse
  4. users guide, the mouse supports IBM CGA, EGA, Mono, 3270 and Hercules
  5. graphics adapters.  I have not had a chance to test these routines on all of
  6. these type of monitors, but have tested them on CGA, and some of the routines
  7. on Hercules.  I will be able to finish checking all the routines on the
  8. hercules shortly, but do not anticipate any problems.  The mouse driver
  9. software automatically senses the character cell size of different video
  10. modes.  In text mode, the mouse will always give the characters upper left
  11. pixel as the position.  For example, on a CGA card in 80 column mode, the
  12. character cells are 8 pixels by 8 pixels.  If the mouse cursor is at
  13. 10,5 (starting from 0,0) the mouse will give the position 80,40.
  14.      The mouse uses 3 types of cursors:
  15.          graphics cursor-a shape that moves over the images on the screen.
  16.          software text cursor-a character attribute that moves from
  17.                   character to character.
  18.          hardware text cursor - a flashing block or partial block that
  19.                   moves from character to character.
  20.      The graphics cursor is used in graphics mode.  Usually, it is
  21. defined as a block of pixels in a 16 x 16 pixel area.  The mouse cursor's
  22. appearance against the background depends on the mask used.  The default
  23. appearance in graphics mode is an arrow.  Mouse function 9 let's you change
  24. the mask.  The mask is defined in an array of 32 integers, the first 16
  25. defining the screen mask, and the second 16 defining the cursor mask.
  26. This table from the users guide shows the effects of the masks.
  27. SCREEN MASK     CURSOR MASK           RESULTING SCREEN BIT
  28.        0               0                        0
  29.        0               1                        1
  30.        1               0                        Unchanged
  31.        1               1                        Inverted
  32.  
  33. When defining a graphics cursor, you also define a hot spot, meaning the
  34. individual pixel that the mouse software will use in determining its
  35. location.
  36.      The software text cursor also has a mask defining its effect on the
  37. screen.  The screen mask determines which of the characters attributes
  38. are preserved.  The cursor mask defines how the attributes are changed
  39. to show the cursor.  The 16 bits of each mask are:
  40.    15- set blinking or nonblinking
  41.    14-12 background color
  42.    11 intensity
  43.    10-8 foreground color
  44.    7-0 ascii value of char
  45.  
  46. The mouse can also use the hardware cursor in text mode, in which case
  47. you can define the start/stop scan lines, to display a partial of full
  48. block blinking cursor.  The number of scan lines depends on the type
  49. of video display.
  50.  
  51. The mouse software keeps some internal counters.  It increments a seperate
  52. counter each time a button is pressed or released, resetting them to 0
  53. after they have been read or after function 0, initialization.  I also
  54. keeps an internal cursor flag, which is always 0 or less.  When the flag
  55. is 0 the mouse cursor is displayed.  Each call to hide the cursor decrements
  56. the flag.  Thus if you call hide_cursor() twice, you must call show_cursor()
  57. twice to get it to show again.
  58.  
  59. The mouse measures distance in values called mickey's (Honest, I didn't make
  60. it up).  A mickey is approximately 1/200th of an inch.  There are functions
  61. which let you change the mickey/pixel ration (how far you have to move the
  62. mouse to move the same distance on the screen) and to change the speed
  63. doubling threshold (Default 64 mickeys/second).
  64.  
  65.  
  66. SPECIAL NOTES:
  67. For the mouse graphics cursor to show on a hercules graphics board, my
  68. understanding is that you have to poke 6 into location 40:49 hex for
  69. page 0, or a 5 for page 1.  I have not had a chance to test it yet,
  70. but that is the information I got from the Microsoft forum on CIS.
  71.   When printing to or updating the screen while the mouse cursor is showing,
  72. the mouse sometimes has problems not obliterating your changes when it moves
  73. away if you wrote directly accross where the mouse cursor was.  It
  74. usually is best to hide the cursor momentarily while you update the
  75. screen.
  76.  
  77.  
  78. MOUSE FUNCTIONS
  79. ---------------
  80.  
  81. Function 0
  82. int mouse_init(void);
  83. Initializes the mouse software to its defaults,:
  84. cursor in the center of the screen,
  85. internal cursor flag -1 (not showing),
  86. graphics cursor  arrow/-1,-1 hot spot
  87. text cursor an inverting box,
  88. horizontal mickey/pixel ration of 8:8,
  89. vertical mickey/pixel ratio of 16:8
  90. minimum and maximum horizontal and vertical positions usually the entire
  91.     screen.
  92.  
  93. Returns 0 if mouse not installed.
  94.  
  95.  
  96. Function 1
  97. void show_cursor(void);
  98. Show the cursor.  Increments the internal cursor flag.
  99.  
  100.  
  101. Function 2
  102. void hide_cursor(void);
  103. Hide the cursor.  Decrements the internal cursor flag.
  104.  
  105.  
  106. Function 3
  107. void get_status(int *,int *, int *);
  108. Get mouse position and status.
  109. gives button status and current position.
  110. status: 1=left button pressed, 2=right, 3=both
  111.  
  112.  
  113. Function 4
  114. void pos_mouse(int,int);
  115. Position the mouse on the screen.  It wants the pixel coordinates, not just
  116. character positions.
  117.  
  118.  
  119. Function 5
  120. void b_press(int,int *,int *, int *,int *);
  121. Gets the current status of the button,(0=check left button,1=check right)
  122. and the number of times the button was pressed since the last call to this
  123. function.  Also returns the position of the mouse the last time the button
  124. was pressed.
  125.  
  126.  
  127. Function 6
  128. int b_release(int,int *,int *,int *,int *);
  129. Like function 5, but checks button releases instead.
  130.  
  131.  
  132. Function 7
  133. void sethbounds(int,int);
  134. Set the left and right limits for the mouse to travel.
  135.  
  136.  
  137. Function 8
  138. void setvbounds(int,int);
  139. Set the top and bottom limits for the mouse to travel.
  140.  
  141.  
  142. Function 9
  143. void setgraphics(int,int, void (far *));
  144. Sets the graphics cursor's hot spot and mask which defines what the
  145. graphics cursor will look like.  The cursor hot spot must be within
  146. the range -16 to +16 pixels relative to the cursor.  The mask values
  147. could be something like:
  148. int xmask[32]={0x07e0,0x0000,0x0180,0x700e,0x0000,0x1c38,0xc003,0x0660,
  149.                0xf00f,0x03c0,0xc003,0x0660,0x0000,0x1c38,0x0180,0x700e,
  150.                0x07e0,0x0000,0xffff,0x0000,0xffff,0x0000,0xffff,0x0000,
  151.                0xffff,0x0000,0xffff,0x0000,0xffff,0x0000,0xffff,0x0000 };
  152. defines a graphics cursor like an x.  See the reference earlier in this
  153. file for the table of the mask values effects on the screen.
  154.  
  155.  
  156. Function 10
  157. void settext(int,int,int);
  158. sets the mouse text cursor to hardware or software cursor mode.  The first
  159. integer defines the mode, 0= use software cursor, 1=use hardware cursor.
  160. The second 2 integers define either the screen and cursor masks (software
  161. mode) or the start and stop scan lines of the hardware cursor.
  162. Typical mask values might be settext(0,0xFFFF,0x7700);
  163.  
  164.  
  165. Function 11
  166. void motion(int *,int *);
  167. This function reads the motion counters since the last call to this function.
  168. Returns the motion in "mickeys", always within the range of -32768 to +32767.
  169.  
  170.  
  171.  
  172. Function 12
  173. void set_subroutine(int,void (far *)());
  174. This function sets a subroutine to be conditionally called by the mouse
  175. software.  The condition of execution is defined by the mask.
  176. Bit 0          cursor position changes
  177.     1          left button pressed
  178.     2          left button released
  179.     3          right button pressed
  180.     4          tight button released
  181.     5-15       unused
  182.  
  183. To disable an interrupt for a specified condition, call function again
  184. with the corresponding bit set to zero.  Calling mouse function zero also
  185. resets everything.
  186.      The subroutine to be called must be a far procedure, must save all
  187.      registers, and must not do any dos or bios calls.
  188.  
  189.  
  190. Functions 13,14
  191. void light_pen(int);
  192. These functions turn the light kpen emulation mode on or off.  I don't know
  193. of any c programs that use light pen emulation, but the functions were easy
  194. to implement and included for completeness.  A zero parameter turns on
  195. emulation, any other parameter turns it off.
  196.  
  197.  
  198. Function 15
  199. void setspeed(int,int);
  200. Sets the mickey / pixel ratio vertically and horizontally.  Default values
  201. are horizontal 8 mickeys to 8 pixels, vertically 16 to 8.
  202.  
  203.  
  204. Function 16
  205. Void conditional_off(int,int,int,int);
  206. This function is similar to hide_cursor(), but only turns off the cursor
  207. if it is in the area defined when this function is called.  If this function
  208. hides the cursor, show_cursor() must be called again later on to show the
  209. cursor again.
  210.  
  211.  
  212. Function 19
  213. void set_threshold(int);
  214. This function sets how fast the mouse must move before its relative cursor
  215. movements on the screen are doubled.  Default value is 64 mickeys per second.
  216.  
  217.  
  218.