-
Notifications
You must be signed in to change notification settings - Fork 0
/
mouse.c
177 lines (133 loc) · 3.03 KB
/
mouse.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/*
Mouse interface by Rapha‰l Quinet <[email protected]>
You are allowed to use any parts of this code in another program, as
long as you give credits to the authors in the documentation and in
the program itself. Read the file README.1ST for more information.
This program comes with absolutely no warranty.
MOUSE.C - Mouse driver routines.
*/
/* the includes */
#include "deu.h"
#include <dos.h>
/* mouse interrupt number */
#define MOUSE 0x33
/* the global data */
Bool UseMouse; /* is there a mouse driver? */
/*
initialize the mouse driver
*/
void CheckMouseDriver()
{
union REGS regs;
struct SREGS sregs;
regs.x.ax = 0x0000;
int86(MOUSE, ®s, ®s);
if (regs.x.ax == 0xffff)
{
UseMouse = TRUE; /* mouse */
#ifdef CIRRUS_PATCH
/*
note from RQ:
This test is temporary and should be removed in DEU 5.3
We should create a better "fake cursor" by using the
mouse callback function. Remember to remove the callback
when DEU exits...
*/
if (CirrusCursor == TRUE)
{
regs.x.ax = 0x000C;
regs.x.cx = 0x0001;
regs.x.dx = FP_OFF( MouseCallBackFunction);
sregs.es = FP_SEG( MouseCallBackFunction);
int86x( MOUSE, ®s, ®s, &sregs);
}
#endif /* CIRRUS_PATCH */
}
else
UseMouse = FALSE; /* no mouse */
}
/*
show the pointer
*/
void ShowMousePointer()
{
union REGS regs;
regs.x.ax = 0x0001;
int86(MOUSE, ®s, ®s);
}
/*
hide the pointer
*/
void HideMousePointer()
{
union REGS regs;
regs.x.ax = 0x0002;
int86(MOUSE, ®s, ®s);
}
/*
read pointer coordinates
*/
void GetMouseCoords(int *x, int *y, int *buttons)
{
union REGS regs;
regs.x.ax = 0x0003;
int86(MOUSE, ®s, ®s);
if (x != NULL)
*x = regs.x.cx;
if (y != NULL)
*y = regs.x.dx;
if (buttons)
*buttons = regs.x.bx;
}
/*
change pointer coordinates
*/
void SetMouseCoords( int x, int y)
{
union REGS regs;
regs.x.ax = 0x0004;
regs.x.cx = (unsigned) x;
regs.x.dx = (unsigned) y;
int86(MOUSE, ®s, ®s);
}
/*
set horizontal and vertical limits (constrain pointer in a box)
*/
void SetMouseLimits( int x0, int y0, int x1, int y1)
{
union REGS regs;
regs.x.ax = 0x0007;
regs.x.cx = (unsigned) x0;
regs.x.dx = (unsigned) x1;
int86(MOUSE, ®s, ®s);
regs.x.ax = 0x0008;
regs.x.cx = (unsigned) y0;
regs.x.dx = (unsigned) y1;
int86(MOUSE, ®s, ®s);
}
/*
reset horizontal and vertical limits
*/
void ResetMouseLimits()
{
union REGS regs;
regs.x.ax = 0x0007;
regs.x.cx = (unsigned) 0;
regs.x.dx = (unsigned) ScrMaxX;
int86(MOUSE, ®s, ®s);
regs.x.ax = 0x0008;
regs.x.cx = (unsigned) 0;
regs.x.dx = (unsigned) ScrMaxY;
int86(MOUSE, ®s, ®s);
}
/*
mouse callback function
*/
void MouseCallBackFunction()
{
#ifdef CIRRUS_PATCH
if (CirrusCursor == TRUE)
SetHWCursorPos(_CX, _DX);
#endif /* CIRRUS_PATCH */
}
/* end of file */