Skip to content

feat(attackshark): enable live battery percent readout for X11 SE - #223

Merged
snekxs merged 1 commit into
OpenMouse-Project:mainfrom
shamsghani:feat/x11-se-battery
Oct 13, 2026
Merged

snekxs merged 1 commit into
OpenMouse-Project:mainfrom
shamsghani:feat/x11-se-battery

Conversation

@shamsghani

@shamsghani shamsghani commented Oct 13, 2026 •

Copy link
Copy Markdown

Summary

Enables live battery percentage reporting for the Attack Shark X11 SE (receiver model ID 0x07).

The model was already tracked in X11_RECEIVER_MODELS, but lacked the battery: "percent" scale property (which was kept unassigned until verified on hardware).

Verified on real hardware against the official Attack Shark software and community reference implementations (HarukaYamamoto0/attack-shark-x11-driver): the X11 SE streams standard 0–100% battery values via the 5th byte of the receiver's telemetry packet (03 07 40 01 <percent>).

Changes

  • src/drivers/attackshark/hid.ts: Flagged model ID 0x07 with "percent" in X11_RECEIVER_MODELS.
  • src/drivers/attackshark/hid.test.ts: Added unit test asserting that report [0x03, 0x07, 0x40, 0x01, 85] parses as 85%.

Testing

  • Verified on physical hardware: live battery percentage successfully reports and updates in the OpenMouse UI over the 2.4 GHz wireless receiver via OpenMouse Bridge.
  • Ran test suite: npx tsx --test src/drivers/attackshark/hid.test.ts (29 passed, 0 failed).
  • Ran TypeScript build: npm run build succeeds without diagnostics.

Summary by CodeRabbit

  • Bug Fixes
    • Battery reports from the X11 SE receiver are now recognized as percentages and display the correct battery level.

@github-actions github-actions Bot added type: enhancement PR title category: enhancement area: protocol Protocol codecs and shared types area: drivers Device drivers and transport integration area: tests Protocol and driver tests labels Oct 13, 2026
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: OpenMouse-Project/mouse-protocol/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ae1178cb-82d8-4ac3-a543-3bc9c2d000f8
📥 Commits

Reviewing files that changed from the base of the PR and between 80ba207 and 4148a34.

📒 Files selected for processing (2)
  • src/drivers/attackshark/hid.test.ts
  • src/drivers/attackshark/hid.ts

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

📝 Walkthrough

The X11 SE receiver model now uses a percentage battery scale. A test checks that a battery report containing 85 parses as 85.

Changes: X11 SE battery parsing

Layer / File(s) Summary
Set and verify percentage scale
src/drivers/attackshark/hid.ts, src/drivers/attackshark/hid.test.ts
The X11 SE receiver model now uses the percentage battery scale. A test checks that a report value of 85 parses as 85.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Feature

Suggested reviewers: snekxs

Merge Risk: ⚪ Minimal · up to 4148a

X11 SE battery reports now expose the reported percentage directly; the tested parsing path behaves as intended, with no concrete merge-blocking risk remaining.

Security architecture risk: 🔵 Low · up to 4148a

This is a narrowly scoped battery-readout change. It does not expand device access or settings-write permissions. Remaining uncertainty concerns readout lifecycle behavior and downstream use of the reported value, rather than demonstrated privilege escalation.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated new exposure is acceptance of battery values from an already connected receiver report source into status and the existing product-ID-shared cache. No new connection channel or settings authority is established by this change.

Trust Boundaries and Controls

  • observed — Battery acceptance checks the report ID, recognized battery-capable model, fixed event markers and numeric range. Model identity is assigned before full battery validation, but that ordering predates the PR. Other percentage-capable model IDs were already accepted, providing counterevidence to increased maximum authority for a malicious report source.

Resilience and Maintainability Implications

  • inferred — Absent or rejected samples can now cause model 0x07 status reads to use the existing bounded battery wait, whose default is 2.5 seconds per invocation. Malformed numbered reports can establish model identity without supplying a valid sample. This demonstrates a bounded readout delay, not an unbounded wait or verified security regression.
Pre-merge checks · Passed 5
Passed Passed checks (5 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: enabling live battery percentage readout for the Attack Shark X11 SE.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@snekxs
snekxs merged commit 2613e68 into OpenMouse-Project:main Oct 13, 2026
5 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.42.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

area: drivers Device drivers and transport integration area: protocol Protocol codecs and shared types area: tests Protocol and driver tests released type: enhancement PR title category: enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants