From 6b47f11db64f216d2c75c39836c65410bc340f98 Mon Sep 17 00:00:00 2001 From: Jukka Heinonen Date: Mon, 27 Oct 2003 22:06:27 +0000 Subject: [PATCH] Clean up mouse driver implementation. --- dlls/winedos/int33.c | 218 ++++++++++++++++++++++++++----------------- 1 file changed, 134 insertions(+), 84 deletions(-) diff --git a/dlls/winedos/int33.c b/dlls/winedos/int33.c index 7f0a868cc2a..fc2c6bef5ad 100644 --- a/dlls/winedos/int33.c +++ b/dlls/winedos/int33.c @@ -35,13 +35,37 @@ WINE_DEFAULT_DEBUG_CHANNEL(int); static struct { - DWORD x, y, but; - WORD lbcount, rbcount, rlastx, rlasty, llastx, llasty; - FARPROC16 callback; - WORD callmask; - WORD VMPratio, HMPratio, oldx, oldy; + WORD x, y, but; + WORD lbcount, rbcount, rlastx, rlasty, llastx, llasty; + FARPROC16 callback; + WORD callmask; + WORD VMPratio, HMPratio, oldx, oldy; } mouse_info; + +/********************************************************************** + * INT33_ResetMouse + * + * Handler for: + * - subfunction 0x00 (reset mouse) + * - subfunction 0x21 (software reset) + */ +static void INT33_ResetMouse( CONTEXT86 *context ) +{ + memset( &mouse_info, 0, sizeof(mouse_info) ); + + /* Set the default mickey/pixel ratio */ + mouse_info.HMPratio = 8; + mouse_info.VMPratio = 16; + + if (context) + { + SET_AX( context, 0xFFFF ); /* driver installed */ + SET_BX( context, 3 ); /* number of buttons */ + } +} + + /********************************************************************** * DOSVM_Int33Handler (WINEDOS16.151) * @@ -49,86 +73,112 @@ static struct */ void WINAPI DOSVM_Int33Handler( CONTEXT86 *context ) { - switch (LOWORD(context->Eax)) { - case 0x00: - case 0x21: - TRACE("Reset mouse driver and request status\n"); - SET_AX( context, 0xFFFF ); /* installed */ - SET_BX( context, 3 ); /* # of buttons */ - memset( &mouse_info, 0, sizeof(mouse_info) ); - /* Set the default mickey/pixel ratio */ - mouse_info.HMPratio = 8; - mouse_info.VMPratio = 16; - break; - case 0x01: - FIXME("Show mouse cursor\n"); - break; - case 0x02: - FIXME("Hide mouse cursor\n"); - break; - case 0x03: - TRACE("Return mouse position and button status: (%ld,%ld) and %ld\n", - mouse_info.x, mouse_info.y, mouse_info.but); - SET_BX( context, mouse_info.but ); - SET_CX( context, mouse_info.x ); - SET_DX( context, mouse_info.y ); - break; - case 0x04: - FIXME("Position mouse cursor\n"); - break; - case 0x05: - TRACE("Return Mouse button press Information for %s mouse button\n", - BX_reg(context) ? "right" : "left"); - if (BX_reg(context)) { - SET_BX( context, mouse_info.rbcount ); - mouse_info.rbcount = 0; - SET_CX( context, mouse_info.rlastx ); - SET_DX( context, mouse_info.rlasty ); - } else { - SET_BX( context, mouse_info.lbcount ); - mouse_info.lbcount = 0; - SET_CX( context, mouse_info.llastx ); - SET_DX( context, mouse_info.llasty ); + switch (AX_reg(context)) + { + case 0x0000: + TRACE("Reset mouse driver and request status\n"); + INT33_ResetMouse( context ); + break; + + case 0x0001: + FIXME("Show mouse cursor\n"); + break; + + case 0x0002: + FIXME("Hide mouse cursor\n"); + break; + + case 0x0003: + TRACE("Return mouse position and button status: (%d,%d) and %d\n", + mouse_info.x, mouse_info.y, mouse_info.but); + SET_BX( context, mouse_info.but ); + SET_CX( context, mouse_info.x ); + SET_DX( context, mouse_info.y ); + break; + + case 0x0004: + FIXME("Position mouse cursor\n"); + break; + + case 0x0005: + TRACE("Return Mouse button press Information for %s mouse button\n", + BX_reg(context) ? "right" : "left"); + if (BX_reg(context)) + { + SET_BX( context, mouse_info.rbcount ); + mouse_info.rbcount = 0; + SET_CX( context, mouse_info.rlastx ); + SET_DX( context, mouse_info.rlasty ); + } + else + { + SET_BX( context, mouse_info.lbcount ); + mouse_info.lbcount = 0; + SET_CX( context, mouse_info.llastx ); + SET_DX( context, mouse_info.llasty ); + } + SET_AX( context, mouse_info.but ); + break; + + case 0x0007: + FIXME("Define horizontal mouse cursor range %d..%d\n", + CX_reg(context), DX_reg(context)); + break; + + case 0x0008: + FIXME("Define vertical mouse cursor range %d..%d\n", + CX_reg(context), DX_reg(context)); + break; + + case 0x0009: + FIXME("Define graphics mouse cursor\n"); + break; + + case 0x000A: + FIXME("Define text mouse cursor\n"); + break; + + case 0x000B: + TRACE("Read Mouse motion counters\n"); + { + int dx = ((int)mouse_info.x - (int)mouse_info.oldx) + * (mouse_info.HMPratio / 8); + int dy = ((int)mouse_info.y - (int)mouse_info.oldy) + * (mouse_info.VMPratio / 8); + + SET_CX( context, (WORD)dx ); + SET_DX( context, (WORD)dy ); + + mouse_info.oldx = mouse_info.x; + mouse_info.oldy = mouse_info.y; + } + break; + + case 0x000C: + TRACE("Define mouse interrupt subroutine\n"); + mouse_info.callmask = CX_reg(context); + mouse_info.callback = (FARPROC16)MAKESEGPTR(context->SegEs, + DX_reg(context)); + break; + + case 0x000F: + TRACE("Set mickey/pixel ratio\n"); + mouse_info.HMPratio = CX_reg(context); + mouse_info.VMPratio = DX_reg(context); + break; + + case 0x0010: + FIXME("Define screen region for update\n"); + break; + + case 0x0021: + TRACE("Software reset\n"); + INT33_ResetMouse( context ); + break; + + default: + INT_BARF(context,0x33); } - SET_AX( context, mouse_info.but ); - break; - case 0x07: - FIXME("Define horizontal mouse cursor range %d..%d\n", - CX_reg(context), DX_reg(context)); - break; - case 0x08: - FIXME("Define vertical mouse cursor range %d..%d\n", - CX_reg(context), DX_reg(context)); - break; - case 0x09: - FIXME("Define graphics mouse cursor\n"); - break; - case 0x0A: - FIXME("Define text mouse cursor\n"); - break; - case 0x0B: - TRACE("Read Mouse motion counters\n"); - 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) ); - mouse_info.oldx = mouse_info.x; - mouse_info.oldy = mouse_info.y; - break; - case 0x0C: - TRACE("Define mouse interrupt subroutine\n"); - mouse_info.callmask = CX_reg(context); - mouse_info.callback = (FARPROC16)MAKESEGPTR(context->SegEs, LOWORD(context->Edx)); - break; - case 0x0F: - TRACE("Set mickey/pixel ratio\n"); - mouse_info.HMPratio = CX_reg(context); - mouse_info.VMPratio = DX_reg(context); - break; - case 0x10: - FIXME("Define screen region for update\n"); - break; - default: - INT_BARF(context,0x33); - } } typedef struct {