valentine

Terminal control panel for the Focusrite Scarlett 18i20 — a from-scratch replacement for Focusrite Control.
Log | Files | Refs | README | LICENSE

commit b873468a5e13f618f1058f5f4d6d5256f6229b2d
parent d6965e725d2eba1c17f2bd45d4b747f4b520cb3a
Author: Matthew Gantenbein <ganten1998@gmail.com>
Date:   Mon,  1 Jun 2026 14:33:39 -0500

fix: drain queued input after each key so slow writes can't cascade

A control change can be many USB writes (8 for an ADAT group fader); while
that runs, held/repeated keys pile up in the terminal buffer and then replay,
making one fader press cascade straight to silence. After handling a key, drain
any already-queued events (non-blocking) so it's one action per redraw. The
fader math itself was correct/linear — this was buffered key-repeat.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Diffstat:
Mvalentine/src/main.rs | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/valentine/src/main.rs b/valentine/src/main.rs @@ -1036,6 +1036,14 @@ fn run<B: Backend>(terminal: &mut Terminal<B>, app: &mut App) -> Result<()> { app.on_key(key.code); } } + // Drain any input that queued up while on_key ran. Each control + // change can take many USB writes (e.g. 8 for an ADAT group fader), + // during which held/repeated keys pile up in the terminal buffer; + // without draining, that backlog replays and a single press cascades + // (a fader would run straight to silence). One action per redraw. + while event::poll(Duration::from_millis(0))? { + let _ = event::read()?; + } } app.tick(); }