📄 moustrap.prn
字号:
The MouseTrap Library
High & Low Level Mouse Control
Functions for 'C' Programs
Version 1.1
By James M. Curran
By James M. Curran.
24 Greendale Road
Cedar Grove, NJ
07009-1313
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3
Registration . . . . . . . . . . . . . . . . . . . . . . . . 3
Warranty . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2. Basic Mouse Control Functions . . . . . . . . . . . . . . . . . 4
Check_Mouse . . . . . . . . . . . . . . . . . . . . . . . . . 5
Show_Mouse . . . . . . . . . . . . . . . . . . . . . . . . . 6
Hide_Mouse . . . . . . . . . . . . . . . . . . . . . . . . . 6
Get_Mouse_Position . . . . . . . . . . . . . . . . . . . . . 7
Set_Mouse_Position . . . . . . . . . . . . . . . . . . . . . 9
Get_Mouse_Press . . . . . . . . . . . . . . . . . . . . . . . 10
Get_Mouse_Release . . . . . . . . . . . . . . . . . . . . . . 10
Set_Mouse_Limit . . . . . . . . . . . . . . . . . . . . . . . 11
Set_Mouse_Limit_Horiz . . . . . . . . . . . . . . . . . . . . 11
Set_Mouse_Limit_Vert . . . . . . . . . . . . . . . . . . . . 11
Set_Mouse_Region . . . . . . . . . . . . . . . . . . . . . . 11
Set_Mouse_Text_Cursor . . . . . . . . . . . . . . . . . . . . 12
Set_Mouse_Graphic_Cursor . . . . . . . . . . . . . . . . . . 13
3. Advanced Mouse Control Functions . . . . . . . . . . . . . . . 16
Activate_Mouse_Page . . . . . . . . . . . . . . . . . . . . . 17
Add_Mouse_Page . . . . . . . . . . . . . . . . . . . . . . . 18
Add_Mouse_Button . . . . . . . . . . . . . . . . . . . . . . 19
Add_Mouse_Hot_Spot . . . . . . . . . . . . . . . . . . . . . 20
Clear_All_Mouse_Definitions . . . . . . . . . . . . . . . . . 21
Clear_Mouse_Pages . . . . . . . . . . . . . . . . . . . . . . 22
DeActivate_Mouse_Page . . . . . . . . . . . . . . . . . . . . 23
Define_Mouse_System . . . . . . . . . . . . . . . . . . . . . 24
Delete_Mouse_Button . . . . . . . . . . . . . . . . . . . . . 25
Delete_Mouse_Hot_Spot . . . . . . . . . . . . . . . . . . . . 25
Delete_Mouse_Page . . . . . . . . . . . . . . . . . . . . . . 25
Get_Char_Mouse_Kbd . . . . . . . . . . . . . . . . . . . . . 26
Read_Mouse . . . . . . . . . . . . . . . . . . . . . . . . . 27
Read_Mouse_Kbd . . . . . . . . . . . . . . . . . . . . . . . 28
4. Using the MouseTrap Library . . . . . . . . . . . . . . . . . 29
5. Technical Specification . . . . . . . . . . . . . . . . . . . 35
Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
MOUSTRAP.H . . . . . . . . . . . . . . . . . . . . . . . . . 37
Global Variables . . . . . . . . . . . . . . . . . . . . . . 38
Error Codes. . . . . . . . . . . . . . . . . . . . . . . . . 39
Reference . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Support . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Revision History . . . . . . . . . . . . . . . . . . . . . . 43
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
MouseTrap Library, Rel 1.01
February 12, 1989
Introduction
The MouseTrap library is a collection of functions to
control a mouse, designed to be called from a 'C' program. They
provide easy access to the low-level functions of the mouse
interrupt, as well as a simplified system for high-level control
over the mouse. The basic functions are mostly self explanatory
and are described in chapter 2 of the document. The high-level
functions are a bit more complicated. They are described in
Chapter 3 with a tutorial in Chapter 4.
Registration
The MouseTrap Library is copyrighted by James M. Curran.
You are granted a limited license to use MouseTrap, for
noncommercial programs. You may, and are in fact encouraged, to
copy and distribute it, provided that the following conditions
are met: (a) No fee may be charged for copying or distributing,
and (b) only the library files (*.LIB) and accompanying
documentation are distributed, and only in their original,
unmodified form.
Sending a voluntary contribution of $15.00 will appease your
guilt, and earn you my undying gratitude. It will also get you a
copy of the source code, the Compact (CMOUSE.LIB) & Medium
(MMOUSE.LIB) memory model libraries, the missing chapter from
this booklet, and other assorted related files. Microsoft C 5.1
& MASM 5.1 are needed to recompile the source files, (unless
modified by the user).
Contributions, (and requests for information on commercial
licenses) should be sent to:
James M. Curran
24 Greendale Road
Cedar Grove, NJ 07009-1313
Finally, there's only one thing you can say for sure about a
"Version 1.0" release of software--- That it will soon be
followed by a "Version 1.01" Bug-Fix release. So, all registered
user will be sent that version when it's ready. (That's merely
cautionary; there are no known bugs at this time).
Warranty
Warranty ? We make no promises that the MouseTrap library
will do anything useful for you. Nor do we promise that it WON'T
do anything harmful. (Life's Tough; "Want do you want for
nothing ? Rubber Biscuit ?")
- Page 3 -
MouseTrap Library, Rel 1.01
February 12, 1989
Chapter 2:
Basic Mouse Control Functions
The eleven primitives that make up the low-level support
functions are almost direct calls to the mouse driver interrupt,
and are written in 8086 assembler. They were originally derived
from a set of 'C' functions given in an article in "The 'C'
Gazette" (see references at end), but since then numerous
revisions have transformed them. The only thing left are the
names of two functions.
Check_Mouse() Get_Mouse_Press()
Show_Mouse() Get_Mouse_Release()
Hide_Mouse() Set_Mouse_Text_Cursor()
Get_Mouse_Position()
Set_Mouse_Position()
Set_Mouse_Limits()
- Page 4 -
MouseTrap Library, Rel 1.01
February 12, 1989
Check_Mouse - Check for the existence and type of Mouse.
Syntax:
#include <moustrap.h>
mouse_t Check_Mouse(void);
Description:
This function initialized the mouse interrupt driver, and
must be the first low-level function called (but see
Define_Mouse_System()). It checks to see if a mouse is attached
(or to be exact, if a mouse device driver is loaded into memory),
and if one is present, determines how many buttons it has. This
information is return by the function, and is also stored in the
global variable "_mouse_there".
Returns Value:
If no mouse is detected, the Check_Mouse function returns 0.
If a mouse IS detected, the number of buttons on it is returned.
These values are also stored in the global _mouse_there. This can
also be used as a TRUE/FALSE indicator.
See Also:
Define_Mouse_System, _mouse_there
Example:
#include <moustrap.h>
#include <stdio.h>
main()
{
Check_Mouse();
if (_mouse_there)
printf("A %d-button Mouse was detected.\n",_mouse_there);
else
printf("No mouse was found.\n");
}
- Page 5 -
MouseTrap Library, Rel 1.01
February 12, 1989
Show_Mouse - Display Mouse Cursor.
Hide_Mouse - Hide Mouse Cursor.
Syntax:
#include <moustrap.h>
void Show_Mouse(void);
void Hide_Mouse(void);
Description:
Show_Mouse causes the mouse cursor to be displayed on the
screen. Hide_Mouse cause the mouse cursor to disappear.
Neither will have any effect if there is no mouse or
Check_Mouse has not been executed yet.
Returns Value:
There is no return value.
See Also:
Check_Mouse, _mouse_there
Example:
#include <moustrap.h>
#include <stdio.h>
main()
{
Check_Mouse();
Show_Mouse();
printf("Look, Ma! A mouse !");
getch(); /* Mouse visible until a key is pressed */
Hide_Mouse();
}
- Page 6 -
MouseTrap Library, Rel 1.01
February 12, 1989
Get_Mouse_Position
Syntax:
#include <moustrap.h>
mouse_t Get_Mouse_Position(mouse_t *X, mouse_t *Y);
Description:
Get_Mouse_Position places the X (Horizontal) and Y
(Vertical) coordinates of the present location of the mouse
cursor into the locations given by X & Y. The locations are
given using graphic coordinates in the range (0,0) to
(639,199). It also returns the binary sum of the buttons
pressed. If _mouse_there indicates that no mouse was
detected, the values of X & Y are left unchanged, and the
function returns 0.
Return Value:
The binary sum of the buttons pressed, where the Left button
equals 1, the Right button equals 2, and the Middle
button, 4. These values are added together if more than one
button is pressed. For example, pressing the Left &
Middle buttons would have Get_Mouse_Position return a value
of 5.
See Also:
_mouse_there, Set_Mouse_Position
Example:
#include <moustrap.h>
#include <stdio.h>
main()
{
int X,Y,m;
Check_Mouse();
do {
m = Get_Mouse_Position( &X, &Y);
if (m & 1)
printf("Left Button, ");
if (m & 2)
printf("Right Button, ");
if (m & 4)
printf("Middle Button, ");
if (m)
printf("pressed at (%d, %d)\n",X,Y);
- Page 7 -
MouseTrap Library, Rel 1.01
February 12, 1989
} while (m==0);
}
Pressing the Left & Right buttons would print something
similar to:
Left Button, Right Button pressed at (120, 85)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -