Skip to content

Add multiple hardware on-board profile slots (1–5) without Synapse - #98

Open
Zedris wants to merge 7 commits into
infinityInfinite:mainfrom
Zedris:feat/onboard-profile-slots
Open

Zedris wants to merge 7 commits into
infinityInfinite:mainfrom
Zedris:feat/onboard-profile-slots

Conversation

@Zedris

@Zedris Zedris commented Nov 28, 2026

Copy link
Copy Markdown

Note: This PR builds on PR #1 (fix/naga-v3-pro-profile-upload) and will be rebased cleanly onto main once PR #1 is merged.

What it does

Adds full management of multiple hardware on-board profile slots (1–5) on supported Razer mice without requiring Razer Synapse:

  1. Protocol (crates/secbird-core/src/commands.rs, onboard.rs): Implements class 05:* commands extracted from Synapse 4's obmEngine / rzDevice25:
    • 05:80 — Get Number of Profiles
    • 05:81 — Get Profiles ID List ([total, id1, id2, ...])
    • 05:02 — Create New Profile ([slot])
    • 05:03 — Delete Profile ([slot], refuses to delete the last remaining slot; switches active slot first if deleting the active one)
    • 05:04 / 05:84 — Set / Get Active Profile ID ([slot])
    • 05:08 / 05:88 — Set / Get Profile Name With Offset (250-byte chunked header: 16-byte GUID, 100-byte UTF-8 name, 128-byte owner, 6-byte hash; 64-byte chunks)
    • 05:0B — Reset Profile ([slot])
    • 05:0C / 05:8C — Set / Get Profile Color ([slot, r, g, b])
  2. Independent per-slot backups (profile.rs, actions.rs): Tracks OnboardSave per slot (onboard_slots: BTreeMap<u8, OnboardSave>, keeping backward compatibility with the legacy onboard field) so saving a profile to Slot 2 does not undo Slot 1. Auto-creates a slot if saving to one that does not exist yet.
  3. CLI (crates/secbird/src/main.rs): Adds secbird slot [list|new <1-5> [name]|use <1-5>|delete <1-5>], --slot N on button save-to-mouse and button put-back, and on-board slot count in secbird info.
  4. Web Editor (server.rs, editor.html): Adds /api/onboard-slot and optional slot parameter on /api/save-to-mouse & /api/put-back, and upgrades "Saved on the mouse" (Profile and Buttons sections) with Switch, Save here, Put back, Delete, and "+ Add slot N" controls (with graceful fallback to the single-slot UI on devices that don't report 05:81).
  5. Simulator & Tests (sim.rs, onboard.rs): Simulates class 05:* commands and adds unit tests for header encoding, slot lifecycle, and independent multi-slot button saves.

What I tested, on which device

  • Hardware verified on Razer Naga V3 Pro (Wireless, 00E8, firmware v1.0, Windows, no Synapse installed):
    • secbird -v slot list reads 05:81 (05 01 00 00 00 00 -> Slot 1) and 05:84 (01) cleanly, handling Failed on 05:88/05:8C gracefully.
    • Created Slot 2 from the editor ("+ Add slot 2"), saved different button profiles to Slot 1 and Slot 2, quit Secretarybird completely, and power-cycled the mouse.
    • Hardware cycling verified: pressing the mouse's underside profile button cycles between Slot 1 (White) and Slot 2 (Red), with both profiles' remaps persisting across power cycles with zero software running.
  • Automated tests:
    • cargo test: 147 (secbird-core) + 8 (secbird-tray) + 1 doc-test — all pass.
    • cargo clippy --all-targets -- -D warnings: pass, zero warnings.
    • node --test crates/secbird-tray/tests/*.test.cjs: 7/7 pass.

What I couldn't test

  • Other Razer mouse models (e.g. Basilisk V3, DeathAdder V3) and wired mode (00E7).
  • Devices that support custom indicator colors via 05:0C/05:8C (the Naga V3 Pro uses fixed indicator colors per slot and returns Failed on 05:8C, which is handled gracefully).

Risks / impact on other devices

  • Low risk: devices that do not answer 05:81 fall back to the existing single-slot "Saved on the mouse" UI unchanged. Existing profiles.json files with the single onboard field remain fully compatible.
  • Flash writes (05:02, 05:03, 05:04, 05:08, 02:0C) only happen on explicit user action, never automatically on profile switch.

Checklist

  • cargo test and cargo clippy --all-targets -- -D warnings pass
  • node --test crates/secbird-tray/tests/*.test.cjs passes
  • Simulator tests for new device behaviour; source comments referencing Synapse 4's obmEngine / rzDevice25
  • No new network calls, dependencies or system changes
  • CHANGELOG line under [Unreleased]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant