2 * DOS interrupt 33h handler
15 #include "debugtools.h"
17 DEFAULT_DEBUG_CHANNEL(int);
22 WORD lbcount, rbcount, rlastx, rlasty, llastx, llasty;
25 WORD VMPratio, HMPratio, oldx, oldy;
28 /**********************************************************************
31 * Handler for int 33h (MS MOUSE).
33 void WINAPI DOSVM_Int33Handler( CONTEXT86 *context )
35 switch (LOWORD(context->Eax)) {
37 TRACE("Reset mouse driver and request status\n");
38 AX_reg(context) = 0xFFFF; /* installed */
39 BX_reg(context) = 3; /* # of buttons */
40 memset( &mouse_info, 0, sizeof(mouse_info) );
41 /* Set the default mickey/pixel ratio */
42 mouse_info.HMPratio = 8;
43 mouse_info.VMPratio = 16;
46 FIXME("Show mouse cursor\n");
49 FIXME("Hide mouse cursor\n");
52 TRACE("Return mouse position and button status\n");
53 BX_reg(context) = mouse_info.but;
54 CX_reg(context) = mouse_info.x;
55 DX_reg(context) = mouse_info.y;
58 FIXME("Position mouse cursor\n");
61 TRACE("Return Mouse button press Information for %s mouse button\n",
62 BX_reg(context) ? "right" : "left");
63 if (BX_reg(context)) {
64 BX_reg(context) = mouse_info.rbcount;
65 mouse_info.rbcount = 0;
66 CX_reg(context) = mouse_info.rlastx;
67 DX_reg(context) = mouse_info.rlasty;
69 BX_reg(context) = mouse_info.lbcount;
70 mouse_info.lbcount = 0;
71 CX_reg(context) = mouse_info.llastx;
72 DX_reg(context) = mouse_info.llasty;
74 AX_reg(context) = mouse_info.but;
77 FIXME("Define horizontal mouse cursor range\n");
80 FIXME("Define vertical mouse cursor range\n");
83 FIXME("Define graphics mouse cursor\n");
86 FIXME("Define text mouse cursor\n");
89 TRACE("Read Mouse motion counters\n");
90 CX_reg(context) = (mouse_info.x - mouse_info.oldx) * (mouse_info.HMPratio / 8);
91 DX_reg(context) = (mouse_info.y - mouse_info.oldy) * (mouse_info.VMPratio / 8);
92 mouse_info.oldx = mouse_info.x;
93 mouse_info.oldy = mouse_info.y;
96 TRACE("Define mouse interrupt subroutine\n");
97 mouse_info.callmask = CX_reg(context);
98 mouse_info.callback = (FARPROC16)MAKESEGPTR(context->SegEs, LOWORD(context->Edx));
101 TRACE("Set mickey/pixel ratio\n");
102 mouse_info.HMPratio = CX_reg(context);
103 mouse_info.VMPratio = DX_reg(context);
106 FIXME("Define screen region for update\n");
109 INT_BARF(context,0x33);
115 WORD mask,but,x,y,mx,my;
118 static void MouseRelay(CONTEXT86 *context,void *mdata)
120 MCALLDATA *data = (MCALLDATA *)mdata;
121 CONTEXT86 ctx = *context;
123 ctx.Eax = data->mask;
129 ctx.SegCs = SELECTOROF(data->proc);
130 ctx.Eip = OFFSETOF(data->proc);
132 DPMI_CallRMProc(&ctx, NULL, 0, 0);
135 void WINAPI DOSVM_Int33Message(UINT message,WPARAM wParam,LPARAM lParam)
138 unsigned Height, Width, SX=1, SY=1;
140 if (!VGA_GetMode(&Height,&Width,NULL)) {
141 /* may need to do some coordinate scaling */
146 mouse_info.x = LOWORD(lParam) * SX;
147 mouse_info.y = HIWORD(lParam) * SY;
153 case WM_LBUTTONDBLCLK:
154 mouse_info.but |= 0x01;
156 mouse_info.llastx = mouse_info.x;
157 mouse_info.llasty = mouse_info.y;
158 mouse_info.lbcount++;
161 mouse_info.but &= ~0x01;
165 case WM_RBUTTONDBLCLK:
166 mouse_info.but |= 0x02;
168 mouse_info.rlastx = mouse_info.x;
169 mouse_info.rlasty = mouse_info.y;
170 mouse_info.rbcount++;
173 mouse_info.but &= ~0x02;
177 case WM_MBUTTONDBLCLK:
178 mouse_info.but |= 0x04;
182 mouse_info.but &= ~0x04;
187 if ((mask & mouse_info.callmask) && mouse_info.callback) {
188 MCALLDATA *data = calloc(1,sizeof(MCALLDATA));
189 data->proc = mouse_info.callback;
190 data->mask = mask & mouse_info.callmask;
191 data->but = mouse_info.but;
192 data->x = mouse_info.x;
193 data->y = mouse_info.y;
194 DOSVM_QueueEvent(-1, DOS_PRIORITY_MOUSE, MouseRelay, data);