rev |
line source |
nuclear@1
|
1 /* TODO: try NOT using the v8086 interrupts to avoid the overhead */
|
nuclear@1
|
2 #include "mouse.h"
|
nuclear@1
|
3 #include "inttypes.h"
|
nuclear@1
|
4 #include "dpmi.h"
|
nuclear@1
|
5
|
nuclear@1
|
6 #define INTR 0x33
|
nuclear@1
|
7
|
nuclear@1
|
8 #define QUERY 0
|
nuclear@1
|
9 #define SHOW 1
|
nuclear@1
|
10 #define HIDE 2
|
nuclear@1
|
11 #define READ 3
|
nuclear@1
|
12 #define WRITE 4
|
nuclear@1
|
13
|
nuclear@1
|
14 #define XLIM 7
|
nuclear@1
|
15 #define YLIM 8
|
nuclear@1
|
16
|
nuclear@1
|
17 int have_mouse(void)
|
nuclear@1
|
18 {
|
nuclear@1
|
19 struct dpmi_real_regs regs;
|
nuclear@1
|
20 memset(®s, 0, sizeof regs);
|
nuclear@1
|
21 regs.eax = QUERY;
|
nuclear@1
|
22 dpmi_real_int(INTR, ®s);
|
nuclear@1
|
23 return regs.eax & 0xffff;
|
nuclear@1
|
24 }
|
nuclear@1
|
25
|
nuclear@1
|
26 void show_mouse(int show)
|
nuclear@1
|
27 {
|
nuclear@1
|
28 struct dpmi_real_regs regs;
|
nuclear@1
|
29 memset(®s, 0, sizeof regs);
|
nuclear@1
|
30 regs.eax = show ? SHOW : HIDE;
|
nuclear@1
|
31 dpmi_real_int(INTR, ®s);
|
nuclear@1
|
32 }
|
nuclear@1
|
33
|
nuclear@1
|
34 int read_mouse(int *xp, int *yp)
|
nuclear@1
|
35 {
|
nuclear@1
|
36 struct dpmi_real_regs regs;
|
nuclear@1
|
37 memset(®s, 0, sizeof regs);
|
nuclear@1
|
38
|
nuclear@1
|
39 regs.eax = READ;
|
nuclear@1
|
40 dpmi_real_int(INTR, ®s);
|
nuclear@1
|
41
|
nuclear@1
|
42 if(xp) *xp = regs.ecx & 0xffff;
|
nuclear@1
|
43 if(yp) *yp = regs.edx & 0xffff;
|
nuclear@1
|
44 return regs.ebx & 0xffff;
|
nuclear@1
|
45 }
|
nuclear@1
|
46
|
nuclear@1
|
47 void set_mouse(int x, int y)
|
nuclear@1
|
48 {
|
nuclear@1
|
49 struct dpmi_real_regs regs;
|
nuclear@1
|
50 memset(®s, 0, sizeof regs);
|
nuclear@1
|
51
|
nuclear@1
|
52 regs.eax = WRITE;
|
nuclear@1
|
53 regs.ecx = x;
|
nuclear@1
|
54 regs.edx = y;
|
nuclear@1
|
55 dpmi_real_int(INTR, ®s);
|
nuclear@1
|
56 }
|
nuclear@1
|
57
|
nuclear@1
|
58 void set_mouse_limits(int xmin, int ymin, int xmax, int ymax)
|
nuclear@1
|
59 {
|
nuclear@1
|
60 struct dpmi_real_regs regs;
|
nuclear@1
|
61 memset(®s, 0, sizeof regs);
|
nuclear@1
|
62 regs.eax = XLIM;
|
nuclear@1
|
63 regs.ecx = xmin;
|
nuclear@1
|
64 regs.edx = xmax;
|
nuclear@1
|
65 dpmi_real_int(INTR, ®s);
|
nuclear@1
|
66
|
nuclear@1
|
67 memset(®s, 0, sizeof regs);
|
nuclear@1
|
68 regs.eax = YLIM;
|
nuclear@1
|
69 regs.ecx = ymin;
|
nuclear@1
|
70 regs.edx = ymax;
|
nuclear@1
|
71 dpmi_real_int(INTR, ®s);
|
nuclear@1
|
72 }
|