Skip to content

feat(daemon): settling re-poll after controller reconnect - #11

Merged
vdemonchy merged 1 commit into
mainfrom
feat/settling-repoll
Jun 7, 2026
Merged

vdemonchy merged 1 commit into
mainfrom
feat/settling-repoll

Conversation

@vdemonchy

Copy link
Copy Markdown
Owner

Summary

  • A physical mode switch (XInput ↔ DS4 ↔ Switch ↔ HID) re-enumerates the controller over USB (remove + add). The single post-add poll can read the device mid-transition — openHID rides the ~1.5s udev uaccess race, and reader.Read/power_supply attrs may not be ready yet — so readHID returns a Stale read carrying the previous mode's battery, and nothing corrects it until the next poll tick (30–60s).
  • Schedules short follow-up polls (settleDelays = {1s, 3s}) after each hotplug add via a new scheduleSettle helper feeding a buffered settleCh, so the settled value reaches both frontends within seconds. Daemon-only — the GNOME extension and COSMIC applet already mirror the state file.
  • Non-blocking sends into a size-1 channel coalesce bursts of reconnects with no timer bookkeeping.

Test Plan

  • go test ./cmd/cyclone2/ -run TestScheduleSettle -v — new unit tests (arms one timer per delay; simultaneous fires coalesce to one queued send)
  • go test ./..., go build ./..., go vet ./... — clean (and go test -race clean)
  • Manual (hardware): with the daemon running, flip the controller mode switch and confirm $XDG_RUNTIME_DIR/cyclone2-linux.json reflects the new mode/battery within a few seconds, not after a full poll interval

🤖 Generated with Claude Code

A physical mode switch re-enumerates the controller; the single post-add
poll can read it mid-transition and show the previous mode's battery until
the next poll tick. Schedule short follow-up polls (1s, 3s) so the settled
value reaches both frontends within seconds.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the enhancement New feature or request label Jun 7, 2026
@vdemonchy
vdemonchy merged commit 718796b into main Jun 7, 2026
1 check passed
@vdemonchy
vdemonchy deleted the feat/settling-repoll branch June 7, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant