Skip to content

Commit

Permalink
Fix cursor restoring behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
jushar committed Mar 11, 2017
1 parent 050a11e commit d6474bc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 14 additions & 4 deletions Client/core/CGUI.cpp
Expand Up @@ -761,8 +761,15 @@ void CLocalGUI::UpdateCursor ( void )
CCore::GetSingleton ().GetGame ()->GetPad ()->Disable ( false );
CCore::GetSingleton ().GetGame ()->GetPad ()->Clear ();*/

// Update stored position
POINT point;
GetCursorPos(&point);

m_StoredMousePosition.x = point.x;
m_StoredMousePosition.y = point.y;

// Set the mouse back to the center of the screen (to prevent the game from reacting to its movement)
SetCursorPos ( dwWidth / 2, dwHeight / 2 );
SetCursorPos ( dwWidth / 2, dwHeight / 2, false, false );

// Disable our mouse cursor
CSetCursorPosHook::GetSingleton ( ).EnableSetCursorPos ();
Expand Down Expand Up @@ -806,11 +813,14 @@ DWORD CLocalGUI::TranslateScanCodeToGUIKey ( DWORD dwCharacter )
}
}

void CLocalGUI::SetCursorPos ( int iX, int iY, bool bForce )
void CLocalGUI::SetCursorPos ( int iX, int iY, bool bForce, bool overrideStored )
{
// Update the stored position
m_StoredMousePosition.x = iX;
m_StoredMousePosition.y = iY;
if (overrideStored)
{
m_StoredMousePosition.x = iX;
m_StoredMousePosition.y = iY;
}

// Apply the position
if ( bForce )
Expand Down
2 changes: 1 addition & 1 deletion Client/core/CGUI.h
Expand Up @@ -61,7 +61,7 @@ class CLocalGUI : public CSingleton < CLocalGUI >
void Restore ( void );

void DrawMouseCursor ( void );
void SetCursorPos ( int iX, int iY, bool bForce = false );
void SetCursorPos ( int iX, int iY, bool bForce = false, bool overrideStored = true );

CConsole* GetConsole ( void );
void SetConsoleVisible ( bool bVisible );
Expand Down

0 comments on commit d6474bc

Please sign in to comment.