From 4e7d33729742d43c906a72f72d5264ab0b2e8c3c Mon Sep 17 00:00:00 2001 From: Nimetu Date: Wed, 20 Mar 2019 12:25:15 +0200 Subject: [PATCH] Changed: Only capture mouse for freeview or when button is held and mouse is moving --HG-- branch : develop --- code/ryzom/client/src/input.cpp | 36 +++++++++++++++------------------ code/ryzom/client/src/input.h | 3 --- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/code/ryzom/client/src/input.cpp b/code/ryzom/client/src/input.cpp index bf90d92bd..d554002ed 100644 --- a/code/ryzom/client/src/input.cpp +++ b/code/ryzom/client/src/input.cpp @@ -84,9 +84,6 @@ bool InitMouseWithCursor (bool hardware) MouseHardware = hardware; CViewPointer::setHWMouse( hardware ); - // Update mouse information - UpdateMouse (); - if (InitMouseFirstTime) { InitMouseFirstTime = false; @@ -129,16 +126,6 @@ bool IsMouseCursorHardware () return MouseHardware; } -// ********************************************************************************* -// Set the mouse mode. Call this method once per frame to update window size -void UpdateMouse () -{ - if (!Driver->isSystemCursorCaptured()) - { - DownMouseButtons = 0; - } -} - // ********************************************************************************* // Use this method to toggle the mouse (freelook <- cursor) void SetMouseFreeLook () @@ -160,7 +147,6 @@ void SetMouseFreeLook () pointer->show (false); } } - UpdateMouse (); } } @@ -202,7 +188,6 @@ void SetMouseCursor (bool updatePos) } MouseFreeLook = false; - UpdateMouse (); // Integer coordinates sint ix = (sint)(x*(float)width+0.5f); @@ -253,7 +238,6 @@ void SetMouseCursor (bool updatePos) void SetMouseSpeed (float speed) { MouseCursorSpeed = speed; - UpdateMouse (); } // ********************************************************************************* @@ -261,12 +245,27 @@ void SetMouseSpeed (float speed) void SetMouseAcceleration (uint accel) { MouseCursorAcceleration = accel; - UpdateMouse (); } // ********************************************************************************* void HandleSystemCursorCapture(const CEvent &event) { + static bool mouseCaptured = false; + + // capture on first move event after button is held down or free look is activated + if (event == EventMouseMoveId && !mouseCaptured && (MouseFreeLook || DownMouseButtons != 0)) + { + mouseCaptured = true; + Driver->setCapture(true); + } + + // release when button is released and not in free look + if (mouseCaptured && !MouseFreeLook && DownMouseButtons == 0) + { + mouseCaptured = false; + Driver->setCapture(false); + } + if (event == EventMouseDownId) { CEventMouseDown &em = (CEventMouseDown &) event; @@ -279,8 +278,6 @@ void HandleSystemCursorCapture(const CEvent &event) cursor->setPointerMiddleDown(em.Button == middleButton); cursor->setPointerRightDown(em.Button == rightButton); } - - Driver->setCapture(true); } if (event == EventMouseUpId) @@ -297,7 +294,6 @@ void HandleSystemCursorCapture(const CEvent &event) cursor->setPointerMiddleDown(false); cursor->setPointerRightDown(false); } - Driver->setCapture(false); } } diff --git a/code/ryzom/client/src/input.h b/code/ryzom/client/src/input.h index e7579d375..60288416d 100644 --- a/code/ryzom/client/src/input.h +++ b/code/ryzom/client/src/input.h @@ -44,9 +44,6 @@ bool InitMouseWithCursor (bool hardware); // Is mouse cursor hardware ? bool IsMouseCursorHardware (); -// Set the mouse mode. Call this method once per frame to update window size -void UpdateMouse (); - // Use this method to toggle the mouse (freelook <- cursor) void SetMouseFreeLook ();