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

Fix mouse input events being read multiple times #418

Merged

Conversation

tim-blackbird
Copy link
Contributor

@tim-blackbird tim-blackbird commented Dec 2, 2023

@alice-i-cecile I saw you were busy moving at the moment (congrats c:), but this should fix the issue with Bevy 0.12.1 that people mentioned in the discord.

Fixes #285

Cleanest fix I could come up with was to replace the Events<T> in InputStreams with Vec<T>, and then collecting the events into that with an EventReader in update_action_state.

Comment on lines +62 to +63
let mouse_wheel: Vec<MouseWheel> = mouse_wheel
.get_reader()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no way to correctly read the events from here.
Same thing for the from_world method on MutableInputStreams .

Copy link
Contributor

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Thanks a ton <3 Yeah, I'm moving currently but I have a bit in a cafe and I'll merge and ship this.

@alice-i-cecile alice-i-cecile merged commit efcc6ba into Leafwing-Studios:main Dec 2, 2023
3 of 4 checks passed
@alice-i-cecile alice-i-cecile mentioned this pull request Dec 2, 2023
@keis
Copy link

keis commented Dec 2, 2023

I think this change broke the egui feature. I'm getting this compile error on 0.11.2

   --> /home/keis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leafwing-input-manager-0.11.2/src/systems.rs:130:9
    |
127 |       let (mouse_buttons, mouse_wheel) = if ctx.is_pointer_over_area() || ctx.wants_pointer_input() {
    |  ________________________________________-
128 | |         (None, None)
    | |         ------------ expected because of this
129 | |     } else {
130 | |         (mouse_buttons, mouse_wheel)
    | |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(Option<_>, Option<_>)`, found `(Option<&Input<MouseButton>>, Vec<MouseWheel>)`
131 | |     };
    | |_____- `if` and `else` have incompatible types
    |
    = note: expected tuple `(std::option::Option<_>, std::option::Option<_>)`
               found tuple `(std::option::Option<&Input<MouseButton>>, std::vec::Vec<bevy::input::mouse::MouseWheel>)`

@tim-blackbird
Copy link
Contributor Author

Sorry about that. I'll have another PR up in a bit.

@tim-blackbird
Copy link
Contributor Author

Got a fix for that here: #421.
In the mean time, it does compile if you keep the default features (ui and block_ui_interactions) enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Double-counting of mouse motion and mouse wheel events
3 participants