Repository navigation
Add headset volume capability with ASTRO A50 Gen 5 support - #600
Conversation
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>
There was a problem hiding this comment.
🟡 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
|
|
||
| Result<HeadsetVolumeResult> Headset::setHeadsetVolume(uint8_t volume) | ||
| { | ||
| HEADSET_FEATURE_IMPL(CAP_HEADSET_VOLUME, setHeadsetVolume, volume); |
Sapd
left a comment
There was a problem hiding this comment.
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 changedtests/test_output_formats.cpp:73docs/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>
|
Done in f36302a: |
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.

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 LEVELsets the volume on a 0–128 scale, the same as sidetone and microphone volume.Headset::setHeadsetVolume) and the C API (HSC_CAP_HEADSET_VOLUME,hsc_set_volume).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 withmapSidetoneToDiscrete<22>().--readme-helper, andLIBRARY_USAGE.mdandADDING_A_DEVICE.mdare updated.Tested on a real A50 Gen 5:
--volume 0,64and128give 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*_STATUScapability.The PR has three commits: the core capability, the A50 implementation, and the regenerated README table.
Checklist