Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(win32device): no freecam mouse look when the warp misses

Olcay Seygan3a3b0f100b00
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32Mouse.cpp b/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32Mouse.cpp
index 3d421a7ac..bc03d2771 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32Mouse.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32Mouse.cpp
@@ -489,7 +489,10 @@ void Win32Mouse::setVisibility(Bool visible)
}
/** The freecam's mouse look puts the pointer back in the middle of the window every frame. Never
- while another window is in front: the pointer is that window's then. */
+ while another window is in front: the pointer is that window's then. Nor where the middle is off
+ the monitor, as it is for a window bigger than the monitor: SetCursorPos stops the pointer at the
+ edge and still says yes, so every frame read a turn from the middle to the edge, and a 3840x2160
+ -freecam take on a 1080 monitor spun round looking straight up into black. */
Bool Win32Mouse::warpCursor( Int x, Int y )
{
if( ::GetForegroundWindow() != ApplicationHWnd )
@@ -499,6 +502,9 @@ Bool Win32Mouse::warpCursor( Int x, Int y )
POINT screen = { windowX, windowY };
if( !::ClientToScreen( ApplicationHWnd, &screen ) || !::SetCursorPos( screen.x, screen.y ) )
return FALSE;
+ POINT landed;
+ if( !::GetCursorPos( &landed ) || landed.x != screen.x || landed.y != screen.y )
+ return FALSE;
setPosition( x, y );
return TRUE;
}