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
Hello, I'm using the glfw 3.4 version by building with CMake. I found that when you set GLFW_CURSOR_DISABLED by glfwSetInputMode()in moving mouse, sometimes you will find that there is a big offset between the cursor position obtained from glfwGetCursorPos before and after glfwPollEvents is called. I test it on macOS 14.4, Windows 11 and Ubuntu 22.04 LTS, only ubuntu doesn't have this issue.
I found this issus may as same as #1523 and #2411, and when I remove _glfw.platform.setCursorPos(window, width / 2.0, height / 2.0); in _glfwCenterCursorInContentArea at input.c file, both macOS and Windows 11 are correct.
Let me describe what happens and when does this happen in video:
Show the basic interaction. (0:04~0:11)
After start moving my mouse to upper right corner, I set GLFW_CURSOR_DISABLED by press ctrl before stop moving mouse. And you can see the cube jumps to upper right corner immediately, then move back to center. Actually it should move to lower left corner.(0:15~0:17)
You can see the print message where the cursor hover at time 0:22: before poll events , the cursor position is (56, 529), and after poll events, the cursor position is (-288, 758). There is a huge offset between the two positions. (0:21~0:22)
At the 0:39~0:40, I do the same thing as 2 describes, and you can see that the cube obviously flashes in the upper right corner. (0:39~0:40)
At the 0:46, you can see a huge offset between two cursor positions, (89, 586) and (-222, 712). (0:46~0:47)
And macOS has the same issue:
mac_cursor_bug.mov
the cube jumps to the upper right corner then jumps back.
Expect Result
I also record a video which has a result that I expect (after remove _glfw.platform.setCursorPos(window, width / 2.0, height / 2.0); in _glfwCenterCursorInContentArea at input.c file):
correct_result.mp4
In this video you can see the cube always move but not jump.
For end user code my proposed solution would be to ignore the first few frames of input, or alternatively ignore large deltas during the first few frames.
If I get time I will investigate further. I think this is due to the cursor position being set to the middle when GLFW_CURSOR_DISABLED is on , but then an event being received which resets the cursor to the old position.
Problem
Hello, I'm using the glfw 3.4 version by building with CMake. I found that when you set
GLFW_CURSOR_DISABLED
byglfwSetInputMode()
in moving mouse, sometimes you will find that there is a big offset between the cursor position obtained fromglfwGetCursorPos
before and afterglfwPollEvents
is called. I test it on macOS 14.4, Windows 11 and Ubuntu 22.04 LTS, only ubuntu doesn't have this issue.I found this issus may as same as #1523 and #2411, and when I remove
_glfw.platform.setCursorPos(window, width / 2.0, height / 2.0);
in_glfwCenterCursorInContentArea
atinput.c
file, both macOS and Windows 11 are correct.Reproduce Problem
I push a test project to reproduce this issue. You can play with tag v0.0.1-cursor_bug to check this issue.
And I also record a video to show what the issue looks like (using Bongo cat Mver to show my mouse and keyboard):
In this video, I print my cursor position by
glfwGetCursorPos
before and afterglfwPollEvents
is called when cursor is inGLFW_CURSOR_DISABLED
state:win_cursor_bug.mp4
Let me describe what happens and when does this happen in video:
And macOS has the same issue:
mac_cursor_bug.mov
the cube jumps to the upper right corner then jumps back.
Expect Result
I also record a video which has a result that I expect (after remove
_glfw.platform.setCursorPos(window, width / 2.0, height / 2.0);
in_glfwCenterCursorInContentArea
atinput.c
file):correct_result.mp4
In this video you can see the cube always move but not jump.
Test Environment
What I want
The text was updated successfully, but these errors were encountered: