From 88b6a221821c6301e1896ce837aae2e89b27fcd9 Mon Sep 17 00:00:00 2001 From: Naxdy Date: Tue, 9 Apr 2024 19:14:16 +0200 Subject: [PATCH] feat(superhack): give the console time to initialize --- src/input.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/input.rs b/src/input.rs index c8bb023..d43d424 100644 --- a/src/input.rs +++ b/src/input.rs @@ -458,6 +458,10 @@ pub async fn update_button_state_task( // replace this with the input filter of your choice, if you so desire. let mut input_filter = DummyFilter; + let mut initializing = true; + + let init_time = Instant::now(); + loop { update_button_states( &mut gcc_state, @@ -522,7 +526,13 @@ pub async fn update_button_state_task( } else { input_filter.apply_filter(&mut gcc_state); if input_consistency_mode == InputConsistencyMode::SuperHack { - if gcc_state != previous_state { + // transmit state always for the first 5 seconds to give the console time to initialize the controller + if initializing && Instant::now().duration_since(init_time) > Duration::from_secs(5) + { + initializing = false; + } + + if gcc_state != previous_state || initializing { gcc_publisher.publish_immediate(gcc_state); previous_state = gcc_state; }