2020-11-07 01:15:56 +00:00
|
|
|
use bevy::{prelude::*, window::ReceivedCharacter};
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
App::build()
|
|
|
|
.add_plugins(DefaultPlugins)
|
2020-12-16 05:57:16 +00:00
|
|
|
.add_system(print_char_event_system.system())
|
2020-11-07 01:15:56 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
struct State {
|
|
|
|
event_reader: EventReader<ReceivedCharacter>,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// This system prints out all char events as they come in
|
|
|
|
fn print_char_event_system(
|
|
|
|
mut state: Local<State>,
|
|
|
|
char_input_events: Res<Events<ReceivedCharacter>>,
|
|
|
|
) {
|
|
|
|
for event in state.event_reader.iter(&char_input_events) {
|
|
|
|
println!("{:?}: '{}'", event, event.char);
|
|
|
|
}
|
|
|
|
}
|