From 0e1dff859c22522073c46d4f4c86ff8171f7cc36 Mon Sep 17 00:00:00 2001 From: SusieeTheFemboy <96988330+SusieeTheLinuxUser@users.noreply.github.com> Date: Sat, 7 Nov 2026 01:00:23 +0100 Subject: [PATCH] Offer every special button action, including Battery level Action::choices stopped one entry short of SPECIALS, so the last special action never showed in the button combo box. Co-Authored-By: Claude Opus 5.5 --- src/mouse.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/mouse.rs b/src/mouse.rs index 8b5c1b0..ee106c6 100644 --- a/src/mouse.rs +++ b/src/mouse.rs @@ -71,7 +71,7 @@ impl Action { v.extend((1..=11).map(Action::Button)); } if types.contains(&SPECIAL) { - v.extend((1..SPECIALS.len() as u32 - 1).map(|n| Action::Special(SPECIAL_BASE + n))); + v.extend((1..SPECIALS.len() as u32).map(|n| Action::Special(SPECIAL_BASE + n))); } if types.contains(&NONE) { v.push(Action::None); @@ -349,3 +349,16 @@ impl HidppDpi { Ok(u16::from_be_bytes([r[4], r[5]])) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn special_choices_cover_every_entry() { + let choices = Action::choices(&[SPECIAL]); + // index 0 ("Unknown") stays out, the last entry ("Battery level") is offered + assert!(!choices.contains(&Action::Special(SPECIAL_BASE))); + assert!(choices.contains(&Action::Special(SPECIAL_BASE + SPECIALS.len() as u32 - 1))); + } +}