support for mouse wheels and 4th and 5th mouse button (WM_MOUSEWHEEL, WM_XBUTTON*)

svn path=/trunk/; revision=6172
This commit is contained in:
Thomas Bluemel 2003-09-28 00:26:13 +00:00
parent 719909479f
commit 7871924668
4 changed files with 118 additions and 31 deletions

View file

@ -4343,6 +4343,10 @@ extern "C" {
#define MK_XBUTTON1 (0x0020) #define MK_XBUTTON1 (0x0020)
#define MK_XBUTTON2 (0x0040) #define MK_XBUTTON2 (0x0040)
/* XButton values */
#define XBUTTON1 (0x0001)
#define XBUTTON2 (0x0002)
/* WNDCLASS structure */ /* WNDCLASS structure */
#define CS_BYTEALIGNCLIENT (4096) #define CS_BYTEALIGNCLIENT (4096)
#define CS_BYTEALIGNWINDOW (8192) #define CS_BYTEALIGNWINDOW (8192)

View file

@ -1122,7 +1122,7 @@ extern "C" {
#define WM_KEYFIRST (256) #define WM_KEYFIRST (256)
#define WM_KEYLAST (264) #define WM_KEYLAST (264)
#define WM_MOUSEFIRST (512) #define WM_MOUSEFIRST (512)
#define WM_MOUSELAST (521) #define WM_MOUSELAST (525)
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: mouse.c,v 1.42 2003/09/24 18:39:34 weiden Exp $ /* $Id: mouse.c,v 1.43 2003/09/28 00:26:13 weiden Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* PURPOSE: Mouse * PURPOSE: Mouse
@ -401,11 +401,13 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
BOOL Moved = FALSE; BOOL Moved = FALSE;
LONG mouse_ox, mouse_oy; LONG mouse_ox, mouse_oy;
LONG mouse_cx = 0, mouse_cy = 0; LONG mouse_cx = 0, mouse_cy = 0;
LONG dScroll = 0;
HDC hDC; HDC hDC;
PDC dc; PDC dc;
PSURFOBJ SurfObj; PSURFOBJ SurfObj;
PSURFGDI SurfGDI; PSURFGDI SurfGDI;
RECTL MouseRect; RECTL MouseRect;
WORD wp;
MSG Msg; MSG Msg;
LARGE_INTEGER LargeTickCount; LARGE_INTEGER LargeTickCount;
ULONG TickCount; ULONG TickCount;
@ -464,9 +466,11 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
MouseMoveAdded = FALSE; MouseMoveAdded = FALSE;
//PrintInputData(i, Data[i]);
if (Data[i].ButtonFlags != 0) if (Data[i].ButtonFlags != 0)
{ {
wp = 0;
if ((Data[i].ButtonFlags & MOUSE_LEFT_BUTTON_DOWN) > 0) if ((Data[i].ButtonFlags & MOUSE_LEFT_BUTTON_DOWN) > 0)
{ {
/* insert WM_MOUSEMOVE messages before Button down messages */ /* insert WM_MOUSEMOVE messages before Button down messages */
@ -509,6 +513,41 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
else else
Msg.message = CurInfo->SwapButtons ? WM_LBUTTONDOWN : WM_RBUTTONDOWN; Msg.message = CurInfo->SwapButtons ? WM_LBUTTONDOWN : WM_RBUTTONDOWN;
} }
if ((Data[i].ButtonFlags & MOUSE_BUTTON_4_DOWN) > 0)
{
/* insert WM_MOUSEMOVE messages before Button down messages */
if ((0 != Data[i].LastX) || (0 != Data[i].LastY))
{
MsqInsertSystemMessage(&Msg, FALSE);
MouseMoveAdded = TRUE;
}
CurInfo->ButtonsDown |= MK_XBUTTON1;
if(IntDetectDblClick(CurInfo, TickCount))
{
Msg.message = WM_XBUTTONDBLCLK;
wp = XBUTTON1;
}
else
Msg.message = WM_XBUTTONDOWN;
}
if ((Data[i].ButtonFlags & MOUSE_BUTTON_5_DOWN) > 0)
{
/* insert WM_MOUSEMOVE messages before Button down messages */
if ((0 != Data[i].LastX) || (0 != Data[i].LastY))
{
MsqInsertSystemMessage(&Msg, FALSE);
MouseMoveAdded = TRUE;
}
CurInfo->ButtonsDown |= MK_XBUTTON2;
if(IntDetectDblClick(CurInfo, TickCount))
{
Msg.message = WM_XBUTTONDBLCLK;
wp = XBUTTON2;
}
else
Msg.message = WM_XBUTTONDOWN;
}
if ((Data[i].ButtonFlags & MOUSE_LEFT_BUTTON_UP) > 0) if ((Data[i].ButtonFlags & MOUSE_LEFT_BUTTON_UP) > 0)
{ {
@ -525,33 +564,53 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
CurInfo->ButtonsDown &= CurInfo->SwapButtons ? ~MK_LBUTTON : ~MK_RBUTTON; CurInfo->ButtonsDown &= CurInfo->SwapButtons ? ~MK_LBUTTON : ~MK_RBUTTON;
Msg.message = CurInfo->SwapButtons ? WM_LBUTTONUP : WM_RBUTTONUP; Msg.message = CurInfo->SwapButtons ? WM_LBUTTONUP : WM_RBUTTONUP;
} }
if ((Data[i].ButtonFlags & MOUSE_BUTTON_4_UP) > 0)
Moved = (0 != mouse_cx) || (0 != mouse_cy);
if(Moved && MouseEnabled)
{ {
if (!CurInfo->SafetySwitch && !CurInfo->SafetySwitch2 && CurInfo->ButtonsDown &= ~MK_XBUTTON1;
((mouse_ox != CurInfo->x) || (mouse_oy != CurInfo->y))) Msg.message = WM_XBUTTONUP;
{
ExAcquireFastMutexUnsafe(&CurInfo->CursorMutex);
SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect);
ExReleaseFastMutexUnsafe(&CurInfo->CursorMutex);
mouse_cx = 0;
mouse_cy = 0;
}
} }
if ((Data[i].ButtonFlags & MOUSE_BUTTON_5_UP) > 0)
Msg.wParam = CurInfo->ButtonsDown;
MsqInsertSystemMessage(&Msg, FALSE);
/* insert WM_MOUSEMOVE messages after Button up messages */
if(!MouseMoveAdded && Moved)
{ {
Msg.message = WM_MOUSEMOVE; CurInfo->ButtonsDown &= ~MK_XBUTTON2;
Msg.message = WM_XBUTTONUP;
}
if ((Data[i].ButtonFlags & MOUSE_WHEEL) > 0)
{
dScroll += (LONG)Data[i].ButtonData;
}
if (Data[i].ButtonFlags != MOUSE_WHEEL)
{
Moved = (0 != mouse_cx) || (0 != mouse_cy);
if(Moved && MouseEnabled)
{
if (!CurInfo->SafetySwitch && !CurInfo->SafetySwitch2 &&
((mouse_ox != CurInfo->x) || (mouse_oy != CurInfo->y)))
{
ExAcquireFastMutexUnsafe(&CurInfo->CursorMutex);
SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect);
ExReleaseFastMutexUnsafe(&CurInfo->CursorMutex);
mouse_cx = 0;
mouse_cy = 0;
}
}
Msg.wParam = CurInfo->ButtonsDown;
MsqInsertSystemMessage(&Msg, FALSE); MsqInsertSystemMessage(&Msg, FALSE);
MouseMoveAdded = TRUE;
/* insert WM_MOUSEMOVE messages after Button up messages */
if(!MouseMoveAdded && Moved)
{
Msg.message = WM_MOUSEMOVE;
MsqInsertSystemMessage(&Msg, FALSE);
MouseMoveAdded = TRUE;
}
} }
} }
} }
KeQueryTickCount(&LargeTickCount);
TickCount = LargeTickCount.u.LowPart;
/* If the mouse moved then move the pointer. */ /* If the mouse moved then move the pointer. */
if ((mouse_cx != 0 || mouse_cy != 0) && MouseEnabled) if ((mouse_cx != 0 || mouse_cy != 0) && MouseEnabled)
@ -559,8 +618,6 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
if(!MouseMoveAdded) if(!MouseMoveAdded)
{ {
KeQueryTickCount(&LargeTickCount);
TickCount = LargeTickCount.u.LowPart;
Msg.wParam = CurInfo->ButtonsDown; Msg.wParam = CurInfo->ButtonsDown;
Msg.message = WM_MOUSEMOVE; Msg.message = WM_MOUSEMOVE;
Msg.pt.x = CurInfo->x; Msg.pt.x = CurInfo->x;
@ -578,6 +635,18 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
ExReleaseFastMutexUnsafe(&CurInfo->CursorMutex); ExReleaseFastMutexUnsafe(&CurInfo->CursorMutex);
} }
} }
/* send WM_MOUSEWHEEL message */
if(dScroll && MouseEnabled)
{
Msg.message = WM_MOUSEWHEEL;
Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, dScroll);
Msg.lParam = MAKELPARAM(CurInfo->x, CurInfo->y);
Msg.time = TickCount;
Msg.pt.x = CurInfo->x;
Msg.pt.y = CurInfo->y;
MsqInsertSystemMessage(&Msg, FALSE);
}
ObDereferenceObject(InputWindowStation); ObDereferenceObject(InputWindowStation);
} }

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: msgqueue.c,v 1.22 2003/09/08 02:14:20 weiden Exp $ /* $Id: msgqueue.c,v 1.23 2003/09/28 00:26:13 weiden Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -206,7 +206,7 @@ MsqTranslateMouseMessage(HWND hWnd, UINT FilterLow, UINT FilterHigh,
return(FALSE); return(FALSE);
} }
if (Msg == WM_LBUTTONDBLCLK || Msg == WM_RBUTTONDBLCLK || Msg == WM_MBUTTONDBLCLK) if (Msg == WM_LBUTTONDBLCLK || Msg == WM_RBUTTONDBLCLK || Msg == WM_MBUTTONDBLCLK || Msg == WM_XBUTTONDBLCLK)
{ {
if (((*HitTest) != HTCLIENT) || !(IntGetClassLong(Window, GCL_STYLE, FALSE) & CS_DBLCLKS)) if (((*HitTest) != HTCLIENT) || !(IntGetClassLong(Window, GCL_STYLE, FALSE) & CS_DBLCLKS))
{ {
@ -227,13 +227,27 @@ MsqTranslateMouseMessage(HWND hWnd, UINT FilterLow, UINT FilterHigh,
if ((*HitTest) != HTCLIENT) if ((*HitTest) != HTCLIENT)
{ {
Msg += WM_NCMOUSEMOVE - WM_MOUSEMOVE; switch(Msg)
Message->Msg.wParam = *HitTest; {
case WM_MOUSEWHEEL:
break;
case WM_XBUTTONDOWN:
case WM_XBUTTONUP:
case WM_XBUTTONDBLCLK:
return FALSE;
default:
Msg += WM_NCMOUSEMOVE - WM_MOUSEMOVE;
Message->Msg.wParam = *HitTest;
break;
}
} }
else else
{ {
Point.x -= Window->ClientRect.left; if(Msg != WM_MOUSEWHEEL)
Point.y -= Window->ClientRect.top; {
Point.x -= Window->ClientRect.left;
Point.y -= Window->ClientRect.top;
}
} }
/* FIXME: Check message filter. */ /* FIXME: Check message filter. */