From a8f621e3d63905f0193a08b435d8d26faa1b1d5d Mon Sep 17 00:00:00 2001 From: Mae PUGIN <48982737+mornepousse@users.noreply.github.com> Date: Tue, 7 Apr 2026 10:37:42 +0200 Subject: [PATCH] fix: Remove TAMA/AUTOSHIFT from Refresh All, add query delay TAMA? and AUTOSHIFT? commands were causing keyboard to malfunction. Added 50ms delay between serial queries to prevent buffer corruption. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/main.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8794870..d910653 100644 --- a/src/main.rs +++ b/src/main.rs @@ -894,9 +894,16 @@ fn main() { let tx = tx.clone(); std::thread::spawn(move || { let mut ser = serial.lock().unwrap_or_else(|e| e.into_inner()); - for (tag, cmd) in [("td", "TD?"), ("combo", "COMBO?"), ("leader", "LEADER?"), ("ko", "KO?"), ("bt", "BT?"), ("tama", "TAMA?"), ("autoshift", "AUTOSHIFT?")] { + // Use binary protocol if v2, text fallback otherwise + let queries: &[(&str, &str)] = if ser.v2 { + &[("td", "TD?"), ("combo", "COMBO?"), ("leader", "LEADER?"), ("ko", "KO?"), ("bt", "BT?")] + } else { + &[("td", "TD?"), ("combo", "COMBO?"), ("leader", "LEADER?"), ("ko", "KO?"), ("bt", "BT?")] + }; + for (tag, cmd) in queries { + std::thread::sleep(std::time::Duration::from_millis(50)); let lines = ser.query_command(cmd).unwrap_or_default(); - let _ = tx.send(BgMsg::TextLines(tag.into(), lines)); + let _ = tx.send(BgMsg::TextLines((*tag).into(), lines)); } }); });