-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Don't transform relative values when using MOUSE_MODE_CAPTURED #57264
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me. Probably need to be mentioned in the InputEventMouseMotion
docs to avoid any confusion.
We've discussed this in the Input PR meeting and basically the result of the discussion is:
And in both you need the GUI context, so you can't use the raw input. So we think the best solution would be to add a global_relative property (similar to global_position) that is unscaled, and you use the one that best works for your needs. |
I tend to agree with reduz's opinion here. There isn't a single good behavior for relative mouse movement that covers all use cases. This also allows implementing this feature/fix without having to break compatibility in any way, now that 4.0 is released. That said, |
This is still an issue, and a clear simple solution has been given over 19 months ago. You have to apply a hacky workaround for this in client code in order to "unscale" it (which is the value that you will always want when using raw input). When you interact with UI stuff you are not using raw input because raw input does not contain the mouse pointer ballistics. So I don't understand what situation you mentioned in your meeting. |
I'm not sure I have fully wrapped my head around every possible use case in a 2D / UI scenario, but at least in a 3D game scenario you never want to scale this value. It is not a minor issue either, if careless developers default to the scaling behaviour for mouse input, it will be perceived as very broken by players and this could easily tarnish the reputation of the engine if it becomes a common issue for games made with Godot. Even if there are cases where the scaled behaviour is desired, I believe that defaulting to the scaling behaviour violates the Godot philosophy of making the common case easy and the rare case possible. Adding a work-around to apply scaling is a lot more intuitive than to "undo" the scaling, likewise it seems strange to me to have a default property that scales and a more specialized property that doesn't. If you absolutely must keep the behaviour of the current property, then I would suggest to simply call the new unscaled property "delta" or "raw_delta" and make it clear in the comments for this and the "relative" property what the differences are and when you want to use which. All that aside I do agree that "unscaled_relative" would be a lot less potentially confusing than "global_relative", but neither is really good IMO for something that is the expected default behaviour. |
I've tried to add However, it doesn't seem to work for some reason. The values are always Testing project for the above branch: test_unscaled_relative_input.zip simplescreenrecorder-2024-01-26_00.00.00.mp4 |
@Calinou I believe I see the reason why you are seeing zeros. Collapsed to avoid noise
If I add the lines mm->set_relative_unscaled(get_relative_unscaled());
mm->set_velocity_unscaled(get_velocity_unscaled()); to |
When
MOUSE_MODE_CAPTURED
is used,InputEventMouseMotion
'srelative
property provides raw mouse motion data. Therefore, this data should not be transformed by the current Viewport transform.This PR ensures that
InputEventMouseMotion
'srelative
data is not transformed when usingMOUSE_MODE_CAPTURED
i.e. when it contains raw mouse motion data.Fixes #49734
Fixes #54818