Skip to content

Limit PRO X 2 legacy battery fallback to unsupported features#538

Open
ChrisLauinger77 wants to merge 2 commits into
Sapd:masterfrom
ChrisLauinger77:codex/pro-x2-centurion-battery-only
Open

Limit PRO X 2 legacy battery fallback to unsupported features#538
ChrisLauinger77 wants to merge 2 commits into
Sapd:masterfrom
ChrisLauinger77:codex/pro-x2-centurion-battery-only

Conversation

@ChrisLauinger77

@ChrisLauinger77 ChrisLauinger77 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • propagate Logitech G PRO X 2 LIGHTSPEED Centurion battery timeouts, offline results, and HID errors directly
  • retain the former vendor-specific battery query only when CENTURION_BATTERY_SOC is genuinely unsupported
  • add regression coverage for the fallback decision

Motivation

The Logitech G PRO X 2 LIGHTSPEED (046d:0af7) is handled as a Centurion device. Its sidetone, inactive-time, equalizer, and primary battery capabilities use the Centurion protocol.

Previously, every failed Centurion battery query was followed by a second query using the older vendor-specific 0x51 packet format. When the headset was powered off but its USB receiver remained connected, each poll could therefore send two different protocol sequences and consume two HID read timeouts.

During long-running Windows testing, repeated polling while the headset was automatically powered off was correlated with the receiver entering a persistent slow state: later HID discovery calls could take about 60 seconds even after the headset was powered on again. Avoiding the second transaction after communication failures makes the offline path shorter and prevents mixing protocols when the device is not responding.

The legacy query remains available for compatibility when Centurion feature discovery succeeds but reports that CENTURION_BATTERY_SOC is not supported. This preserves support for a potential firmware variant that exposes the older battery packets without the Centurion battery feature.

This PR intentionally does not claim that the former fallback is the proven sole cause of the Windows HID slowdown; it removes the redundant request specifically from timeout and error paths so that the scenario can be retested cleanly.

Behavior change

  • NotSupported: try the legacy vendor-specific battery query.
  • Timeout, DeviceOffline, HIDError, or any other Centurion failure: return the original error without sending a second battery request.
  • Successful Centurion battery results are unchanged.

Validation

  • clean CMake/Ninja build with unit tests enabled
  • ctest --output-on-failure: 2/2 tests passed
  • regression assertions for NotSupported, Timeout, DeviceOffline, and HIDError
  • git diff --check
  • tested on Linux with physical Logitech G PRO X 2 LIGHTSPEED hardware using headsetcontrol -o json; battery output works correctly

The original long-running Windows reproduction scenario will be retested once this change is available to QontrolPanel through the HeadsetControl submodule.

@ChrisLauinger77 ChrisLauinger77 marked this pull request as ready for review July 10, 2026 14:43
@ChrisLauinger77 ChrisLauinger77 marked this pull request as draft July 10, 2026 14:43
@ChrisLauinger77 ChrisLauinger77 marked this pull request as ready for review July 10, 2026 14:47

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e942cbf563

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// PID 0x0af7 uses Centurion exclusively. Propagate failures instead of
// sending the former vendor-specific battery request as a fallback.
if (!centurion_battery) {
return centurion_battery.error();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore the legacy battery fallback

When the Centurion feature lookup/request fails (for example on a G PRO X 2 firmware that still exposes the legacy 0x51/0x0b battery packets but not CenturionBatterySoc, or when discovery times out), this early return makes CAP_BATTERY_STATUS fail even though the previous vendor-specific query path could still return the battery level and detect power-off packets. The class still targets the 0xffa0 vendor protocol, so keeping the fallback for Centurion failures avoids regressing those supported devices.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, good point regarding a potential firmware variant without CenturionBatterySoc. I updated the implementation to retain the legacy battery query only when the Centurion lookup returns NotSupported. Communication failures such as Timeout, DeviceOffline, and HIDError now propagate immediately, so the offline scenario cannot issue a second battery request. I also added regression coverage for this fallback decision.

@ChrisLauinger77 ChrisLauinger77 changed the title Use Centurion exclusively for PRO X 2 battery queries Limit PRO X 2 legacy battery fallback to unsupported features Jul 10, 2026
@ChrisLauinger77

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: c87c3bf46e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

1 participant