Skip to content

Commit

Permalink
derive clone for Input (#3569)
Browse files Browse the repository at this point in the history
# Objective

- As part of exploring input event suppression in bevy_egui here: vladbat00/bevy_egui@53c1773
- I found that the only way to suppress events properly, is to allow to clone the relevant Input<Whatever>, and update with events manually from within the system. This cloned Input then is discarded, the Events<*> structs are cleared, and bevy_input's normal update of Input proceeds, without the events that have been suppressed.

## Solution

- This enables Input to be cloned, allowing it to be manually updated with events.
  • Loading branch information
rezural committed Feb 4, 2022
1 parent ef65548 commit e2cce09
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/bevy_input/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use bevy_ecs::schedule::State;
/// * Call the [`Input::press`] method for each press event.
/// * Call the [`Input::release`] method for each release event.
/// * Call the [`Input::clear`] method at each frame start, before processing events.
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct Input<T> {
pressed: HashSet<T>,
just_pressed: HashSet<T>,
Expand Down

0 comments on commit e2cce09

Please sign in to comment.