Skip to content

Commit

Permalink
desktop: Fire both KeyDown and TextControl events
Browse files Browse the repository at this point in the history
Fixup for ruffle-rs#11059, which broke left/right arrows on desktop
  • Loading branch information
n0samu authored and adrian17 committed May 22, 2023
1 parent b94f9f3 commit 42e162a
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions desktop/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,21 +587,27 @@ impl App {
if let Some(key) = input.virtual_keycode {
let key_code = winit_to_ruffle_key_code(key);
let key_char = winit_key_to_char(key, modifiers.shift());
let event = match input.state {
match input.state {
ElementState::Pressed => {
player_lock.handle_event(PlayerEvent::KeyDown {
key_code,
key_char,
});
if let Some(control_code) =
winit_to_ruffle_text_control(key, modifiers)
{
PlayerEvent::TextControl { code: control_code }
} else {
PlayerEvent::KeyDown { key_code, key_char }
player_lock.handle_event(PlayerEvent::TextControl {
code: control_code,
});
}
}
ElementState::Released => {
PlayerEvent::KeyUp { key_code, key_char }
player_lock.handle_event(PlayerEvent::KeyUp {
key_code,
key_char,
});
}
};
player_lock.handle_event(event);
}
if player_lock.needs_render() {
self.window.request_redraw();
}
Expand Down

0 comments on commit 42e162a

Please sign in to comment.