Skip to content

feat(status): show dpi of mice without a battery - #139

Open
higorhgon wants to merge 1 commit into
OpenMouse-Project:mainfrom
higorhgon:feat/settings-without-battery
Open

higorhgon wants to merge 1 commit into
OpenMouse-Project:mainfrom
higorhgon:feat/settings-without-battery

Conversation

@higorhgon

@higorhgon higorhgon commented Dec 1, 2026 •

Copy link
Copy Markdown

Summary

Bridge dropped a native status that had no battery, so a mouse whose driver reads DPI and polling rate but no battery never got them on its Home row. This keeps those settings.

  • NativeStatus.battery is now optional. parse_status accepts a reply with DPI and/or polling rate and no battery, and returns None only when the reply has neither.
  • A DPI or polling rate of 0 reads as unknown: drivers fill in 0 for what they could not read (a mouse asleep behind its receiver), which used to show as "0 DPI".
  • A status without a battery goes to the new BridgeService::record_native_settings, which updates the known-device row (DPI, polling, awake) and leaves the battery list alone, so the tray icon and the low-battery alert are unchanged.
  • Pulsar and Lamzu only wrap their battery in Some; no behavior change.

The polling interval is unchanged: settings refresh with the existing 5-minute status read.

Motivation

The 8BitDo Retro R8 reports DPI and polling rate through its 2.4 GHz receiver but no battery (OpenMouse-Project/mouse-protocol#326). With that driver installed in native-hid, the R8's row now reads Connected · 1200 DPI · 500 Hz instead of Connected. This change has no effect until a mouse-protocol release with that driver is pinned here.

Testing

  • cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings and cargo test --locked pass.
  • New tests: a status with settings and no battery parses, one with 0 DPI and polling does not; a battery-less mouse shows its DPI and polling rate and adds no battery entry.
  • On Linux (Hyprland) with an 8BitDo Retro R8 and the mouse-protocol#326 driver installed locally in native-hid (npm install --no-save): live_mice reads battery: None, dpi: Some(1200), polling_rate_hz: Some(500), and /v1/status lists the R8 as connected with dpi: 1200, pollingRateHz: 500 and an empty batteries.

🤖 Generated with Claude Code

Note

Make NativeStatus.battery optional so batteryless mice show DPI and polling rate

Changes NativeStatus.battery from NativeBattery to Option<NativeBattery> in native_hid.rs. Status replies with DPI or polling-rate settings are now parsed even without battery data; zero DPI and polling-rate values are treated as unknown.

  • Adds BridgeService.record_native_settings in service.rs to record settings-only native reads. It marks the device as not asleep, updates the known-device record, and leaves the battery list empty.
  • Updates lamzu.read_status and pulsar.read_status to wrap battery in Some for the new optional field.
  • Behavioral Change: native_hid.parse_status returns None for replies with neither battery nor nonzero DPI/polling-rate values; the poll_devices debug message for None now refers to battery or settings readers.

Macroscope summarized bdf5301.

Summary by CodeRabbit

  • Bug Fixes
    • DPI and polling-rate settings are now retained when a device reports settings but no battery status.
    • Devices with no battery reading can still have their settings recorded, and are no longer treated as asleep solely because a battery reading is unavailable.
    • Zero-valued DPI and polling-rate readings are treated as unknown rather than reported as valid settings.
    • Battery readings continue to be recorded when available.

- accept a native status with dpi/polling only
- treat a dpi or polling rate of 0 as unread
- update the mouse row without touching the tray
  or the battery alerts
- cover both cases with tests
@github-actions github-actions Bot added the type: enhancement PR title category: enhancement label Dec 1, 2026
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Native status parsing now permits settings without battery data. Native polling records those settings without creating a battery reading. Lamzu and Pulsar drivers wrap valid battery data in the optional battery field.

Changes: Native status handling

Layer / File(s) Summary
Optional battery status and parsing
src/drivers/native_hid.rs, src/drivers/lamzu.rs, src/drivers/pulsar.rs
NativeStatus.battery is optional. Parsing keeps nonzero DPI and polling-rate values when battery parsing fails, and treats zero settings as unknown. The Lamzu and Pulsar drivers wrap valid battery data in Some. Tests cover battery-bearing, settings-only, and empty statuses.
Record settings-only responses
src/service.rs
Native polling records settings and device metadata when a status has no battery. Battery-bearing statuses continue through the battery-recording path. A service test checks that settings are remembered without a battery entry.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant NativeHID
  participant parse_status
  participant NativePolling
  participant BridgeService
  participant RememberedDeviceStore
  NativeHID->>parse_status: Native response with settings and no battery
  parse_status->>NativePolling: Status with settings and no battery
  NativePolling->>BridgeService: Record native settings
  BridgeService->>RememberedDeviceStore: Remember settings and clear asleep state
Loading

Possibly related PRs

Suggested reviewers: jazzstack, snekxs

Merge Risk: Minimal · up to bdf53

This change keeps DPI and polling-rate settings visible for mice that report no battery. It does not alter tray or battery-alert behavior. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat(status): show dpi of mice without a battery" matches the main change. The PR makes NativeStatus.battery optional, so settings-only status (DPI and polling rate) is kept when a mouse re…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(status): show dpi of mice without a battery" matches the main change. The PR makes NativeStatus.battery optional, so settings-only status (DPI and polling rate) is kept when a mouse reports no battery, and a new BridgeService::record_native_settings method stores those settings. The title is specific and concise, and it follows the conventional commit style.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d175004 and bdf5301.

Files selected for processing: 4

  • src/drivers/lamzu.rs
  • src/drivers/native_hid.rs
  • src/drivers/pulsar.rs
  • src/service.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@github-actions github-actions Bot added area: native Native bridge and platform services area: devices HID access and device drivers labels Dec 1, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 1, 2026

Copy link
Copy Markdown

Approvability

Verdict: Approved at bdf5301

Macroscope's review found this PR approvable — Mice without battery telemetry can now show DPI and polling rate and appear awake. The change uses existing device persistence while keeping settings-only readings out of battery tray and alert handling.

Notes:

  • Your repo's Minimum Blocking Severity is Off, so correctness findings do not automatically block approval.

You can add or adjust custom eligibility rules. Learn more.

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

Labels

area: devices HID access and device drivers area: native Native bridge and platform services type: enhancement PR title category: enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants