Skip to content

Add support for Sony PULSE 3D (CFI-ZWH1) - #610

Merged
Sapd merged 4 commits into
Sapd:masterfrom
Ashraf-Obay:add-sony-pulse-3d
Oct 26, 2026
Merged

Sapd merged 4 commits into
Sapd:masterfrom
Ashraf-Obay:add-sony-pulse-3d

Conversation

@Ashraf-Obay

@Ashraf-Obay Ashraf-Obay commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Changes made

Adds battery status for the Sony PULSE 3D wireless headset (CFI-ZWH1, the PS5 headset) through its USB dongle 054c:0d5e.

Protocol (found by passive listening; nothing is written to the device)

HID is on interface 3, which has four top-level collections. The headset status is on the vendor collection (usage page 0xFF01, usage 0x0020) as an 8-byte input report:

Byte Meaning
0 report ID 0xB0
3 battery 0–100 in steps of 10, or 0x80 while charging
4 bit 0x08 set while the headset is connected, cleared on power-off

The other bytes (a 0–100 level and some button flags) aren't decoded.

Evidence: a 6-hour log on real hardware showed byte 3 stepping 80 → 70 → 60 → 50 → 40 → 30 about once an hour. Power-off/on, plugging the charge cable in and out, and button presses were each checked separately.

The catch: the dongle never answers queries

It only sends the status report when something changes (power on/off, a button press, the charge cable, or a battery step, about hourly). Feature reports on the vendor collections read back as zeros. The collection also declares a 1-bit output report 0xB1, but the dongle rejects writes to it (ERROR_GEN_FAILURE on both interrupt OUT and SET_REPORT), so I couldn't find a way to request a report.

So getBattery():

  1. drains the reports already queued on the (cached) connection and keeps the newest status per handle, so long-running callers like GUIs/tray apps see every change;
  2. if this connection hasn't seen a status yet, waits up to hsc_device_timeout for the next one, and otherwise returns a timeout telling the user to press a headset button;
  3. clears the per-handle state in onConnectionClosed(), as logitech_astro_a50_gen4.hpp does.

Mapping: powered off → BATTERY_UNAVAILABLE (-1). Charging → BATTERY_CHARGING with the last level seen before plugging in, or -1 if none was seen.

Tests: tests/test_sony_pulse_3d.cpp covers newest-report-wins with other collections' reports in between, state kept across calls and per handle, charging, power-off, and error propagation, using the real captured reports. It also asserts that nothing is written to the device.

Tested on hardware: Windows 11 with the CI-built headsetcontrol.exe from this branch:

  • the device is detected as Sony PULSE 3D [0x054c:0x0d5e];
  • -b with no headset event times out after the configured --timeout (checked at 2 s, 5 s and 10 s) with the "press a button" error and BATTERY_UNAVAILABLE;
  • -b --timeout 30000 with one volume press during the wait → BATTERY_AVAILABLE, level 20.

I verified the charging and power-off flags on the hardware with a standalone listener; in this branch they're covered by unit tests. Linux and macOS are untested (no hardware/OS access). Since #596 the usage-page/usage lookup selects the status collection on all platforms whenever hidapi reports usages. Only older hidapi falls back to interface 3, and there the report-ID filter skips the other collections' reports. A wrong collection would just yield no 0xB0 reports, which ends in the timeout message rather than a wrong reading.

The one-shot CLI is the worst case for this device (a press is needed during the wait). Long-running library users that keep the Headset alive get the queued reports and stay current.

Checklist

  • I adjusted the README (if needed)
  • For new features in HeadsetControl: I discussed it beforehand in Issues or Discussions and adhered to the wiki

(Not a new feature, just a new device using the existing battery capability.)


🤖 Generated with Claude Code

Ashraf-Obay and others added 2 commits October 25, 2026 00:26
Battery status for the PULSE 3D wireless headset via its USB dongle
(054c:0d5e). The dongle never answers queries; it sends an 8-byte status
report (ID 0xB0) on the vendor collection (usage page 0xFF01, usage 0x20)
only when something changes:

  byte[3]  battery 0-100 in steps of 10, or 0x80 while charging
  byte[4]  bit 0x08 set while the headset is connected

getBattery() drains the reports queued on the cached connection, keeps
the newest status per handle, and otherwise waits up to the device
timeout for the next report. Nothing is written to the device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the awaiting-maintainer The author replied or pushed - our move label Oct 24, 2026
@Sapd

Sapd commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Good protocol write-up, and the passive approach is the right call - the mock asserting writes == 0 is what makes that claim checkable rather than a promise in prose. Built it here: clean, no warnings, suite green, clang-format 18 clean, README matches --readme-helper. The per-handle state plus onConnectionClosed() follows the ASTRO A50 Gen 4 precedent, including the mutex.

I broke each behaviour to see what the tests hold. Three of four fail as they should: clearing state on close, the 0x80 charging marker, and the connected flag. The fourth doesn't.

The report-ID filter isn't covered. Drop report[0] != STATUS_REPORT_ID from remember() and the suite still passes, because MEDIA_KEY is 5 bytes and report.size() < REPORT_SIZE rejects it first - the ID comparison never runs. That filter is the whole basis for "reports from the other collections on that interface are ignored", so it's worth a report that actually reaches it:

// Same length as a status report but another collection's report ID
const std::vector<uint8_t> OTHER_COLLECTION_8B { 0x01, 0x05, 0x00, 0x64, 0xef, 0x15, 0x11, 0x64 };

queued after AT_30 in testPulse3DLatestQueuedReportWins. Checked both ways here: passes with the filter, fails with "newest report should win" without it.

The collection comment is out of date. Lines 70-71 and the PR body say the usage lookup is Windows-only with an interface-3 fallback elsewhere. #596 is in your history and it made the usage_page/usage match run on all platforms, so Linux and macOS also select the right collection whenever hidapi fills those fields; the interface fallback only bites on older hidapi.

Keep PLATFORM_ALL. Untested isn't a reason to narrow - we narrow where there's a mechanism for breakage, and there isn't one here: nothing is written, and a wrong collection just yields no 0xb0 reports, so the worst case is your timeout message rather than a wrong setting.

Not yours to fix: -b while charging with no earlier level prints Level: -1%. hyperx_cloud_alpha_wireless.hpp:95 and hyperx_cloud_flight.hpp:106 already ship that same -1 with BATTERY_CHARGING, and the standard output prints the level for anything that isn't BATTERY_UNAVAILABLE. Your device makes it the normal case rather than a corner, since byte 3 is 0x80 for the whole charging session and a one-shot run starts with no remembered level. I'll fix the output layer separately.

Those two and I'll merge.

@github-actions github-actions Bot added awaiting-author We replied - waiting on the author needs-rebase Branch conflicts with master and removed awaiting-maintainer The author replied or pushed - our move labels Oct 26, 2026
Queue a full-length report with another collection's ID in the
newest-report test, so the report-ID check is actually exercised (the
5-byte media-key report was already rejected by the length check).

The usage-page lookup runs on all platforms since Sapd#596; the interface 3
fallback only applies when hidapi doesn't report usages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Ashraf-Obay

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review, and for breaking each behaviour to check the tests.

Both are fixed in 56d3768:

  • Report-ID filter: OTHER_COLLECTION_8B (your vector) is now queued after AT_30 in testPulse3DLatestQueuedReportWins. I checked it both ways in CI on my fork: the suite passes with the filter, and with report[0] != STATUS_REPORT_ID removed it fails with "newest report should win".
  • Collection comment: getCapabilityDetail() now says the usage lookup selects the collection on every platform where hidapi reports usages (since Add Jabra Link 380 (paired headset) support #596). Interface 3 is only the fallback for older hidapi. I updated the PR description the same way.

Keeping PLATFORM_ALL as you suggested, and thanks for taking the -1% while-charging output separately.

@github-actions github-actions Bot added awaiting-maintainer The author replied or pushed - our move and removed awaiting-author We replied - waiting on the author labels Oct 26, 2026
Resolve test list conflicts with Sapd#590 by keeping both new test files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot removed the needs-rebase Branch conflicts with master label Oct 26, 2026
@Sapd

Sapd commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Both verified on your merged branch, which is purely additive against master - your conflict resolution keeps #590's test entries, nothing dropped.

The report-ID filter has teeth now: removing report[0] != STATUS_REPORT_ID fails with "newest report should win". I re-broke every behaviour on the rebased tree and four of four fail as they should - report-ID filter, clearing state on close, the 0x80 marker, and the connected flag. Comment reads correctly on the #596 behaviour. Build clean, no warnings, README matches --readme-helper, clang-format 18 clean, CI green on all three platforms.

The one thing with no coverage is the level <= 100 bound, and I'm not asking for it - it guards a byte value the protocol doesn't document, so a test would have to invent a report the device never sends. The guard being there is the right call.

Merging. Good first contribution: the six-hour capture log, the explicit note that feature reports read back as zeros and 0xB1 is rejected, and a mock that asserts writes == 0 all made this reviewable without the hardware. The -1% while charging is on me.

@Sapd
Sapd merged commit 8159093 into Sapd:master Oct 26, 2026
7 checks passed
@github-actions github-actions Bot removed the awaiting-maintainer The author replied or pushed - our move label Oct 26, 2026
Sapd added a commit that referenced this pull request Oct 26, 2026
A device that reports charging without a level leaves level_percent at -1,
and the standard output printed that verbatim as "Level: -1%", which reads
like a real reading. The line is now left out, as it already is for an
unavailable battery.

Three devices reach this: hyperx_cloud_alpha_wireless and hyperx_cloud_flight
have shipped it for a while, and the Sony PULSE 3D (#610) makes it the normal
case while charging, since its status byte carries 0x80 instead of a level for
the whole charging session.

The structured formats are unchanged. They already use -1 as the "unknown"
sentinel for an unavailable battery, so JSON, YAML and ENV keep emitting
level -1 and no consumer has to change. Verified against master across every
battery test profile in all four formats.

Test device profile 8 covers the case, and a CLI test asserts the level line
is gone while BATTERY_CHARGING is still reported, that a charging headset
which does report a level still prints it, and that JSON keeps the sentinel.
Sapd added a commit to gdevenyi/HeadsetControl that referenced this pull request Oct 26, 2026
Resolve the test-list conflicts with Sapd#590 and Sapd#610 by keeping all three new
test files, and regenerate the README table for the capability column and the
device rows those added. Keeps this branch's wording for the ALSA sidetone
note ("Virtuoso other than the XT") and its footnote about sidetone being
verified on the XT only; master's "XT/SE" was the pre-fixup text that rode
along in Sapd#580's README regeneration.
@Ashraf-Obay
Ashraf-Obay deleted the add-sony-pulse-3d branch October 27, 2026 03:10
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.

2 participants