ReactOS 0.4.15-dev-5664-g3bf4ef6
mouse.c File Reference
#include <win32k.h>
Include dependency graph for mouse.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (UserInput)
 
WORD FASTCALL UserGetMouseButtonsState (VOID)
 
VOID NTAPI UserProcessMouseInput (PMOUSE_INPUT_DATA mid)
 
DWORD IntFixMouseInputButtons (DWORD dwFlags)
 
BOOL NTAPI UserSendMouseInput (MOUSEINPUT *pmi, BOOL bInjected)
 
VOID FASTCALL IntRemoveTrackMouseEvent (PDESKTOP pDesk)
 
BOOL FASTCALL IntQueryTrackMouseEvent (LPTRACKMOUSEEVENT lpEventTrack)
 
BOOL FASTCALL IntTrackMouseEvent (LPTRACKMOUSEEVENT lpEventTrack)
 
BOOL APIENTRY NtUserTrackMouseEvent (LPTRACKMOUSEEVENT lpEventTrack)
 
DWORD APIENTRY NtUserGetMouseMovePointsEx (UINT cbSize, LPMOUSEMOVEPOINT lpptIn, LPMOUSEMOVEPOINT lpptOut, int nBufPoints, DWORD resolution)
 

Variables

MOUSEMOVEPOINT gMouseHistoryOfMoves [64]
 
INT gcMouseHistoryOfMoves = 0
 

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserInput  )

◆ IntFixMouseInputButtons()

DWORD IntFixMouseInputButtons ( DWORD  dwFlags)

Definition at line 138 of file mouse.c.

139{
140 DWORD dwNewFlags;
141
142 if (!gspv.bMouseBtnSwap)
143 return dwFlags;
144
145 /* Buttons other than left and right are not affected */
148
149 /* Swap buttons */
151 dwNewFlags |= MOUSEEVENTF_RIGHTDOWN;
153 dwNewFlags |= MOUSEEVENTF_RIGHTUP;
155 dwNewFlags |= MOUSEEVENTF_LEFTDOWN;
157 dwNewFlags |= MOUSEEVENTF_LEFTUP;
158
159 return dwNewFlags;
160}
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL bMouseBtnSwap
Definition: sysparams.h:82
SPIVALUES gspv
Definition: sysparams.c:17
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define MOUSEEVENTF_LEFTUP
Definition: winuser.h:1175
#define MOUSEEVENTF_RIGHTUP
Definition: winuser.h:1177
#define MOUSEEVENTF_LEFTDOWN
Definition: winuser.h:1174
#define MOUSEEVENTF_RIGHTDOWN
Definition: winuser.h:1176

Referenced by UserSendMouseInput().

◆ IntQueryTrackMouseEvent()

BOOL FASTCALL IntQueryTrackMouseEvent ( LPTRACKMOUSEEVENT  lpEventTrack)

Definition at line 375 of file mouse.c.

377{
378 PDESKTOP pDesk;
379 PTHREADINFO pti;
380
382 pDesk = pti->rpdesk;
383
384 /* Always cleared with size set and return true. */
385 RtlZeroMemory(lpEventTrack , sizeof(TRACKMOUSEEVENT));
386 lpEventTrack->cbSize = sizeof(TRACKMOUSEEVENT);
387
388 if (pDesk->dwDTFlags & (DF_TME_LEAVE | DF_TME_HOVER) &&
389 pDesk->spwndTrack &&
390 pti->MessageQueue == pDesk->spwndTrack->head.pti->MessageQueue)
391 {
392 if (pDesk->htEx != HTCLIENT)
393 lpEventTrack->dwFlags |= TME_NONCLIENT;
394
395 if (pDesk->dwDTFlags & DF_TME_LEAVE)
396 lpEventTrack->dwFlags |= TME_LEAVE;
397
398 if (pDesk->dwDTFlags & DF_TME_HOVER)
399 {
400 lpEventTrack->dwFlags |= TME_HOVER;
401 lpEventTrack->dwHoverTime = pDesk->dwMouseHoverTime;
402 }
403 lpEventTrack->hwndTrack = UserHMGetHandle(pDesk->spwndTrack);
404 }
405 return TRUE;
406}
#define TRUE
Definition: types.h:120
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define TME_LEAVE
Definition: commctrl.h:4981
#define TME_NONCLIENT
Definition: commctrl.h:4982
struct tagTRACKMOUSEEVENT TRACKMOUSEEVENT
#define TME_HOVER
Definition: commctrl.h:4980
DWORD dwMouseHoverTime
Definition: desktop.h:34
PWND spwndTrack
Definition: desktop.h:31
DWORD htEx
Definition: desktop.h:32
DWORD dwDTFlags
Definition: desktop.h:12
struct _DESKTOP * rpdesk
Definition: win32.h:92
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:89
THRDESKHEAD head
Definition: ntuser.h:690
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define DF_TME_LEAVE
Definition: desktop.h:48
#define DF_TME_HOVER
Definition: desktop.h:47
#define HTCLIENT
Definition: winuser.h:2465

Referenced by NtUserTrackMouseEvent().

◆ IntRemoveTrackMouseEvent()

VOID FASTCALL IntRemoveTrackMouseEvent ( PDESKTOP  pDesk)

Definition at line 355 of file mouse.c.

357{
358 /* Generate a leave message */
359 if (pDesk->dwDTFlags & DF_TME_LEAVE)
360 {
361 UINT uMsg = (pDesk->htEx != HTCLIENT) ? WM_NCMOUSELEAVE : WM_MOUSELEAVE;
362 UserPostMessage(UserHMGetHandle(pDesk->spwndTrack), uMsg, 0, 0);
363 }
364 /* Kill the timer */
365 if (pDesk->dwDTFlags & DF_TME_HOVER)
367
368 /* Reset state */
370 pDesk->spwndTrack = NULL;
371}
#define NULL
Definition: types.h:112
unsigned int UINT
Definition: ndis.h:50
#define WM_MOUSELEAVE
Definition: commctrl.h:4975
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1346
BOOL FASTCALL IntKillTimer(PWND Window, UINT_PTR IDEvent, BOOL SystemTimer)
Definition: timer.c:573
#define ID_EVENT_SYSTIMER_MOUSEHOVER
Definition: timer.h:27
#define WM_NCMOUSELEAVE
Definition: winuser.h:1832

Referenced by IntSendDestroyMsg().

◆ IntTrackMouseEvent()

BOOL FASTCALL IntTrackMouseEvent ( LPTRACKMOUSEEVENT  lpEventTrack)

Definition at line 410 of file mouse.c.

412{
413 PDESKTOP pDesk;
414 PTHREADINFO pti;
415 PWND pWnd;
416 POINT point;
417
419 pDesk = pti->rpdesk;
420
421 if (!(pWnd = UserGetWindowObject(lpEventTrack->hwndTrack)))
422 return FALSE;
423
424 if ( pDesk->spwndTrack != pWnd ||
425 (pDesk->htEx != HTCLIENT) ^ !!(lpEventTrack->dwFlags & TME_NONCLIENT) )
426 {
427 if ( lpEventTrack->dwFlags & TME_LEAVE && !(lpEventTrack->dwFlags & TME_CANCEL) )
428 {
429 UserPostMessage( lpEventTrack->hwndTrack,
431 0, 0);
432 }
433 TRACE("IntTrackMouseEvent spwndTrack %p pwnd %p\n", pDesk->spwndTrack, pWnd);
434 return TRUE;
435 }
436
437 /* Tracking spwndTrack same as pWnd */
438 if (lpEventTrack->dwFlags & TME_CANCEL) // Canceled mode.
439 {
440 if (lpEventTrack->dwFlags & TME_LEAVE)
441 pDesk->dwDTFlags &= ~DF_TME_LEAVE;
442
443 if (lpEventTrack->dwFlags & TME_HOVER)
444 {
445 if (pDesk->dwDTFlags & DF_TME_HOVER)
446 { // Kill hover timer.
448 pDesk->dwDTFlags &= ~DF_TME_HOVER;
449 }
450 }
451 }
452 else // Not Canceled.
453 {
454 if (lpEventTrack->dwFlags & TME_LEAVE)
455 pDesk->dwDTFlags |= DF_TME_LEAVE;
456
457 if (lpEventTrack->dwFlags & TME_HOVER)
458 {
459 pDesk->dwDTFlags |= DF_TME_HOVER;
460
461 if (!lpEventTrack->dwHoverTime || lpEventTrack->dwHoverTime == HOVER_DEFAULT)
462 pDesk->dwMouseHoverTime = gspv.iMouseHoverTime; // use the system default hover time-out.
463 else
464 pDesk->dwMouseHoverTime = lpEventTrack->dwHoverTime;
465 // Start timer for the hover period.
467 // Get windows thread message points.
468 point = pWnd->head.pti->ptLast;
469 // Set desktop mouse hover from the system default hover rectangle.
475 }
476 }
477 return TRUE;
478}
#define FALSE
Definition: types.h:117
POINTL point
Definition: edittest.c:50
#define TME_CANCEL
Definition: commctrl.h:4984
#define HOVER_DEFAULT
Definition: commctrl.h:4986
#define TRACE(s)
Definition: solgame.cpp:4
RECT rcMouseHover
Definition: desktop.h:33
LONG y
Definition: windef.h:330
LONG x
Definition: windef.h:329
INT iMouseHoverWidth
Definition: sysparams.h:85
INT iMouseHoverHeight
Definition: sysparams.h:86
INT iMouseHoverTime
Definition: sysparams.h:87
Definition: ntuser.h:689
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:134
FORCEINLINE VOID RECTL_vSetRect(_Out_ RECTL *prcl, _In_ LONG left, _In_ LONG top, _In_ LONG right, _In_ LONG bottom)
Definition: rect.h:5
VOID CALLBACK SystemTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
Definition: timer.c:280
UINT_PTR FASTCALL IntSetTimer(PWND Window, UINT_PTR IDEvent, UINT Elapse, TIMERPROC TimerFunc, INT Type)
Definition: timer.c:177
#define TMRF_SYSTEM
Definition: timer.h:20

Referenced by NtUserTrackMouseEvent().

◆ NtUserGetMouseMovePointsEx()

DWORD APIENTRY NtUserGetMouseMovePointsEx ( UINT  cbSize,
LPMOUSEMOVEPOINT  lpptIn,
LPMOUSEMOVEPOINT  lpptOut,
int  nBufPoints,
DWORD  resolution 
)

Definition at line 543 of file mouse.c.

549{
550 MOUSEMOVEPOINT Safeppt;
551 //BOOL Hit;
552 INT iRet = -1;
553
554 TRACE("Enter NtUserGetMouseMovePointsEx\n");
555
556 if ((cbSize != sizeof(MOUSEMOVEPOINT)) || (nBufPoints < 0) || (nBufPoints > 64))
557 {
559 return (DWORD)-1;
560 }
561
562 if (!lpptIn || (!lpptOut && nBufPoints))
563 {
565 return (DWORD)-1;
566 }
567
569 {
570 ProbeForRead(lpptIn, cbSize, 1);
571 RtlCopyMemory(&Safeppt, lpptIn, cbSize);
572 }
574 {
576 _SEH2_YIELD(return (DWORD)-1);
577 }
578 _SEH2_END;
579
581
582 // http://msdn.microsoft.com/en-us/library/ms646259(v=vs.85).aspx
583 // This explains the math issues in transforming points.
584 iRet = gcMouseHistoryOfMoves; // FIFO is forward so retrieve backward.
585 //Hit = FALSE;
586 do
587 {
588 if (Safeppt.x == 0 && Safeppt.y == 0)
589 break; // No test.
590 // Finds the point, it returns the last nBufPoints prior to and including the supplied point.
591 if (gMouseHistoryOfMoves[iRet].x == Safeppt.x && gMouseHistoryOfMoves[iRet].y == Safeppt.y)
592 {
593 if (Safeppt.time) // Now test time and it seems to be absolute.
594 {
595 if (Safeppt.time == gMouseHistoryOfMoves[iRet].time)
596 {
597 //Hit = TRUE;
598 break;
599 }
600 else
601 {
602 if (--iRet < 0) iRet = 63;
603 continue;
604 }
605 }
606 //Hit = TRUE;
607 break;
608 }
609 if (--iRet < 0) iRet = 63;
610 }
611 while (iRet != gcMouseHistoryOfMoves);
612
613 switch(resolution)
614 {
615 case GMMP_USE_DISPLAY_POINTS:
616 if (nBufPoints)
617 {
619 {
620 ProbeForWrite(lpptOut, cbSize, 1);
621 }
623 {
625 iRet = -1;
626 _SEH2_YIELD(goto cleanup);
627 }
628 _SEH2_END;
629 }
630 iRet = nBufPoints;
631 break;
632 case GMMP_USE_HIGH_RESOLUTION_POINTS:
633 break;
634 default:
636 iRet = -1;
637 }
638
639cleanup:
640 TRACE("Leave NtUserGetMouseMovePointsEx, ret=%i\n", iRet);
641 UserLeave();
642 return (DWORD)iRet;
643}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static void cleanup(void)
Definition: main.c:1335
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:254
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:238
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:37
MOUSEMOVEPOINT gMouseHistoryOfMoves[64]
Definition: mouse.c:13
INT gcMouseHistoryOfMoves
Definition: mouse.c:14
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28
#define ERROR_POINT_NOT_FOUND
Definition: winerror.h:693
#define ERROR_NOACCESS
Definition: winerror.h:578

◆ NtUserTrackMouseEvent()

BOOL APIENTRY NtUserTrackMouseEvent ( LPTRACKMOUSEEVENT  lpEventTrack)

Definition at line 482 of file mouse.c.

484{
485 TRACKMOUSEEVENT SafeTME;
486 BOOL bRet = FALSE;
487
488 TRACE("Enter NtUserTrackMouseEvent\n");
489
491 {
492 ProbeForRead(lpEventTrack, sizeof(TRACKMOUSEEVENT), 1);
493 RtlCopyMemory(&SafeTME, lpEventTrack, sizeof(TRACKMOUSEEVENT));
494 }
496 {
498 _SEH2_YIELD(return FALSE);
499 }
500 _SEH2_END;
501
502 if (SafeTME.cbSize != sizeof(TRACKMOUSEEVENT))
503 {
505 return FALSE;
506 }
507
509 {
511 return FALSE;
512 }
513
515
516 if (SafeTME.dwFlags & TME_QUERY)
517 {
518 bRet = IntQueryTrackMouseEvent(&SafeTME);
520 {
521 ProbeForWrite(lpEventTrack, sizeof(TRACKMOUSEEVENT), 1);
522 RtlCopyMemory(lpEventTrack, &SafeTME, sizeof(TRACKMOUSEEVENT));
523 }
525 {
527 bRet = FALSE;
528 }
529 _SEH2_END;
530 }
531 else
532 {
533 bRet = IntTrackMouseEvent(&SafeTME);
534 }
535
536 TRACE("Leave NtUserTrackMouseEvent, ret=%i\n", bRet);
537 UserLeave();
538 return bRet;
539}
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:245
#define TME_QUERY
Definition: commctrl.h:4983
BOOL FASTCALL IntTrackMouseEvent(LPTRACKMOUSEEVENT lpEventTrack)
Definition: mouse.c:410
BOOL FASTCALL IntQueryTrackMouseEvent(LPTRACKMOUSEEVENT lpEventTrack)
Definition: mouse.c:375
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583

◆ UserGetMouseButtonsState()

WORD FASTCALL UserGetMouseButtonsState ( VOID  )

Definition at line 22 of file mouse.c.

23{
24 WORD wRet = 0;
25
27
30
31 return wRet;
32}
unsigned short WORD
Definition: ntddk_ex.h:93
PSYSTEM_CURSORINFO IntGetSysCursorInfo(VOID)
Definition: cursoricon.c:187
BYTE gafAsyncKeyState[256 *2/8]
Definition: keyboard.c:13
#define IS_KEY_DOWN(ks, vk)
Definition: input.h:99
#define MK_SHIFT
Definition: winuser.h:2359
#define VK_CONTROL
Definition: winuser.h:2193
#define MK_CONTROL
Definition: winuser.h:2360
#define VK_SHIFT
Definition: winuser.h:2192

Referenced by co_UserDestroyWindow(), co_WinPosSetWindowPos(), IntDeactivateWindow(), UserAttachThreadInput(), UserDeleteW32Thread(), UserSendMouseInput(), and UserSetCursorPos().

◆ UserProcessMouseInput()

VOID NTAPI UserProcessMouseInput ( PMOUSE_INPUT_DATA  mid)

Definition at line 40 of file mouse.c.

41{
43
44 /* Convert MOUSE_INPUT_DATA to MOUSEINPUT. First init all fields. */
45 mi.dx = mid->LastX;
46 mi.dy = mid->LastY;
47 mi.mouseData = 0;
48 mi.dwFlags = 0;
49 mi.time = 0;
50 mi.dwExtraInfo = mid->ExtraInformation;
51
52 /* Mouse position */
53 if (mi.dx != 0 || mi.dy != 0)
55
56 /* Flags for absolute move */
57 if (mid->Flags & MOUSE_MOVE_ABSOLUTE)
61
62 /* Left button */
67
68 /* Middle button */
73
74 /* Right button */
79
80 /* Note: Next buttons use mouseData field so they cannot be sent in one call */
81
82 /* Button 4 */
84 {
86 mi.mouseData |= XBUTTON1;
87 }
89 {
91 mi.mouseData |= XBUTTON1;
92 }
93
94 /* If mouseData is used by button 4, send input and clear mi */
96 {
98 RtlZeroMemory(&mi, sizeof(mi));
99 }
100
101 /* Button 5 */
103 {
104 mi.mouseData |= XBUTTON2;
106 }
108 {
109 mi.mouseData |= XBUTTON2;
111 }
112
113 /* If mouseData is used by button 5, send input and clear mi */
115 {
117 RtlZeroMemory(&mi, sizeof(mi));
118 }
119
120 /* Mouse wheel */
121 if (mid->ButtonFlags & MOUSE_WHEEL)
122 {
123 mi.mouseData = mid->ButtonData;
125 }
126
127 /* If something has changed, send input to user */
128 if (mi.dwFlags)
130}
#define MOUSE_LEFT_BUTTON_DOWN
Definition: ntddmou.h:46
#define MOUSE_LEFT_BUTTON_UP
Definition: ntddmou.h:47
#define MOUSE_MIDDLE_BUTTON_DOWN
Definition: ntddmou.h:50
#define MOUSE_BUTTON_4_DOWN
Definition: ntddmou.h:52
#define MOUSE_BUTTON_5_UP
Definition: ntddmou.h:55
#define MOUSE_WHEEL
Definition: ntddmou.h:56
#define MOUSE_MOVE_ABSOLUTE
Definition: ntddmou.h:68
#define MOUSE_VIRTUAL_DESKTOP
Definition: ntddmou.h:69
#define MOUSE_BUTTON_5_DOWN
Definition: ntddmou.h:54
#define MOUSE_BUTTON_4_UP
Definition: ntddmou.h:53
#define MOUSE_RIGHT_BUTTON_UP
Definition: ntddmou.h:49
#define MOUSE_MIDDLE_BUTTON_UP
Definition: ntddmou.h:51
#define MOUSE_RIGHT_BUTTON_DOWN
Definition: ntddmou.h:48
USHORT ButtonData
Definition: ntddmou.h:83
USHORT ButtonFlags
Definition: ntddmou.h:82
USHORT Flags
Definition: ntddmou.h:78
ULONG ExtraInformation
Definition: ntddmou.h:89
DWORD dwFlags
Definition: winuser.h:3777
BOOL NTAPI UserSendMouseInput(MOUSEINPUT *pmi, BOOL bInjected)
Definition: mouse.c:168
static MONITORINFO mi
Definition: win.c:7338
#define MOUSEEVENTF_ABSOLUTE
Definition: winuser.h:1184
#define MOUSEEVENTF_WHEEL
Definition: winuser.h:1182
#define MOUSEEVENTF_MIDDLEUP
Definition: winuser.h:1179
#define MOUSEEVENTF_XUP
Definition: winuser.h:1181
#define MOUSEEVENTF_MOVE
Definition: winuser.h:1173
#define MOUSEEVENTF_XDOWN
Definition: winuser.h:1180
#define MOUSEEVENTF_VIRTUALDESK
Definition: winuser.h:1183
#define MOUSEEVENTF_MIDDLEDOWN
Definition: winuser.h:1178

Referenced by RawInputThreadMain().

◆ UserSendMouseInput()

BOOL NTAPI UserSendMouseInput ( MOUSEINPUT pmi,
BOOL  bInjected 
)

Definition at line 168 of file mouse.c.

169{
170 POINT ptCursor;
171 PSYSTEM_CURSORINFO pCurInfo;
172 MSG Msg;
174
175 ASSERT(pmi);
176
177 pCurInfo = IntGetSysCursorInfo();
178 ptCursor = gpsi->ptCursor;
180
182
183 if (pmi->dwFlags & MOUSEEVENTF_MOVE)
184 {
185 /* Mouse has changes position */
186 if (!(pmi->dwFlags & MOUSEEVENTF_ABSOLUTE))
187 {
188 /* Relative move */
189 ptCursor.x += pmi->dx;
190 ptCursor.y += pmi->dy;
191 }
192 else if (pmi->dwFlags & MOUSEEVENTF_VIRTUALDESK)
193 {
194 /* Absolute move in virtual screen units */
195 ptCursor.x = pmi->dx * UserGetSystemMetrics(SM_CXVIRTUALSCREEN) >> 16;
196 ptCursor.y = pmi->dy * UserGetSystemMetrics(SM_CYVIRTUALSCREEN) >> 16;
197 }
198 else
199 {
200 /* Absolute move in primary monitor units */
201 ptCursor.x = pmi->dx * UserGetSystemMetrics(SM_CXSCREEN) >> 16;
202 ptCursor.y = pmi->dy * UserGetSystemMetrics(SM_CYSCREEN) >> 16;
203 }
204 }
205
206 /* Init message fields */
207 Msg.wParam = UserGetMouseButtonsState();
208 Msg.lParam = MAKELPARAM(ptCursor.x, ptCursor.y);
209 Msg.pt = ptCursor;
210 Msg.time = pmi->time;
211 if (!Msg.time)
212 {
213 Msg.time = EngGetTickCount32();
214 }
215
216 /* Do GetMouseMovePointsEx FIFO. */
222 gcMouseHistoryOfMoves = 0; // 0 - 63 is 64, FIFO forwards.
223
224 /* Update cursor position */
226 {
227 UserSetCursorPos(ptCursor.x, ptCursor.y, bInjected, pmi->dwExtraInfo, TRUE);
228 }
229
231 pCurInfo->ButtonsDown |= MK_SHIFT;
232 else
233 pCurInfo->ButtonsDown &= ~MK_SHIFT;
234
236 pCurInfo->ButtonsDown |= MK_CONTROL;
237 else
238 pCurInfo->ButtonsDown &= ~MK_CONTROL;
239
240 /* Left button */
242 {
244 Msg.message = WM_LBUTTONDOWN;
245 pCurInfo->ButtonsDown |= MK_LBUTTON;
246 Msg.wParam |= MK_LBUTTON;
247 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
248 }
249 else if (dwFlags & MOUSEEVENTF_LEFTUP)
250 {
252 Msg.message = WM_LBUTTONUP;
253 pCurInfo->ButtonsDown &= ~MK_LBUTTON;
254 Msg.wParam &= ~MK_LBUTTON;
255 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
256 }
257
258 /* Middle button */
260 {
262 Msg.message = WM_MBUTTONDOWN;
263 pCurInfo->ButtonsDown |= MK_MBUTTON;
264 Msg.wParam |= MK_MBUTTON;
265 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
266 }
267 else if (dwFlags & MOUSEEVENTF_MIDDLEUP)
268 {
270 Msg.message = WM_MBUTTONUP;
271 pCurInfo->ButtonsDown &= ~MK_MBUTTON;
272 Msg.wParam &= ~MK_MBUTTON;
273 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
274 }
275
276 /* Right button */
278 {
280 Msg.message = WM_RBUTTONDOWN;
281 pCurInfo->ButtonsDown |= MK_RBUTTON;
282 Msg.wParam |= MK_RBUTTON;
283 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
284 }
285 else if (dwFlags & MOUSEEVENTF_RIGHTUP)
286 {
288 Msg.message = WM_RBUTTONUP;
289 pCurInfo->ButtonsDown &= ~MK_RBUTTON;
290 Msg.wParam &= ~MK_RBUTTON;
291 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
292 }
293
296 {
297 /* Fail because both types of events use the mouseData field */
298 WARN("Invalid flags!\n");
299 return FALSE;
300 }
301
302 /* X-Button (4 or 5) */
304 {
305 Msg.message = WM_XBUTTONDOWN;
306 if (pmi->mouseData & XBUTTON1)
307 {
308 SET_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON1, TRUE);
309 pCurInfo->ButtonsDown |= MK_XBUTTON1;
310 Msg.wParam |= MAKEWPARAM(MK_XBUTTON1, XBUTTON1);
311 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
312 }
313 if (pmi->mouseData & XBUTTON2)
314 {
315 SET_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON2, TRUE);
316 pCurInfo->ButtonsDown |= MK_XBUTTON2;
317 Msg.wParam |= MAKEWPARAM(MK_XBUTTON2, XBUTTON2);
318 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
319 }
320 }
321 else if (dwFlags & MOUSEEVENTF_XUP)
322 {
323 Msg.message = WM_XBUTTONUP;
324 if(pmi->mouseData & XBUTTON1)
325 {
326 SET_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON1, FALSE);
327 pCurInfo->ButtonsDown &= ~MK_XBUTTON1;
328 Msg.wParam &= ~MK_XBUTTON1;
329 Msg.wParam |= MAKEWPARAM(0, XBUTTON2);
330 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
331 }
332 if (pmi->mouseData & XBUTTON2)
333 {
334 SET_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON2, FALSE);
335 pCurInfo->ButtonsDown &= ~MK_XBUTTON2;
336 Msg.wParam &= ~MK_XBUTTON2;
337 Msg.wParam |= MAKEWPARAM(0, XBUTTON2);
338 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
339 }
340 }
341
342 /* Mouse wheel */
344 {
345 Msg.message = WM_MOUSEWHEEL;
346 Msg.wParam = MAKEWPARAM(pCurInfo->ButtonsDown, pmi->mouseData);
347 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
348 }
349
350 return TRUE;
351}
#define WARN(fmt,...)
Definition: debug.h:112
struct @1616 Msg[]
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
PSERVERINFO gpsi
Definition: imm.c:18
#define EngGetTickCount32()
Definition: eng.h:43
#define ASSERT(a)
Definition: mode.c:44
VOID FASTCALL co_MsqInsertMouseMessage(MSG *Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: msgqueue.c:580
PPROCESSINFO gppiInputProvider
Definition: ntuser.c:16
struct _THREADINFO * PTHREADINFO
Definition: ntwin32.h:6
DWORD time
Definition: winable.h:43
ULONG_PTR dwExtraInfo
Definition: winable.h:44
DWORD mouseData
Definition: winable.h:41
DWORD dwFlags
Definition: winable.h:42
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define WM_MOUSEWHEEL
Definition: treelist.c:96
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
BOOL UserSetCursorPos(INT x, INT y, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: cursoricon.c:238
#define SET_KEY_DOWN(ks, vk, down)
Definition: input.h:101
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:208
WORD FASTCALL UserGetMouseButtonsState(VOID)
Definition: mouse.c:22
DWORD IntFixMouseInputButtons(DWORD dwFlags)
Definition: mouse.c:138
#define MK_RBUTTON
Definition: winuser.h:2358
#define MAKEWPARAM(l, h)
Definition: winuser.h:3999
#define SM_CYVIRTUALSCREEN
Definition: winuser.h:1033
#define MAKELPARAM(l, h)
Definition: winuser.h:3998
#define SM_CYSCREEN
Definition: winuser.h:954
#define VK_RBUTTON
Definition: winuser.h:2181
#define WM_RBUTTONUP
Definition: winuser.h:1770
#define VK_MBUTTON
Definition: winuser.h:2183
#define WM_LBUTTONDOWN
Definition: winuser.h:1766
#define WM_RBUTTONDOWN
Definition: winuser.h:1769
#define SM_CXVIRTUALSCREEN
Definition: winuser.h:1032
#define MK_MBUTTON
Definition: winuser.h:2361
#define WM_LBUTTONUP
Definition: winuser.h:1767
#define MK_LBUTTON
Definition: winuser.h:2357
#define SM_CXSCREEN
Definition: winuser.h:953
#define WM_MBUTTONUP
Definition: winuser.h:1773
#define WM_MBUTTONDOWN
Definition: winuser.h:1772
#define VK_LBUTTON
Definition: winuser.h:2180

Referenced by co_UserSetCapture(), NtUserSendInput(), and UserProcessMouseInput().

Variable Documentation

◆ gcMouseHistoryOfMoves

INT gcMouseHistoryOfMoves = 0

Definition at line 14 of file mouse.c.

Referenced by NtUserGetMouseMovePointsEx(), and UserSendMouseInput().

◆ gMouseHistoryOfMoves

MOUSEMOVEPOINT gMouseHistoryOfMoves[64]

Definition at line 13 of file mouse.c.

Referenced by NtUserGetMouseMovePointsEx(), and UserSendMouseInput().