Skip to content

Commit

Permalink
Use correct macros to get the mouse position.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Hoikas committed Nov 11, 2024
1 parent 06e46e4 commit eac94a8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Windowsx.h>
#endif

#include "plInputManager.h"
#include "plPipeline.h"
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit eac94a8

Please sign in to comment.