From c7fd7e72c9816319ef2ff540e415b1d561e83074 Mon Sep 17 00:00:00 2001 From: Naxdy Date: Tue, 2 Apr 2024 10:12:23 +0200 Subject: [PATCH] feat(HID): get state on-demand to improve latency --- src/gcc_hid.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gcc_hid.rs b/src/gcc_hid.rs index da2f34a..72e50e9 100644 --- a/src/gcc_hid.rs +++ b/src/gcc_hid.rs @@ -353,11 +353,16 @@ pub async fn usb_transfer_task( ticker.next().await; } - let state = gcc_subscriber.next_message_pure().await; - let report = get_gcinput_hid_report(&state); - match writer.write(&report).await { - Ok(()) => { + match writer + .write(&{ + let state = gcc_subscriber.next_message_pure().await; + let report = get_gcinput_hid_report(&state); trace!("Report Written: {:08b}", report); + report + }) + .await + { + Ok(()) => { let currtime = Instant::now(); let polltime = currtime.duration_since(lasttime); let micros = polltime.as_micros();