I want to lure the mouse in the middle of the window (for example, in the FPS game) using SetCursorPos .
The problem is that when I do this, my window receives WM_MOUSEMOVE, which at best cancels any movement that is intended for the user, and in the worst case enters into a feedback loop.
I considered reading the position using GetCursorPos and ignoring the message if it is the same as where I moved it using SetCursorPos. The problem with this approach is that the mouse is asynchronous. If the program ever lags, then GetCursorPos will return a value other than what I expected - and therefore it will not know to ignore the message.
Is there a good way to handle this problem?
source
share