Skip to content

Commit a505115

Browse files
committed
Use GET_X_LPARAM instead of LOWORD (fixes #256)
Also GET_Y_LPARAM instead of HIWORD. See https://stackoverflow.com/questions/20666361/capture-mouse-position
1 parent 9796b3e commit a505115

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

Client/core/CGUI.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "StdInc.h"
1313
#include <game/CGame.h>
14+
#include <windowsx.h>
1415

1516
using std::string;
1617

@@ -541,7 +542,7 @@ bool CLocalGUI::ProcessMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPara
541542
return true;
542543

543544
case WM_MOUSEMOVE:
544-
pGUI->ProcessMouseInput(CGUI_MI_MOUSEPOS, LOWORD(lParam), HIWORD(lParam));
545+
pGUI->ProcessMouseInput(CGUI_MI_MOUSEPOS, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
545546
return true;
546547

547548
case WM_LBUTTONDOWN:

Client/core/CMouseControl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "StdInc.h"
1313
#include "CMouseControl.h"
14+
#include <windowsx.h>
1415
#include <game/CGame.h>
1516

1617
#define MOUSE_CONTROL_MULTIPLIER 35
@@ -78,7 +79,7 @@ bool CMouseControl::ProcessMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam)
7879

7980
// Let's calculate our mouse movement directions
8081
CVector2D resolution = g_pCore->GetGUI()->GetResolution();
81-
int iX = LOWORD(lParam), iY = HIWORD(lParam);
82+
int iX = GET_X_LPARAM(lParam), iY = GET_Y_LPARAM(lParam);
8283
float fX = (iX - resolution.fX * 0.5f) / resolution.fX;
8384

8485
fX *= MOUSE_CONTROL_MULTIPLIER;
@@ -137,4 +138,4 @@ void CMouseControl::ApplyAxes(CControllerState& cs)
137138

138139
cs.LeftStickX = m_usLeftStickX;
139140
cs.LeftStickY = m_usLeftStickY;
140-
}
141+
}

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "game/CAnimBlendAssocGroup.h"
1515
#include "game/CAnimBlendAssociation.h"
1616
#include "game/CAnimBlendHierarchy.h"
17+
#include <windowsx.h>
1718

1819
SString StringZeroPadout(const SString& strInput, uint uiPadoutSize)
1920
{
@@ -2475,8 +2476,8 @@ bool CClientGame::ProcessMessageForCursorEvents(HWND hwnd, UINT uMsg, WPARAM wPa
24752476
}
24762477
if (ucButtonHit != 0xFF)
24772478
{
2478-
int iX = LOWORD(lParam);
2479-
int iY = HIWORD(lParam);
2479+
int iX = GET_X_LPARAM(lParam);
2480+
int iY = GET_Y_LPARAM(lParam);
24802481

24812482
CVector2D vecResolution = g_pCore->GetGUI()->GetResolution();
24822483

@@ -2644,7 +2645,7 @@ bool CClientGame::ProcessMessageForCursorEvents(HWND hwnd, UINT uMsg, WPARAM wPa
26442645
{
26452646
case WM_MOUSEMOVE:
26462647
{
2647-
int iX = LOWORD(lParam), iY = HIWORD(lParam);
2648+
int iX = GET_X_LPARAM(lParam), iY = GET_Y_LPARAM(lParam);
26482649
static int iPreviousX = 0, iPreviousY = 0;
26492650
if (iX != iPreviousX || iY != iPreviousY)
26502651
{

0 commit comments

Comments
 (0)