Vitaliy Margolen : dinput: Warp mouse each 10ms instead of dropping events.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jun 23 06:43:20 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 101e9e64e6748951bf0b733829de405defb354bd
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=101e9e64e6748951bf0b733829de405defb354bd

Author: Vitaliy Margolen <wine-patch at kievinfo.com>
Date:   Thu Jun 22 07:30:52 2006 -0600

dinput: Warp mouse each 10ms instead of dropping events.

---

 dlls/dinput/mouse.c |   24 +++++++++---------------
 1 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c
index 8bd395e..e626bf6 100644
--- a/dlls/dinput/mouse.c
+++ b/dlls/dinput/mouse.c
@@ -136,6 +136,7 @@ struct SysMouseImpl
     /* warping: whether we need to move mouse back to middle once we
      * reach window borders (for e.g. shooters, "surface movement" games) */
     WARP_STATUS		            need_warp;
+    DWORD                           last_warped;
     int				    acquired;
     HANDLE			    hEvent;
     CRITICAL_SECTION		    crit;
@@ -418,7 +419,6 @@ static LRESULT CALLBACK dinput_mouse_hoo
     MSLLHOOKSTRUCT *hook = (MSLLHOOKSTRUCT *)lparam;
     SysMouseImpl* This = (SysMouseImpl*) current_lock;
     DWORD dwCoop;
-    static long last_event = 0;
     int wdata;
 
     if (code != HC_ACTION) return CallNextHookEx( 0, code, wparam, lparam );
@@ -426,16 +426,6 @@ static LRESULT CALLBACK dinput_mouse_hoo
     EnterCriticalSection(&(This->crit));
     dwCoop = This->dwCoopLevel;
 
-    /* Only allow mouse events every 10 ms.
-     * This is to allow the cursor to start acceleration before
-     * the warps happen. But if it involves a mouse button event we
-     * allow it since we don't want to lose the clicks.
-     */
-    if (((GetCurrentTime() - last_event) < 10)
-        && wparam == WM_MOUSEMOVE)
-	goto end;
-    else last_event = GetCurrentTime();
-    
     /* Mouse moved -> send event if asked */
     if (This->hEvent)
         SetEvent(This->hEvent);
@@ -623,6 +613,8 @@ static HRESULT WINAPI SysMouseAImpl_Acqu
       MapWindowPoints(This->win, HWND_DESKTOP, &This->mapped_center, 1);
       TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
       SetCursorPos( This->mapped_center.x, This->mapped_center.y );
+      This->last_warped = GetCurrentTime();
+
 #ifdef MOUSE_HACK
       This->need_warp = WARP_DONE;
 #else
@@ -698,11 +690,12 @@ static HRESULT WINAPI SysMouseAImpl_GetD
     }
     
     /* Check if we need to do a mouse warping */
-    if (This->need_warp == WARP_NEEDED) {
+    if (This->need_warp == WARP_NEEDED && (GetCurrentTime() - This->last_warped > 10)) {
 	dinput_window_check(This);
 	TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
 	SetCursorPos( This->mapped_center.x, This->mapped_center.y );
-	
+        This->last_warped = GetCurrentTime();
+
 #ifdef MOUSE_HACK
 	This->need_warp = WARP_DONE;
 #else
@@ -791,11 +784,12 @@ static HRESULT WINAPI SysMouseAImpl_GetD
     LeaveCriticalSection(&(This->crit));
     
     /* Check if we need to do a mouse warping */
-    if (This->need_warp == WARP_NEEDED) {
+    if (This->need_warp == WARP_NEEDED && (GetCurrentTime() - This->last_warped > 10)) {
 	dinput_window_check(This);
 	TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
 	SetCursorPos( This->mapped_center.x, This->mapped_center.y );
-	
+        This->last_warped = GetCurrentTime();
+
 #ifdef MOUSE_HACK
 	This->need_warp = WARP_DONE;
 #else




More information about the wine-cvs mailing list