Commit Graph

106 Commits

Author SHA1 Message Date
Ken Sanislo 12aabf029b
centurion: support PRO X 2 LIGHTSPEED headphones Centurion features (#3150)
* Add Centurion transport and PRO X 2 LIGHTSPEED headset support

Adds support for the Logitech PRO X 2 LIGHTSPEED Gaming Headset (PID 0x0AF7)
which uses the Centurion transport protocol (report ID 0x51 on USB usage page
0xFFA0) instead of standard HID++ report IDs.

Changes:
- HID enumeration: detect Centurion devices via report descriptor parsing
  (usage page 0xFFA0, report ID 0x51, 63-byte frames)
- Centurion transport: wrap/unwrap HID++ 2.0 frames in Centurion framing
  for write, read, and ping operations
- Feature discovery: enumerate features individually on Centurion devices
  (different response format: [remaining_count, feat_hi, feat_lo])
- Device descriptor for PRO X 2 LIGHTSPEED Gaming Headset
- New feature enum entries for Centurion-era headset features (0x06xx)
- CenturionRawRW class for write-only headset settings controlled via
  raw Centurion commands reverse-engineered from HeadsetControl
- HeadsetSidetone setting (0-100 range, persisted locally)

Known limitations:
- Only sidetone control is implemented; other features need RE work
- Settings are write-only (no read-back from device)
- Headset features (0x06xx) not discoverable via IRoot; registered manually

* Remove static PRO X 2 descriptor; fully probe Centurion devices at runtime

Replace the hardcoded descriptor entry with dynamic discovery of all device
properties via the Centurion protocol. The headset name, kind, serial,
firmware, and battery are now probed at runtime — matching how the device
actually presents itself rather than relying on static data.

Key changes:
- Discover sub-device features via CentPPBridge and route requests through
  the bridge automatically
- Infer device kind from feature IDs (0x06xx = headset) for both wireless
  and direct USB connections
- Read device name from USB product string with protocol probe fallback
- Parse bridge error responses (sub_feat_idx=0xFF) instead of timing out
- Handle unknown HID++ error codes gracefully in base.py
- Fix firmware deduplication for Centurion parent devices
- Prefer sub-device serial/firmware over parent (non-printable) values
- Add Centurion-aware display in solaar show with parent/sub-device sections
- Support both wireless (0AF7 dongle) and direct USB (0AF8) connections

* Display Centurion dongle as receiver with headset as child device

- Add CenturionReceiver class that provides the Receiver UI interface so
  the dongle appears as a parent with the headset indented underneath,
  matching how Lightspeed/Unifying receivers display
- Independently probe dongle features via feature_request() on the
  CenturionReceiver, separate from headset features via bridge
- Fix bridge notification dispatch: remove incorrect sub_cpl=0xFF filter
  that was silently dropping all battery and other notifications
- Fix battery status decoding: charging status is at byte 2 (not byte 1)
  of the CENTURION_BATTERY_SOC response
- Detect wired vs wireless by checking for CentPPBridge in discovered
  features; wired headsets fall back to standalone Device
- Name the dongle "Centurion Receiver" to distinguish from the headset
- Filter unprintable dongle serial (control characters 0x14-0x1F)
- Update CLI show output with proper receiver/child hierarchy and spacing

* Fix headset setting validators and code formatting

- Add signed int8 support to RangeValidator for HeadsetMicGain (0x0611)
- Make HeadsetSidetone version-aware: v1 uses 2-byte skip, v2+ uses
  3-byte skip with 0xFF separator per protocol spec
- Fix ruff formatting in device.py, listener.py, udev_impl.py
- Update CenturionReceiver test for renamed receiver

* Use ConnectionStateChangedEvent for headset online/offline detection

Replace ad-hoc heuristics with proper bridge event function dispatch:
- Function 0 (ConnectionStateChangedEvent): parse sub-device list length
  to determine connect (len>0) vs disconnect (len=0)
- Function 1 (MessageEvent): fallback online detection if headset sends
  a message while marked offline (handles cold-start power-on)

Remove CPL sub_id>=0x80 fallback in listener that misidentified HID++
error replies as disconnect events. Skip HID++ 1.0
set_configuration_pending_flags for CenturionReceiver (not supported).

Also adds OnboardEQ (0x0636) support, bridge multi-fragment sends,
bridge-based headset ping probe, and CLI offline display.

* Update PRO X 2 LIGHTSPEED device doc with current solaar show output

* Fix Centurion protocol version display (1.16 not 2.6)

The HID++ ping math (major + minor/10.0) produced a bogus "2.6" for
Centurion devices whose ProtocolCapabilities returns major=1, minor=0x10.
Store the raw (major, minor) bytes from the ping response and display
them correctly as "Centurion 1.16" in both CLI and GUI.

* Add OnboardEQ (0x0636) support for Centurion headsets

Implement host-computed biquad EQ coefficient generation and multi-fragment
bridge writes for the PRO X 2 LIGHTSPEED headset's 5-band parametric EQ.

The coefficient algorithm uses standard Audio EQ Cookbook peaking EQ formulas
with a simplified rescale normalization (max_b0 × 1.19 headroom). This is our
own implementation — not an exact replica of LGHUB's ~350-line per-band cascade
normalization — but it produces functionally correct results. The DSP
compensates via the rescale factor, and the EQ changes are audible and working
on real hardware.

Wire format verified against 38 LGHUB pcap writes:
- 4-byte LE section headers, LE uint16 coefficient words
- Mixed Q1.31/Q2.30 fixed-point with 24-bit precision
- Only b-coefficients divided by rescale; a-coefficients unchanged
- Two sections: 48kHz playback + 16kHz mic
- No trailing padding, no extra words between sections

Changes:
- base.py: Add flags parameter to write_centurion_cpl() for multi-fragment CPL
- device.py: Rewrite multi-fragment bridge send — proper CPL fragmentation with
  fragment 0 carrying bridge prefix/hdr and continuations carrying raw sub_msg,
  all fragments sent back-to-back without intermediate ACKs
- hidpp20.py: Replace placeholder coefficient code with full biquad math,
  mixed Q-format quantization, rescale normalization, and dual-section output
- settings_templates.py: Persist EQ to slot 0x80 after writing to slot 0x00
  so settings survive power cycle
- tests: Update expected SetEQParameters payloads for new coefficient format

* Extract Centurion protocol into separate modules

Move CenturionReceiver class, factory function, and Centurion protocol
queries (firmware, serial, hardware info, battery, name) from device.py
and hidpp20.py into new centurion.py module. Move OnboardEQ biquad math
and payload builders from hidpp20.py into new onboard_eq.py module.
Move _read_usb_product_string() to common.py to avoid circular imports.

Re-exports preserve backward compatibility for all existing callers.

* Add vertical graphic EQ slider widget for headset equalizer

Replace horizontal slider rows with a traditional graphic EQ layout
using vertical sliders side-by-side, with dB value display and
frequency labels per band.

* Fix device online state clobbered by debug ping in _status_changed

The INFO-level logging guard in _status_changed() called device.ping()
before logging, purely to show accurate online status. But ping() has
side effects — it sets device.online based on the result. When a
ConnectionStateChangedEvent correctly marked a device online, the
subsequent _status_changed() callback would re-ping. If the device
wasn't ready yet (e.g. Centurion headset still booting), the ping
timed out and set online back to False, requiring 2-3 power cycles
to sync state.

Remove the unnecessary ping — the log message already reads
device.online which reflects the state set by the event handler.

* Sort feature constants by ID and add PROFILE_MANAGEMENT

Move RPM_INDICATOR/RPM_LED_PATTERN (0x807A-B) before PER_KEY_LIGHTING
(0x8080-81), sort five Centurion-era headset entries into their correct
positions by feature ID, and add missing PROFILE_MANAGEMENT = 0x8101.

* Add CenturionCoreFeature enum for colliding feature IDs

Centurion transport reuses HID++ 2.0 feature IDs 0x0000, 0x0001,
0x0003, 0x0005, 0x0007 with different meanings. Since SupportedFeature
(IntEnum) requires unique values, create a separate CenturionCoreFeature
enum and resolve_feature() helper for transport-aware lookup.

Also replace the +0x100 offset hack in FeaturesArray.inverse with a
dedicated sub_inverse dict for sub-device feature indexing.

* Fix ruff I001 import sorting in centurion.py and hidpp20.py

* Add 9 missing centurion/headset feature names

Add feature constants split out from the HID++ 2.0 names PR (#3153):
CENTURION_LED_BRIGHTNESS (0x0110), CENTURION_EU_POWER_MODE (0x0115),
CENTURION_DEVICE_BOOL_STATE (0x0116), HEADSET_ADVANCED_PARA_EQ (0x020D),
HEADSET_MIC_TEST (0x020E), HEADSET_EQ_STYLES (0x0213),
BT_HOST_INFO (0x0305), LIGHTSPEED_PAIRING (0x0309),
BT_GAMING_MODE (0x030A).

* Extract _record_ping_protocol helper so all ping paths capture Centurion version

The raw Centurion (major, minor) pickup was only in the Centurion-child
dongle branch of Device.ping(). Wired Centurion variants (e.g. PRO X 2
LIGHTSPEED 046d:0AF8) go through the generic fallback branch and never
recorded the raw version, so they displayed "Centurion 2.6" instead of
"Centurion 1.16".

Extract the protocol + centurion version recording into a helper and
call it from both branches.

---------

Co-authored-by: Peter F. Patel-Schneider <pfpschneider@gmail.com>
2026-04-14 11:43:23 -04:00
Caio Quirino da Silva 5478224cfa
device: Add PRO X 2 Superstrike mouse support with HITS tuning settings (#3132)
* feat: PRO X 2 Superstrike support with click haptics, actuation point and rapid trigger config support

* feat: PRO X 2 Superstrike docs

* docs: document PRO X 2 Superstrike features, device entry, and capabilities

* fix: code review points

# Conflicts:
#	lib/logitech_receiver/hidpp20_constants.py

* Fix the write_key_value for dpi_extended

I was playing with the branch from the MR and I wanted to fix the cli stuff, it now properly sets when I use:

solaar config 1 dpi_extended X 400

Should be enough

Signed-off-by: Shane Fagan <mail@shanefagan.com>

* Fix ruff style check

---------

Signed-off-by: Shane Fagan <mail@shanefagan.com>
Co-authored-by: Shane Fagan <mail@shanefagan.com>
2026-04-12 09:53:47 -04:00
Peter F. Patel-Schneider 230eaf242c docs: add several device descriptions 2026-03-19 11:27:26 -04:00
Peter F. Patel-Schneider 40dcaadec7 docs: add information on G733 Gaming Headest 2026-02-05 10:41:07 -05:00
Peter F. Patel-Schneider a79bb24da5 cli: correctly handle timeout in Bolt discovery 2026-01-18 14:21:56 -05:00
Peter F. Patel-Schneider 97311bed5f ui: handle missing receiver_path more gracefully 2026-01-08 12:38:14 -05:00
Peter F. Patel-Schneider cff0110f81 settings: add scroll ratchet force setting 2025-11-04 03:25:12 +09:00
Peter F. Patel-Schneider 2cb5fa4b97 settings: ignore hidden features 2025-10-27 15:27:13 -04:00
Peter F. Patel-Schneider 0335dd003c release 1.1.15rc2 2025-10-10 09:19:31 -04:00
Ágata Leuck 33a06ac834 docs: add G604 mouse details 2025-04-13 20:29:39 -04:00
ml- ebf8493e72 docs: add information for MX Anywhere 3 for Business 2025-03-29 09:24:07 -04:00
Peter F. Patel-Schneider cf038fd982 settings: improve label and description for LED zone settings 2024-04-19 16:05:29 -04:00
Peter F. Patel-Schneider 08c748c593 release 1.1.12rc1 2024-04-19 03:54:54 -04:00
Peter F. Patel-Schneider c23c6b7124 docs: update EX100 information 2024-03-09 10:36:40 -05:00
Peter F. Patel-Schneider 86fa3757f3 docs: add descriptions of G305 and MX Keys S 2024-01-30 08:02:25 -05:00
Peter F. Patel-Schneider 67b883ac28 docs: add descriptions of M650 and PRO X 2 2024-01-20 11:23:01 -05:00
Peter F. Patel-Schneider 864065c0a5 docs: add file for G915 2023-12-24 23:59:34 -05:00
Peter F. Patel-Schneider 94e9cfce8e docs: add files for MX Anywhere 2S and G915 2023-12-24 23:59:34 -05:00
Peter F. Patel-Schneider 9350300fd8 device: remove incorrect feature for M325 mice 2023-12-14 08:50:02 -05:00
Peter F. Patel-Schneider 05e9441d3b docs: add description of several devices 2023-05-19 07:12:19 -04:00
Peter F. Patel-Schneider c6f468db06 docs: add description for LIFT mouse 2023-03-09 06:43:35 -05:00
Peter F. Patel-Schneider bdde284b38 docs: update information about MX Master 3 for Business 2023-03-02 07:57:26 -05:00
Peter F. Patel-Schneider 49bb19bde4 doc: add description of G304 Lightspeed Wireless Gaming Mouse 2023-02-21 10:25:30 -05:00
Peter F. Patel-Schneider acc559743e docs: add Logi Pop Keys description 2023-02-18 11:25:25 -05:00
Peter F. Patel-Schneider 71e70d5087 doc: update documentation for EX100 receiver 2023-02-11 12:28:01 -05:00
Peter F. Patel-Schneider de308464b0 doc: add description of Illuminated Keyboard with ID C318 2023-02-03 09:34:27 -05:00
Peter F. Patel-Schneider c9f9425b37 doc: update lightspeed receiver descriptions 2023-01-09 13:22:45 -05:00
Peter F. Patel-Schneider 7c12d0ccd2 docs: add description of G535 and N545 2022-12-31 12:23:23 -05:00
vulpes2 eacbfbd178
device: add description for K470 keyboard from the MK470 combo (#1945) 2022-12-25 20:11:48 -05:00
Peter F. Patel-Schneider bd370c07e7 docs: add description of G903 2022-12-17 13:06:23 -05:00
Peter F. Patel-Schneider 9c361c4cf6 docs: update documentation on several devices 2022-11-16 10:35:37 -05:00
Peter F. Patel-Schneider 7dc466fdf4 docs: update documentation on several devices 2022-11-15 15:29:48 -05:00
Peter F. Patel-Schneider 106959d33a doc: update devices directory 2022-11-14 16:51:38 -05:00
Peter F. Patel-Schneider 7a6d673503 docs: add description of several devices 2022-11-08 21:43:38 -05:00
Peter F. Patel-Schneider 178ef1eab9 doc: add Wireless All-in-One Keyboard TK820 2022-11-03 07:22:00 -04:00
Peter F. Patel-Schneider 51a917e6ac docs: add Dell-branded mouse and keyboard 2022-10-21 16:48:07 -04:00
Peter F. Patel-Schneider 5b66dc5796 docs: update description of Marathon Mouse M705 2022-10-13 16:00:15 -04:00
Peter F. Patel-Schneider 255c315ce1 docs: add Dell receiver and several devices 2022-10-13 16:00:15 -04:00
Peter F. Patel-Schneider 87d13ddc5c docs: update G733 description 2022-09-27 16:46:02 -04:00
Peter F. Patel-Schneider 3a0a9e04b0 docs: update description for G502 and add description for G733 headset 2022-09-25 12:22:36 -04:00
Peter F. Patel-Schneider 500ae07363 docs: update Marathon Mouse M705 101B description 2022-09-20 21:03:28 -04:00
Peter F. Patel-Schneider f7898cd994 docs: add description of Marathon Mouse M705 2022-09-15 09:51:24 -04:00
Peter F. Patel-Schneider 13cc244499 docs: add several device descriptions 2022-09-14 19:03:59 -04:00
Peter F. Patel-Schneider ee1bd06f64 release 1.1.5rc1 2022-09-10 09:41:31 -04:00
Peter F. Patel-Schneider 3580da62d9 docs: move old device descriptions to new locations and fix up 2022-09-07 11:42:10 -04:00
Peter F. Patel-Schneider 14587c4aed doc: descriptions for K360 4004 and MX Master 4071 2022-09-04 12:05:53 -04:00
Peter F. Patel-Schneider 4a8cd92824 doc: descriptions for Lightspeed Receiver C541 and G915 WIRELESS RGB Mechanical Gaming Keyboard 407E 2022-09-04 12:05:53 -04:00
Peter F. Patel-Schneider f6764fcc87 docs: update ERGO M575 Trackball 4096 description 2022-08-23 08:29:15 -04:00
Peter F. Patel-Schneider f884930c74 docs: add Wireless Mobile Mouse MX Anywhere 2S 406A description 2022-08-23 08:29:15 -04:00
Peter F. Patel-Schneider 7bf187b7ca docs: add device information for ERGO M575 Trackball 2022-08-21 06:08:40 -04:00