Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using mouse wheel with MOUSE_MODE_CAPTURED is changing mouse position #29559

Closed
Zylann opened this issue Jun 6, 2019 · 1 comment · Fixed by #31107
Closed

Using mouse wheel with MOUSE_MODE_CAPTURED is changing mouse position #29559

Zylann opened this issue Jun 6, 2019 · 1 comment · Fixed by #31107

Comments

@Zylann
Copy link
Contributor

Zylann commented Jun 6, 2019

Godot 3.1.1
Windows 10 64 bits

I use get_viewport().get_mouse_position() in order to get a ray to the 3D world from within _physics_update. However, I found that if I use MOUSE_MODE_CAPTURED, scrolling the mouse wheel will make the function return bad coordinates, until you move the mouse again. I expect this should not happen, mouse wheel is not supposed to move the mouse in any way.

Project:
MousePositionWheel.zip
Run the main scene, notice the mouse position is correctly reported (most often near the center). Then use mouse wheel, you'll see it changes by a lot, until you move the mouse again.

@EmeraldSlash
Copy link

I encountered this issue with the _input method, as it's being called with the InputEventMouseMotion event every time the wheel is scrolled.

yamgent added a commit to yamgent/godot that referenced this issue Aug 5, 2019
WM_MOUSEWHEEL and WM_MOUSEHWHEEL report mouse coordinates relative to
the screen (see lParam in [1]), rather than to the window like the rest
of the mouse events.

The current code already makes adjustments to take that into account.

However, it only makes the adjustments if the mouse is not captured, and
the coordinates are always relative to the screen regardless of whether
the mouse is captured or not, so let's fix the code to always
consistently apply the adjustments.

This fixes godotengine#29559.

[1] - https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-mousewheel
@akien-mga akien-mga added this to the 3.2 milestone Aug 6, 2019
myhalibobo pushed a commit to myhalibobo/godot that referenced this issue Sep 3, 2019
WM_MOUSEWHEEL and WM_MOUSEHWHEEL report mouse coordinates relative to
the screen (see lParam in [1]), rather than to the window like the rest
of the mouse events.

The current code already makes adjustments to take that into account.

However, it only makes the adjustments if the mouse is not captured, and
the coordinates are always relative to the screen regardless of whether
the mouse is captured or not, so let's fix the code to always
consistently apply the adjustments.

This fixes godotengine#29559.

[1] - https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-mousewheel
pchasco pushed a commit to pchasco/godot that referenced this issue Oct 23, 2019
WM_MOUSEWHEEL and WM_MOUSEHWHEEL report mouse coordinates relative to
the screen (see lParam in [1]), rather than to the window like the rest
of the mouse events.

The current code already makes adjustments to take that into account.

However, it only makes the adjustments if the mouse is not captured, and
the coordinates are always relative to the screen regardless of whether
the mouse is captured or not, so let's fix the code to always
consistently apply the adjustments.

This fixes godotengine#29559.

[1] - https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-mousewheel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants