|
|
@ -164,26 +164,29 @@ impl InputState { |
|
|
|
let mut keys_down = self.keys_down; |
|
|
|
let mut scroll_delta = Vec2::ZERO; |
|
|
|
let mut zoom_factor_delta = 1.0; |
|
|
|
new.events.retain(|event| match event { |
|
|
|
Event::Key { key, pressed, .. } => { |
|
|
|
if *pressed { |
|
|
|
// We only retain presses that are novel (i.e. the first Press event, not those generated by key-repeat)
|
|
|
|
keys_down.insert(*key) |
|
|
|
} else { |
|
|
|
keys_down.remove(key); |
|
|
|
true |
|
|
|
for event in &mut new.events { |
|
|
|
match event { |
|
|
|
Event::Key { key, pressed, modifiers } => { |
|
|
|
if *pressed { |
|
|
|
// We only retain presses that are novel (i.e. the first Press event, not those generated by key-repeat)
|
|
|
|
// key repeats are represented by KeyRepeat.
|
|
|
|
if !keys_down.insert(*key) { |
|
|
|
*event = Event::KeyRepeat { key: *key, modifiers: *modifiers }; |
|
|
|
}
|
|
|
|
} else { |
|
|
|
keys_down.remove(key); |
|
|
|
} |
|
|
|
} |
|
|
|
Event::Scroll(delta) => { |
|
|
|
scroll_delta += *delta; |
|
|
|
} |
|
|
|
Event::Zoom(factor) => { |
|
|
|
zoom_factor_delta *= *factor; |
|
|
|
} |
|
|
|
_ => {}, |
|
|
|
} |
|
|
|
Event::Scroll(delta) => { |
|
|
|
scroll_delta += *delta; |
|
|
|
true |
|
|
|
} |
|
|
|
Event::Zoom(factor) => { |
|
|
|
zoom_factor_delta *= *factor; |
|
|
|
true |
|
|
|
} |
|
|
|
_ => true, |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
InputState { |
|
|
|
pointer, |
|
|
|
touch_states: self.touch_states, |
|
|
|