Skip to content

Add headset volume capability with ASTRO A50 Gen 5 support - #600

Merged
Sapd merged 4 commits into
Sapd:masterfrom
Mihuy1:feature/headset-volume
Oct 22, 2026
Merged

Sapd merged 4 commits into
Sapd:masterfrom
Mihuy1:feature/headset-volume

Conversation

@Mihuy1

@Mihuy1 Mihuy1 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Changes made

Adds CAP_HEADSET_VOLUME, which sets the headset's own hardware volume: the level the volume wheel changes, separate from the OS mixer. This follows the plan agreed in #599.

  • --volume LEVEL sets the volume on a 0–128 scale, the same as sidetone and microphone volume.
  • Wired through the capability descriptors, feature handlers, CLI and help text, the C++ API (Headset::setHeadsetVolume) and the C API (HSC_CAP_HEADSET_VOLUME, hsc_set_volume).
  • ASTRO A50 Gen 5 (046d:0b1c): sends 02 0c 05 00 08 1b ff <0..21>, the SET frame documented in Add Logitech ASTRO A50 Gen 5 (046d:0b1c) #531 and confirmed by a USB capture. 0–128 is mapped onto the 22 wheel steps with mapSidetoneToDiscrete<22>().
  • The test device implements the capability. There are library API tests, plus protocol tests that check the A50 SET frames.
  • The README device table is regenerated with --readme-helper, and LIBRARY_USAGE.md and ADDING_A_DEVICE.md are updated.

Tested on a real A50 Gen 5: --volume 0, 64 and 128 give mute, a middle level and full volume.

This PR only adds the setter. As discussed in #599, reading the volume back will come in a separate PR that adds a readable-capabilities bitmask (getReadableCapabilities()), instead of a separate *_STATUS capability.

The PR has three commits: the core capability, the A50 implementation, and the regenerated README table.

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

Mihuy1 and others added 3 commits October 21, 2026 13:31
Adds CAP_HEADSET_VOLUME for the headset's own hardware volume (the
level an on-device volume wheel changes), separate from the OS mixer.

- --volume LEVEL sets it on a 0-128 scale, like sidetone and
  microphone volume. HeadsetVolumeResult also reports the device's
  native range.
- Wired through the capability descriptors, feature handlers, CLI and
  help text, the C++ Headset API and the C API (HSC_CAP_HEADSET_VOLUME,
  hsc_set_volume).
- The test device implements it, with library API tests.

Reading the volume back is left for later: it should come from a
readable-capabilities bitmask rather than a separate *_STATUS
capability (see discussion Sapd#599).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implements CAP_HEADSET_VOLUME for the A50 Gen 5 (046d:0b1c) with the
SET frame from the a50-volumemaster capture and Sapd#531:
02 0c 05 00 08 1b ff <0..21>.

The 0-128 level maps onto the 22-step volume wheel with
mapSidetoneToDiscrete<22>. Protocol tests check the SET frames
using the scripted HID interface.

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 21, 2026
@Sapd
Sapd requested a balanced review from Copilot October 21, 2026 11:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Out-of-range library input can silently request maximum hardware volume rather than return an error.

1 open issue
What changed in this PR

Adds hardware headset-volume control across HeadsetControl, with ASTRO A50 Gen 5 support independent of the OS mixer.

Changes:

  • Adds the setter capability, CLI option, and C/C++ APIs.
  • Implements A50 volume commands and test-device support.
  • Adds protocol/API tests and updates documentation; volume readback remains deferred.
File Description
tests/​test_protocols.cpp Tests A50 volume mapping and frames.
tests/​test_library_api.cpp Tests C/C++ volume setters.
README.md Updates device capability table.
lib/​result_types.hpp Adds volume result structure.
lib/​headsetcontrol.hpp Declares C++ setter.
lib/​headsetcontrol.cpp Dispatches C++ volume requests.
lib/​headsetcontrol_c.h Declares C capability, result, and setter.
lib/​headsetcontrol_c.cpp Implements C wrapper.
lib/​feature_handlers.hpp Registers volume handler.
lib/​devices/​logitech_astro_a50.hpp Implements hardware volume command.
lib/​devices/​hid_device.hpp Adds virtual volume setter.
lib/​devices/​headsetcontrol_test.hpp Implements test-device volume support.
lib/​device.hpp Adds capability identifier.
lib/​capability_descriptors.hpp Defines volume metadata and range.
docs/​LIBRARY_USAGE.md Documents volume APIs and usage.
docs/​ASTRO_A50_EXTRA_FEATURES.md Marks volume control as supported.
docs/​ADDING_A_DEVICE.md Lists the new capability.
cli/​main.cpp Wires volume parsing, help, and execution.

Review effort: Balanced

Comment thread lib/headsetcontrol.cpp

Result<HeadsetVolumeResult> Headset::setHeadsetVolume(uint8_t volume)
{
HEADSET_FEATURE_IMPL(CAP_HEADSET_VOLUME, setHeadsetVolume, volume);

@Sapd Sapd left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built this locally: README table is byte-identical to --readme-helper from this branch, clang-format 18 clean on all touched files, ctest passes, CI green. The protocol test covers the full SET frame and the bucket boundaries.

Three things before merge.

1. API_VERSION needs to go to 1.7. The capability list is part of the structured output, and docs/LIBRARY_USAGE.md documents the second number as incrementing on additions. Three places:

  • cli/output/output.cpp:32, plus a line in the comment block above it saying what changed
  • tests/test_output_formats.cpp:73
  • docs/LIBRARY_USAGE.md:31

docs/ADDING_A_CAPABILITY.md lists seven steps and the bump is not one of them. I'll add it there.

2. C API naming. hsc_set_volume / hsc_volume_t sit next to hsc_set_mic_volume, hsc_set_volume_limiter and hsc_set_bluetooth_call_volume, and the C++ method is setHeadsetVolume. Rename to hsc_set_headset_volume / hsc_headset_volume_t while nothing depends on it yet.

3. docs/ASTRO_A50_EXTRA_FEATURES.md. The **Update:** block reads as a changelog entry. Volume belongs in the opening list of implemented features next to battery/chatmix/sidetone/lights/EQ/noise filter, with the table row removed as you did. Same for the comment block in logitech_astro_a50.hpp, which now reads "All six original capabilities were verified".

Two notes, no action needed.

mapSidetoneToDiscrete<22> computes step = 128/22 = 5, so the thresholds stop at 105 and --volume 105 through 128 all land on step 21. Every step is still reachable and it round-trips with mapDiscreteToSidetone, which the read PR will need, so keep it as is.

--volu was an unambiguous abbreviation of --volume-limiter before this and now resolves to --volume. Only affects anyone abbreviating; I'll mention it in the release notes.

I squash on merge, so the Co-Authored-By trailers drop out unless you want them kept.

- Bump API_VERSION to 1.7, since the capability list grew by
  CAP_HEADSET_VOLUME.
- Rename the C API to hsc_set_headset_volume / hsc_headset_volume_t,
  matching the C++ setHeadsetVolume.
- List headset volume with the other implemented A50 features in
  ASTRO_A50_EXTRA_FEATURES.md and the device comment, instead of a
  separate update note.

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

Mihuy1 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Done in f36302a: API_VERSION bumped to 1.7, C API renamed to hsc_set_headset_volume / hsc_headset_volume_t, and volume moved into the A50 feature list and device comment. No need to keep the Co-Authored-By trailers 👍

@Sapd
Sapd merged commit c073504 into Sapd:master Oct 22, 2026
7 checks passed
@github-actions github-actions Bot removed the awaiting-maintainer The author replied or pushed - our move label Oct 22, 2026
Sapd added a commit that referenced this pull request Oct 22, 2026
The CLI parser rejects a sidetone, microphone volume or headset volume
above 128, but Headset::setSidetone(), setMicVolume() and
setHeadsetVolume() are reachable without it, and the C API goes straight
to them. A device scales the 0-128 level onto its own range, so a level
of 255 came out as the device maximum and the result reported
volume = 255 next to max_volume = 128.

Check the range against the capability descriptor before dispatching, so
those three return InvalidParameter / HSC_RESULT_INVALID_PARAM instead.
Anything narrower stays with the device, which validates its own steps.

Found by the Copilot review on #600, where it applies to the new
capability; it was already true for sidetone and microphone volume.
@Mihuy1 Mihuy1 mentioned this pull request Oct 28, 2026
2 tasks done
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.

3 participants