make it easy to dump raw events for debugging on windows/mac [rebuild]

This commit is contained in:
Dustin Carlino 2020-01-12 09:35:38 -08:00
parent de1c481c93
commit ec1e3f435b
2 changed files with 15 additions and 0 deletions

View File

@ -182,6 +182,7 @@ pub struct Settings {
profiling_enabled: bool,
default_font_size: usize,
override_hidpi_factor: Option<f64>,
dump_raw_events: bool,
}
impl Settings {
@ -191,6 +192,7 @@ impl Settings {
profiling_enabled: false,
default_font_size: 30,
override_hidpi_factor: None,
dump_raw_events: false,
}
}
@ -199,6 +201,11 @@ impl Settings {
self.profiling_enabled = true;
}
pub fn dump_raw_events(&mut self) {
assert!(!self.dump_raw_events);
self.dump_raw_events = true;
}
pub fn default_font_size(&mut self, size: usize) {
self.default_font_size = size;
}
@ -309,6 +316,7 @@ pub fn run<G: GUI, F: FnOnce(&mut EventCtx) -> G>(settings: Settings, make_gui:
program,
prerender,
settings.profiling_enabled,
settings.dump_raw_events,
);
}
@ -318,6 +326,7 @@ fn loop_forever<G: GUI>(
program: glium::Program,
prerender: Prerender,
profiling_enabled: bool,
dump_raw_events: bool,
) {
if profiling_enabled {
#[cfg(feature = "profiler")]
@ -348,6 +357,9 @@ fn loop_forever<G: GUI>(
state.gui.before_quit(&state.canvas);
process::exit(0);
}
if dump_raw_events {
println!("Event: {:?}", event);
}
if let Some(ev) = Event::from_glutin_event(event, state.canvas.hidpi_factor) {
new_events.push(ev);
}

View File

@ -46,6 +46,9 @@ fn main() {
if args.enabled("--enable_profiler") {
settings.enable_profiling();
}
if args.enabled("--dump_raw_events") {
settings.dump_raw_events();
}
if let Some(n) = args.optional_parse("--font_size", |s| s.parse::<usize>()) {
settings.default_font_size(n);
}