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

Add API for raw mouse motion #4063

Merged
merged 3 commits into from
Feb 20, 2024
Merged

Add API for raw mouse motion #4063

merged 3 commits into from
Feb 20, 2024

Conversation

GiantBlargg
Copy link
Contributor

Raw mouse movement is unaccelerated and unclamped by screen boundaries, and does not relate to any position on the screen.
It is useful in certain situations such as draggable values and 3D cameras, where screen position does not matter.

2024-02-17.11-18-27.mp4

Added Event::MouseMoved for integrations to supply raw mouse movement.
Added Response:drag_motion to get the raw mouse movement, but will fall back to delta in case the integration does not supply it.

Nothing should be breaking, but third-party integrations that can send Event::MouseMoved should be updated to do so.

Based on #1614 but updated to the current version, and with better fallback behaviour.

Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach! The only thing that worries me is the "unspecified units" part of this, especially for DragValue, who's speed is defined as "How much the value changes when dragged one point (logical pixel)", which after this PR is no longer true.

@GiantBlargg
Copy link
Contributor Author

GiantBlargg commented Feb 18, 2024

I'm fine with reverting the changes to DragValue, my main goal was to add the plumbing to get the raw motion if the app wants it. For now I'm going to keep the changes to Custom3D as I feel that it's a good example of where someone might want to use raw motion.

As for unspecified units, I don't think there's a simple way to determine the relation between mouse movement and screen pixels, it can vary greatly depending on hardware and configuration. I still think it's a useful input to have though, (paired with a sensitivity slider?). In my use case the mouse is locked while dragging, so pointer delta only reports (0,0).

@emilk emilk added the egui label Feb 20, 2024
@emilk emilk merged commit b804857 into emilk:master Feb 20, 2024
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use DeviceEvent::MouseMotion to get mouse delta when mouse go out of screen.
2 participants