-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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 resources for accumulated mouse motion and mouse scroll #13915
Comments
Hi! I am interested in working on this issue, may it be assigned to me? |
@BackupMiles , usualy nobody assigns tasks in bevy, just write that you are working on it, and nobody else will waste their time. Just don't forget to write message if you change your mind |
Thank you for clarifying @bugsweeper, then I will gladly work on this issue 👍 |
Just a quick question: where would be a good place to ask more info about the project/code? |
Either in this issue or in #input-dev :) Just ping me. |
# Objective - Add the `AccumulatedMouseMotion` and `AccumulatedMouseScroll` resources to make it simpler to track mouse motion/scroll changes - Closes #13915 ## Solution - Created two resources, `AccumulatedMouseMotion` and `AccumulatedMouseScroll`, and a method that tracks the `MouseMotion` and `MouseWheel` events and accumulates their deltas every frame. - Also modified the mouse input example to show how to use the resources. ## Testing - Tested the changes by modifying an existing example to use the newly added resources, and moving/scrolling my trackpad around a ton. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Gino Valente <49806985+MrGVSV@users.noreply.github.com>
# Objective - Add the `AccumulatedMouseMotion` and `AccumulatedMouseScroll` resources to make it simpler to track mouse motion/scroll changes - Closes bevyengine#13915 ## Solution - Created two resources, `AccumulatedMouseMotion` and `AccumulatedMouseScroll`, and a method that tracks the `MouseMotion` and `MouseWheel` events and accumulates their deltas every frame. - Also modified the mouse input example to show how to use the resources. ## Testing - Tested the changes by modifying an existing example to use the newly added resources, and moving/scrolling my trackpad around a ton. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Gino Valente <49806985+MrGVSV@users.noreply.github.com>
# Objective - Add the `AccumulatedMouseMotion` and `AccumulatedMouseScroll` resources to make it simpler to track mouse motion/scroll changes - Closes bevyengine#13915 ## Solution - Created two resources, `AccumulatedMouseMotion` and `AccumulatedMouseScroll`, and a method that tracks the `MouseMotion` and `MouseWheel` events and accumulates their deltas every frame. - Also modified the mouse input example to show how to use the resources. ## Testing - Tested the changes by modifying an existing example to use the newly added resources, and moving/scrolling my trackpad around a ton. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Gino Valente <49806985+MrGVSV@users.noreply.github.com>
* Add press and release methods to `Buttonlike` * Add Axislike::send_value * Add DualAxislike::set_axis_pair * Change MockInput methods to take impl Buttonlike * Remove old form of input mocking * Clippy * Add workaround for bevyengine/bevy#13915 to tests * Remove silly test * Fix some doc tests * More simple fixes to doc tests * Wrong KeyCode variant * Update README to reflect 0.15 changes * Re-add a FetchUserInput utility trait for now * Fix redundant doc links * More test fixing * Fix doc links * Fix missing imports for tests * Fix panic in input_map benchmark * New documentation lint * Fix incorrect feature flag
What problem does this solve or what need does it fill?
When working with inputs from mice for gameplay purposes, it is very common to want an aggregate view of "how much did the mouse move this frame?" or "how much did the player scroll?".
This is primarily used for controlling camera positions, such as when zooming or panning a map, or when working with
What solution would you like?
Add two resources, each of which stores a simple
Vec2
:AccumulatedMouseMotion
andAccumulatedMouseScroll
. Reset them to zero at the start of each frame in a system, then sum the corresponding events.What alternative(s) have you considered?
Users can sum these events themselves, and replicate the code listed above. This is a waste of time / confusing to them, and it's quite possible to get the timing of this wrong, leading to laggy or buggy input data.
It's also quite plausible that users (like me, historically) end up doing this computation multiple times across different parts of their app, leading to wasteful and inconsistent results.
Additional context
I needed this functionality in
leafwing-input-manager
, and decided to solve it the right way in Leafwing-Studios/leafwing-input-manager#543. The code associated with theAccumulatorPlugin
can be ripped out and ported quite directly tobevy_input
.MouseScroll
is a bit of a wrinkle: there's two possible units that could be sent. Ultimately, for the context of "gameplay data about what the player's mouse did", I don't think we care, as long as the same amount of physical motion results in about the same amount of accumulation. We may want to apply some sort of scaling factor to convert, but I'm not familiar enough with this behavior to know how to test it to check.The text was updated successfully, but these errors were encountered: