1999-03-25 11:50:49 +01:00
|
|
|
|
/*
|
|
|
|
|
* DOS interrupt 33h handler
|
2002-03-10 00:29:33 +01:00
|
|
|
|
*
|
|
|
|
|
* Copyright 1999 Ove K<EFBFBD>ven
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-03-25 11:50:49 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2001-01-26 21:43:40 +01:00
|
|
|
|
#include <string.h>
|
2000-12-19 05:53:20 +01:00
|
|
|
|
|
2000-02-10 20:03:02 +01:00
|
|
|
|
#include "windef.h"
|
2000-12-19 05:53:20 +01:00
|
|
|
|
#include "winbase.h"
|
2000-02-10 20:03:02 +01:00
|
|
|
|
#include "wingdi.h"
|
1999-03-25 11:50:49 +01:00
|
|
|
|
#include "winuser.h"
|
|
|
|
|
#include "miscemu.h"
|
|
|
|
|
#include "dosexe.h"
|
2000-05-23 23:13:52 +02:00
|
|
|
|
#include "vga.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
|
#include "wine/debug.h"
|
1999-03-25 11:50:49 +01:00
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(int);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
|
2000-09-24 22:47:50 +02:00
|
|
|
|
static struct
|
|
|
|
|
{
|
1999-03-25 11:50:49 +01:00
|
|
|
|
DWORD x, y, but;
|
2002-01-29 03:51:47 +01:00
|
|
|
|
WORD lbcount, rbcount, rlastx, rlasty, llastx, llasty;
|
1999-03-25 11:50:49 +01:00
|
|
|
|
FARPROC16 callback;
|
|
|
|
|
WORD callmask;
|
2002-01-31 21:45:02 +01:00
|
|
|
|
WORD VMPratio, HMPratio, oldx, oldy;
|
2000-09-24 22:47:50 +02:00
|
|
|
|
} mouse_info;
|
1999-03-25 11:50:49 +01:00
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-11-06 20:57:49 +01:00
|
|
|
|
* DOSVM_Int33Handler (WINEDOS16.151)
|
1999-03-25 11:50:49 +01:00
|
|
|
|
*
|
|
|
|
|
* Handler for int 33h (MS MOUSE).
|
|
|
|
|
*/
|
2001-12-04 20:54:44 +01:00
|
|
|
|
void WINAPI DOSVM_Int33Handler( CONTEXT86 *context )
|
1999-03-25 11:50:49 +01:00
|
|
|
|
{
|
2000-09-26 01:53:07 +02:00
|
|
|
|
switch (LOWORD(context->Eax)) {
|
1999-03-25 11:50:49 +01:00
|
|
|
|
case 0x00:
|
1999-06-26 21:09:08 +02:00
|
|
|
|
TRACE("Reset mouse driver and request status\n");
|
2002-08-31 20:47:00 +02:00
|
|
|
|
SET_AX( context, 0xFFFF ); /* installed */
|
|
|
|
|
SET_BX( context, 3 ); /* # of buttons */
|
2000-09-24 22:47:50 +02:00
|
|
|
|
memset( &mouse_info, 0, sizeof(mouse_info) );
|
2002-01-31 21:45:02 +01:00
|
|
|
|
/* Set the default mickey/pixel ratio */
|
|
|
|
|
mouse_info.HMPratio = 8;
|
|
|
|
|
mouse_info.VMPratio = 16;
|
1999-03-25 11:50:49 +01:00
|
|
|
|
break;
|
2000-07-29 13:30:02 +02:00
|
|
|
|
case 0x01:
|
|
|
|
|
FIXME("Show mouse cursor\n");
|
|
|
|
|
break;
|
|
|
|
|
case 0x02:
|
|
|
|
|
FIXME("Hide mouse cursor\n");
|
|
|
|
|
break;
|
1999-03-25 11:50:49 +01:00
|
|
|
|
case 0x03:
|
2002-03-19 03:05:57 +01:00
|
|
|
|
TRACE("Return mouse position and button status: (%ld,%ld) and %ld\n",
|
|
|
|
|
mouse_info.x, mouse_info.y, mouse_info.but);
|
2002-08-31 20:47:00 +02:00
|
|
|
|
SET_BX( context, mouse_info.but );
|
|
|
|
|
SET_CX( context, mouse_info.x );
|
|
|
|
|
SET_DX( context, mouse_info.y );
|
1999-03-25 11:50:49 +01:00
|
|
|
|
break;
|
2000-05-23 23:13:52 +02:00
|
|
|
|
case 0x04:
|
|
|
|
|
FIXME("Position mouse cursor\n");
|
|
|
|
|
break;
|
2002-01-29 03:51:47 +01:00
|
|
|
|
case 0x05:
|
|
|
|
|
TRACE("Return Mouse button press Information for %s mouse button\n",
|
|
|
|
|
BX_reg(context) ? "right" : "left");
|
|
|
|
|
if (BX_reg(context)) {
|
2002-08-31 20:47:00 +02:00
|
|
|
|
SET_BX( context, mouse_info.rbcount );
|
2002-01-29 03:51:47 +01:00
|
|
|
|
mouse_info.rbcount = 0;
|
2002-08-31 20:47:00 +02:00
|
|
|
|
SET_CX( context, mouse_info.rlastx );
|
|
|
|
|
SET_DX( context, mouse_info.rlasty );
|
2002-01-29 03:51:47 +01:00
|
|
|
|
} else {
|
2002-08-31 20:47:00 +02:00
|
|
|
|
SET_BX( context, mouse_info.lbcount );
|
2002-01-29 03:51:47 +01:00
|
|
|
|
mouse_info.lbcount = 0;
|
2002-08-31 20:47:00 +02:00
|
|
|
|
SET_CX( context, mouse_info.llastx );
|
|
|
|
|
SET_DX( context, mouse_info.llasty );
|
2002-01-29 03:51:47 +01:00
|
|
|
|
}
|
2002-08-31 20:47:00 +02:00
|
|
|
|
SET_AX( context, mouse_info.but );
|
2002-01-29 03:51:47 +01:00
|
|
|
|
break;
|
2000-07-29 13:30:02 +02:00
|
|
|
|
case 0x07:
|
2003-07-08 23:11:52 +02:00
|
|
|
|
FIXME("Define horizontal mouse cursor range %d..%d\n",
|
|
|
|
|
CX_reg(context), DX_reg(context));
|
2000-07-29 13:30:02 +02:00
|
|
|
|
break;
|
|
|
|
|
case 0x08:
|
2003-07-08 23:11:52 +02:00
|
|
|
|
FIXME("Define vertical mouse cursor range %d..%d\n",
|
|
|
|
|
CX_reg(context), DX_reg(context));
|
2000-07-29 13:30:02 +02:00
|
|
|
|
break;
|
|
|
|
|
case 0x09:
|
|
|
|
|
FIXME("Define graphics mouse cursor\n");
|
|
|
|
|
break;
|
|
|
|
|
case 0x0A:
|
|
|
|
|
FIXME("Define text mouse cursor\n");
|
|
|
|
|
break;
|
2002-01-31 21:45:02 +01:00
|
|
|
|
case 0x0B:
|
|
|
|
|
TRACE("Read Mouse motion counters\n");
|
2002-08-31 20:47:00 +02:00
|
|
|
|
SET_CX( context, (mouse_info.x - mouse_info.oldx) * (mouse_info.HMPratio / 8) );
|
|
|
|
|
SET_DX( context, (mouse_info.y - mouse_info.oldy) * (mouse_info.VMPratio / 8) );
|
2002-01-31 21:45:02 +01:00
|
|
|
|
mouse_info.oldx = mouse_info.x;
|
|
|
|
|
mouse_info.oldy = mouse_info.y;
|
|
|
|
|
break;
|
2000-05-23 23:13:52 +02:00
|
|
|
|
case 0x0C:
|
1999-06-26 21:09:08 +02:00
|
|
|
|
TRACE("Define mouse interrupt subroutine\n");
|
2000-09-24 22:47:50 +02:00
|
|
|
|
mouse_info.callmask = CX_reg(context);
|
2000-12-13 21:20:09 +01:00
|
|
|
|
mouse_info.callback = (FARPROC16)MAKESEGPTR(context->SegEs, LOWORD(context->Edx));
|
1999-03-25 11:50:49 +01:00
|
|
|
|
break;
|
2002-01-31 21:45:02 +01:00
|
|
|
|
case 0x0F:
|
|
|
|
|
TRACE("Set mickey/pixel ratio\n");
|
|
|
|
|
mouse_info.HMPratio = CX_reg(context);
|
|
|
|
|
mouse_info.VMPratio = DX_reg(context);
|
|
|
|
|
break;
|
2000-07-29 13:30:02 +02:00
|
|
|
|
case 0x10:
|
|
|
|
|
FIXME("Define screen region for update\n");
|
|
|
|
|
break;
|
1999-03-25 11:50:49 +01:00
|
|
|
|
default:
|
|
|
|
|
INT_BARF(context,0x33);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
FARPROC16 proc;
|
|
|
|
|
WORD mask,but,x,y,mx,my;
|
|
|
|
|
} MCALLDATA;
|
|
|
|
|
|
2000-09-24 22:47:50 +02:00
|
|
|
|
static void MouseRelay(CONTEXT86 *context,void *mdata)
|
1999-03-25 11:50:49 +01:00
|
|
|
|
{
|
|
|
|
|
MCALLDATA *data = (MCALLDATA *)mdata;
|
1999-06-26 20:40:24 +02:00
|
|
|
|
CONTEXT86 ctx = *context;
|
1999-03-25 11:50:49 +01:00
|
|
|
|
|
2000-09-26 01:53:07 +02:00
|
|
|
|
ctx.Eax = data->mask;
|
|
|
|
|
ctx.Ebx = data->but;
|
|
|
|
|
ctx.Ecx = data->x;
|
|
|
|
|
ctx.Edx = data->y;
|
|
|
|
|
ctx.Esi = data->mx;
|
|
|
|
|
ctx.Edi = data->my;
|
|
|
|
|
ctx.SegCs = SELECTOROF(data->proc);
|
|
|
|
|
ctx.Eip = OFFSETOF(data->proc);
|
1999-03-25 11:50:49 +01:00
|
|
|
|
free(data);
|
|
|
|
|
DPMI_CallRMProc(&ctx, NULL, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-19 03:05:57 +01:00
|
|
|
|
static void QueueMouseRelay(DWORD mx, DWORD my, WORD mask)
|
|
|
|
|
{
|
|
|
|
|
mouse_info.x = mx;
|
|
|
|
|
mouse_info.y = my;
|
|
|
|
|
|
|
|
|
|
/* Left button down */
|
|
|
|
|
if(mask & 0x02) {
|
|
|
|
|
mouse_info.but |= 0x01;
|
|
|
|
|
mouse_info.llastx = mx;
|
|
|
|
|
mouse_info.llasty = my;
|
|
|
|
|
mouse_info.lbcount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Left button up */
|
|
|
|
|
if(mask & 0x04) {
|
|
|
|
|
mouse_info.but &= ~0x01;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Right button down */
|
|
|
|
|
if(mask & 0x08) {
|
|
|
|
|
mouse_info.but |= 0x02;
|
|
|
|
|
mouse_info.rlastx = mx;
|
|
|
|
|
mouse_info.rlasty = my;
|
|
|
|
|
mouse_info.rbcount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Right button up */
|
|
|
|
|
if(mask & 0x10) {
|
|
|
|
|
mouse_info.but &= ~0x02;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Middle button down */
|
|
|
|
|
if(mask & 0x20) {
|
|
|
|
|
mouse_info.but |= 0x04;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Middle button up */
|
|
|
|
|
if(mask & 0x40) {
|
|
|
|
|
mouse_info.but &= ~0x04;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((mask & mouse_info.callmask) && mouse_info.callback) {
|
|
|
|
|
MCALLDATA *data = calloc(1,sizeof(MCALLDATA));
|
|
|
|
|
data->proc = mouse_info.callback;
|
|
|
|
|
data->mask = mask & mouse_info.callmask;
|
|
|
|
|
data->but = mouse_info.but;
|
|
|
|
|
data->x = mouse_info.x;
|
|
|
|
|
data->y = mouse_info.y;
|
|
|
|
|
DOSVM_QueueEvent(-1, DOS_PRIORITY_MOUSE, MouseRelay, data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-04 20:54:44 +01:00
|
|
|
|
void WINAPI DOSVM_Int33Message(UINT message,WPARAM wParam,LPARAM lParam)
|
1999-03-25 11:50:49 +01:00
|
|
|
|
{
|
|
|
|
|
WORD mask = 0;
|
2000-05-23 23:13:52 +02:00
|
|
|
|
unsigned Height, Width, SX=1, SY=1;
|
1999-03-25 11:50:49 +01:00
|
|
|
|
|
2000-05-23 23:13:52 +02:00
|
|
|
|
if (!VGA_GetMode(&Height,&Width,NULL)) {
|
|
|
|
|
/* may need to do some coordinate scaling */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
if (Width)
|
2002-01-29 03:51:47 +01:00
|
|
|
|
SX = 640/Width;
|
2000-05-23 23:13:52 +02:00
|
|
|
|
if (!SX) SX=1;
|
|
|
|
|
}
|
2002-03-19 03:05:57 +01:00
|
|
|
|
|
1999-03-25 11:50:49 +01:00
|
|
|
|
switch (message) {
|
|
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
|
mask |= 0x01;
|
|
|
|
|
break;
|
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
|
case WM_LBUTTONDBLCLK:
|
|
|
|
|
mask |= 0x02;
|
|
|
|
|
break;
|
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
|
mask |= 0x04;
|
|
|
|
|
break;
|
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
|
case WM_RBUTTONDBLCLK:
|
|
|
|
|
mask |= 0x08;
|
|
|
|
|
break;
|
|
|
|
|
case WM_RBUTTONUP:
|
|
|
|
|
mask |= 0x10;
|
|
|
|
|
break;
|
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
|
case WM_MBUTTONDBLCLK:
|
|
|
|
|
mask |= 0x20;
|
|
|
|
|
break;
|
|
|
|
|
case WM_MBUTTONUP:
|
|
|
|
|
mask |= 0x40;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-19 03:05:57 +01:00
|
|
|
|
QueueMouseRelay(LOWORD(lParam) * SX,
|
|
|
|
|
HIWORD(lParam) * SY,
|
|
|
|
|
mask);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WINAPI DOSVM_Int33Console(MOUSE_EVENT_RECORD *record)
|
|
|
|
|
{
|
|
|
|
|
unsigned Height, Width;
|
|
|
|
|
WORD mask = 0;
|
|
|
|
|
BOOL newLeftButton = record->dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED;
|
|
|
|
|
BOOL oldLeftButton = mouse_info.but & 0x01;
|
|
|
|
|
BOOL newRightButton = record->dwButtonState & RIGHTMOST_BUTTON_PRESSED;
|
|
|
|
|
BOOL oldRightButton = mouse_info.but & 0x02;
|
|
|
|
|
BOOL newMiddleButton = record->dwButtonState & FROM_LEFT_2ND_BUTTON_PRESSED;
|
|
|
|
|
BOOL oldMiddleButton = mouse_info.but & 0x04;
|
|
|
|
|
|
|
|
|
|
if(newLeftButton && !oldLeftButton)
|
|
|
|
|
mask |= 0x02;
|
|
|
|
|
else if(!newLeftButton && oldLeftButton)
|
|
|
|
|
mask |= 0x04;
|
|
|
|
|
|
|
|
|
|
if(newRightButton && !oldRightButton)
|
|
|
|
|
mask |= 0x08;
|
|
|
|
|
else if(!newRightButton && oldRightButton)
|
|
|
|
|
mask |= 0x10;
|
|
|
|
|
|
|
|
|
|
if(newMiddleButton && !oldMiddleButton)
|
|
|
|
|
mask |= 0x20;
|
|
|
|
|
else if(!newMiddleButton && oldMiddleButton)
|
|
|
|
|
mask |= 0x40;
|
2002-11-24 23:15:56 +01:00
|
|
|
|
|
|
|
|
|
if (VGA_GetAlphaMode(&Width, &Height))
|
|
|
|
|
QueueMouseRelay( 640 / Width * record->dwMousePosition.X,
|
|
|
|
|
200 / Height * record->dwMousePosition.Y,
|
|
|
|
|
mask );
|
1999-03-25 11:50:49 +01:00
|
|
|
|
}
|