From eac94a86b8c6d4bca869ae0b8dcf20f97157ab4c Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 11 Nov 2024 18:59:45 -0500 Subject: [PATCH] Use correct macros to get the mouse position. MSDN says: Do not use the LOWORD or HIWORD macros to extract the x- and y- coordinates of the cursor position because these macros return incorrect results on systems with multiple monitors. Systems with multiple monitors can have negative x- and y- coordinates, and LOWORD and HIWORD treat the coordinates as unsigned quantities. --- .../Plasma/PubUtilLib/plInputCore/plInputManager.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp b/Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp index 4ebc51d90d..617d20d587 100644 --- a/Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp +++ b/Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp @@ -42,6 +42,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com // plInputManager.cpp #include "HeadSpin.h" #include "hsWindows.h" +#ifdef WIN32 +# include +#endif #include "plInputManager.h" #include "plPipeline.h" @@ -294,10 +297,10 @@ void plInputManager::HandleWin32ControlEvent(UINT message, WPARAM Wparam, LPARAM plIMouseYEventMsg* pYMsg = new plIMouseYEventMsg; plIMouseBEventMsg* pBMsg = new plIMouseBEventMsg; - pXMsg->fWx = LOWORD(Lparam); - pXMsg->fX = (float)LOWORD(Lparam) / (float)rect.right; - pYMsg->fWy = HIWORD(Lparam); - pYMsg->fY = (float)HIWORD(Lparam) / (float)rect.bottom; + pXMsg->fWx = GET_X_LPARAM(Lparam); + pXMsg->fX = (float)GET_X_LPARAM(Lparam) / (float)rect.right; + pYMsg->fWy = GET_Y_LPARAM(Lparam); + pYMsg->fY = (float)GET_Y_LPARAM(Lparam) / (float)rect.bottom; // Apply mouse scale // pXMsg->fX *= fMouseScale;