Commit a65ef561 authored by Jukka Heinonen's avatar Jukka Heinonen Committed by Alexandre Julliard

Console mode DOS programs now receive mouse events.

Replaced GetMessage with PeekMessage, since MsgWaitForMultipleObjects is allowed to return spontaneously.
parent 53338721
......@@ -24,6 +24,7 @@
#include "wine/windef16.h"
#include "winbase.h" /* for LPSTARTUPINFO32A */
#include "winnt.h" /* for PCONTEXT */
#include "wincon.h" /* for MOUSE_EVENT_RECORD */
struct _DOSEVENT;
......@@ -105,6 +106,7 @@ extern void WINAPI DOSVM_Int31Handler(CONTEXT86*);
/* int33.c */
extern void WINAPI DOSVM_Int33Handler(CONTEXT86*);
extern void WINAPI DOSVM_Int33Message(UINT,WPARAM,LPARAM);
extern void WINAPI DOSVM_Int33Console(MOUSE_EVENT_RECORD*);
/* int67.c */
extern void WINAPI DOSVM_Int67Handler(CONTEXT86*);
......
......@@ -245,8 +245,20 @@ static void DOSVM_ProcessConsole(void)
}
DOSVM_Int09SendScan(scan,msg.Event.KeyEvent.uChar.AsciiChar);
break;
case MOUSE_EVENT:
DOSVM_Int33Console(&msg.Event.MouseEvent);
break;
case WINDOW_BUFFER_SIZE_EVENT:
FIXME("unhandled WINDOW_BUFFER_SIZE_EVENT.\n");
break;
case MENU_EVENT:
FIXME("unhandled MENU_EVENT.\n");
break;
case FOCUS_EVENT:
FIXME("unhandled FOCUS_EVENT.\n");
break;
default:
FIXME("unhandled console event: %d\n", msg.EventType);
FIXME("unknown console event: %d\n", msg.EventType);
}
}
}
......@@ -364,7 +376,7 @@ DWORD WINAPI DOSVM_Loop( LPVOID lpExtra )
DOSVM_ProcessConsole();
}
else if (waitret == WAIT_OBJECT_0 + 1) {
GetMessageA(&msg, 0, 0, 0);
while (PeekMessageA(&msg,0,0,0,PM_REMOVE)) {
if (msg.hwnd) {
/* it's a window message */
DOSVM_ProcessMessage(&msg);
......@@ -389,9 +401,13 @@ DWORD WINAPI DOSVM_Loop( LPVOID lpExtra )
}
}
}
else break;
}
else
{
ERR_(int)("MsgWaitForMultipleObjects returned unexpected value.\n");
return 0;
}
}
}
static WINE_EXCEPTION_FILTER(exception_handler)
......
......@@ -65,7 +65,8 @@ void WINAPI DOSVM_Int33Handler( CONTEXT86 *context )
FIXME("Hide mouse cursor\n");
break;
case 0x03:
TRACE("Return mouse position and button status\n");
TRACE("Return mouse position and button status: (%ld,%ld) and %ld\n",
mouse_info.x, mouse_info.y, mouse_info.but);
BX_reg(context) = mouse_info.but;
CX_reg(context) = mouse_info.x;
DX_reg(context) = mouse_info.y;
......@@ -148,6 +149,58 @@ static void MouseRelay(CONTEXT86 *context,void *mdata)
DPMI_CallRMProc(&ctx, NULL, 0, 0);
}
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);
}
}
void WINAPI DOSVM_Int33Message(UINT message,WPARAM wParam,LPARAM lParam)
{
WORD mask = 0;
......@@ -159,54 +212,68 @@ void WINAPI DOSVM_Int33Message(UINT message,WPARAM wParam,LPARAM lParam)
SX = 640/Width;
if (!SX) SX=1;
}
mouse_info.x = LOWORD(lParam) * SX;
mouse_info.y = HIWORD(lParam) * SY;
switch (message) {
case WM_MOUSEMOVE:
mask |= 0x01;
break;
case WM_LBUTTONDOWN:
case WM_LBUTTONDBLCLK:
mouse_info.but |= 0x01;
mask |= 0x02;
mouse_info.llastx = mouse_info.x;
mouse_info.llasty = mouse_info.y;
mouse_info.lbcount++;
break;
case WM_LBUTTONUP:
mouse_info.but &= ~0x01;
mask |= 0x04;
break;
case WM_RBUTTONDOWN:
case WM_RBUTTONDBLCLK:
mouse_info.but |= 0x02;
mask |= 0x08;
mouse_info.rlastx = mouse_info.x;
mouse_info.rlasty = mouse_info.y;
mouse_info.rbcount++;
break;
case WM_RBUTTONUP:
mouse_info.but &= ~0x02;
mask |= 0x10;
break;
case WM_MBUTTONDOWN:
case WM_MBUTTONDBLCLK:
mouse_info.but |= 0x04;
mask |= 0x20;
break;
case WM_MBUTTONUP:
mouse_info.but &= ~0x04;
mask |= 0x40;
break;
}
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);
}
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;
VGA_GetAlphaMode(&Width, &Height);
QueueMouseRelay(640 / Width * record->dwMousePosition.X,
200 / Height * record->dwMousePosition.Y,
mask);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment