You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
andrey0722 opened this issue
Jun 27, 2019
· 1 comment
Assignees
Labels
bugBug reports and bugfix pull requestsinputKeyboard, joystick or mouseverifiedReproduced or otherwise verified bugsWindowsWin32 specific (not Cygwin or WSL)
One window is created with CursorPosCallback and MouseButtonCallback set
on left mouse pressed GLFW_CURSOR_DISABLED mode is set
on left mouse released GLFW_CURSOR_NORMAL mode is set
When I press left mouse during rapid mouse movement inside the window sometimes cursor hops to strange coords and smooth camera movement breaks. The most notable effect is achieved closer to window's border.
I debugged the library and tried to investigate the problem. Here what I found:
On left mouse pressed glfwSetInputMode(GLFW_CURSOR_DISABLED) centers real cursor and updates virtual. After that the windowProc on GLFW_CURSOR_DISABLED expects cursor somewhere around win32.lastCursorPos (which is already centered). But on first glfwPollEvents() call after disabling cursor it gets cursor around the original position where GLFW_CURSOR_DISABLED mode was set (which is not centered). And it gives incorrect delta, so virtual cursor hops far away. On next glfwPollEvents() calls the cursor position is around center as expected.
Once I've commented out centerCursor() call inside _glfwPlatformSetCursorMode this issue doesn't reproduce anymore. In this case when windowProc is called on the first time the win32.lastCursorPos is not centered and delta is correct.
My guess is that SetCursorPos has already centered cursor but there are some "old" WM_MOUSEMOVE messages in event queue (because cursor moves rapidly at the moment ofGLFW_CURSOR_DISABLED setting) that are not affected by cursor moved.
Looks like similar behavior already has been described in #193 and #1269.
What do you think? Is it a bug?
The text was updated successfully, but these errors were encountered:
In case it helps (even if the issue is about Windows): I found this issue googling for a similar problem I'm seeing in my macOS mouse-lock code (I also looked at how GLFW does it before). I'm seeing a similar jump for the deltaX/deltaY values for exactly one mouseMoved event shortly after mouse lock is activated, usually if the mouse was moving quickly while activating mouse-lock, but it's not the very first event in my case, but the second after mouse lock is activated.
Everything seems to work fine when simply not centering the mouse via CGWarpMouseCursorPosition (I thought that this would be a problem when the mouse is already at the edge of the screen when the mouse lock is activated, but it seems to work fine).
So what I'm doing now (which seems to fix the issue):
...but no CGWarpMouseCursorPosition at all! I've read somewhere else that the 'setMouseCoaliscingEnabled' would improve mouse event latency and/or frequency, but I haven't checked in detail whether this is actually true.
(...and what's missing is making the cursor invisible).
While mouse-lock is active in the mouseMoved event handler (and mouseDragged, etc...), I just look at [event deltaX] and [event deltaY] values (these are also correct when the mouse is at the edge of the screen at the start of mouse look, so it seems like CGAssociateMouseAndMouseCursorPosition() does the trick).
bugBug reports and bugfix pull requestsinputKeyboard, joystick or mouseverifiedReproduced or otherwise verified bugsWindowsWin32 specific (not Cygwin or WSL)
Hello,
I'm using GLFW 3.2.1 on Windows as follows:
GLFW_CURSOR_DISABLED
mode is setGLFW_CURSOR_NORMAL
mode is setWhen I press left mouse during rapid mouse movement inside the window sometimes cursor hops to strange coords and smooth camera movement breaks. The most notable effect is achieved closer to window's border.
I debugged the library and tried to investigate the problem. Here what I found:
On left mouse pressed
glfwSetInputMode(GLFW_CURSOR_DISABLED)
centers real cursor and updates virtual. After that thewindowProc
onGLFW_CURSOR_DISABLED
expects cursor somewhere aroundwin32.lastCursorPos
(which is already centered). But on firstglfwPollEvents()
call after disabling cursor it gets cursor around the original position whereGLFW_CURSOR_DISABLED
mode was set (which is not centered). And it gives incorrect delta, so virtual cursor hops far away. On nextglfwPollEvents()
calls the cursor position is around center as expected.Once I've commented out
centerCursor()
call inside_glfwPlatformSetCursorMode
this issue doesn't reproduce anymore. In this case whenwindowProc
is called on the first time thewin32.lastCursorPos
is not centered and delta is correct.My guess is that SetCursorPos has already centered cursor but there are some "old" WM_MOUSEMOVE messages in event queue (because cursor moves rapidly at the moment of
GLFW_CURSOR_DISABLED
setting) that are not affected by cursor moved.Looks like similar behavior already has been described in #193 and #1269.
What do you think? Is it a bug?
The text was updated successfully, but these errors were encountered: