Commit Graph

940 Commits

Author SHA1 Message Date
Peter F. Patel-Schneider 9c80b64b49 device: fix interface for K845 2026-04-14 11:45:17 -04:00
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
Alessio85 7d571d855f
device: Fix crash in NotificationFlag.flag_names when flags is None (#3185)
flag_names() crashes with AttributeError when NotificationFlag returns
a value whose .name attribute is None. This occurs with certain receiver
firmware versions (Nano C52F, Unifying C52B, Bolt C548).

Return an empty list instead, consistent with the List[str] return type.

Fixes #3184

Co-authored-by: avercelli <avercelli@vulog.com>
2026-04-13 12:46:43 -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
Ken Sanislo b9e0cf8235
hidpp: Add names for HID++ 2.0 features and sort by ID (#3153)
Add 30 documented HID++ 2.0 feature names from LGHUB source analysis:
keyboard/mouse (PROPERTY_ACCESS, BLE_PRO_PRE_PAIRING, FULL_KEY_CUSTOMIZATION,
CONTROL_LIST, SWITCH_SWAPABILITY, DEVICE_MODE, ENABLE_HIDDEN_FEATURES,
KEYBOARD_DISABLE_CONTROLS, LOGI_MODIFIERS), racing peripherals
(RPM_INDICATOR, RPM_LED_PATTERN, LEGACY/AXIS_RESPONSE_CURVE, BANDED_AXIS,
COMBINED_PEDALS, BUNNY_HOPPING, PROFILE_MANAGEMENT, DUAL_CLUTCH,
WHEEL_CENTER_POSITION, DISPLAY_GAME_DATA, CENTER_SPRING, AXIS_MAPPING,
GLOBAL_DAMPING, BRAKE_FORCE, PEDAL_STATUS, TORQUE_LIMIT,
CONFIGURATION_PROFILES, OPERATING_RANGE, TRUE_FORCE, FFB_FILTER).

Sort RPM_INDICATOR/RPM_LED_PATTERN (0x807A-B) before PER_KEY_LIGHTING
(0x8080-81) to maintain ID ordering.
2026-03-20 09:07:11 -04:00
Peter F. Patel-Schneider a22ae124d9 device: don't use Logitech for codename 2026-03-19 11:27:26 -04:00
Peter F. Patel-Schneider ee25bc76c7 device: put lock around getting device name 2026-03-19 11:27:26 -04:00
Peter F. Patel-Schneider dc9affe6fb hidpp: fix bug when showing device notification flags 2026-03-19 11:27:26 -04:00
Peter F. Patel-Schneider 7520c9cc28 hidpp20: be defensive about no device features 2026-03-13 16:21:51 -04:00
Peter F. Patel-Schneider 94e94c1254 hidpp: add feature x1b04 flag sent by M510 4004 2026-03-13 16:21:51 -04:00
Peter F. Patel-Schneider 55a67c142c device: remove incorrect descriptor for WPID 4004 2026-03-13 16:21:51 -04:00
Peter F. Patel-Schneider f17021e2f0 rules: remove use of XTest and use uinput in all cases 2026-03-08 20:58:43 -04:00
Niko Savola 30d4d0f65d
Update Finnish localization (#3154)
* Update Finnish translation template

* Add missing Finnish translations and polish

* Fix typo feeback → feedback

* Update translators list and solaar.pot
2026-03-05 07:53:51 -05:00
Peter F. Patel-Schneider d919bcbb30 device: downgrade ping no such device to informational log entry 2026-02-26 08:46:22 -05:00
Peter F. Patel-Schneider 97dd9467b5 device: add names for G500 mouse 2026-02-26 07:49:18 -05:00
Peter F. Patel-Schneider cbb3106993 device: recover from guessing the wrong number for direct-connected HID++ 1.0 devices 2026-02-26 07:49:18 -05:00
Peter F. Patel-Schneider 6926047020 device: handle inaccessiable devices when determining protocol 2026-01-08 12:37:31 -05:00
Peter F. Patel-Schneider 705279097f cli: allow to change LED settings 2025-12-21 18:03:53 -05:00
Peter F. Patel-Schneider e999b12246 receiver: add info about new lightspeed receiver 2025-12-17 15:52:17 -05:00
Peter F. Patel-Schneider d3216ea57a device: remove debugging statement 2025-12-17 15:44:14 -05:00
Peter F. Patel-Schneider ff23601183 device: fix bug when showing details about direct-connected device 2025-12-16 15:23:06 -05:00
Gabriel Ebner 1dd1ace327
cli: Fix crash when showing notification flags. (#3070) 2025-12-12 04:54:10 -05:00
Peter F. Patel-Schneider 8298db0891 receiver: fix crash when turning notification flags into strings 2025-12-11 15:23:06 -05:00
Peter F. Patel-Schneider 4c63bdb6ee
show better pairing errors (#3063)
* Fix: Show pairing error str

Fixes #2827

* device: also show bolt pairing errors

---------

Co-authored-by: MattHag <16444067+MattHag@users.noreply.github.com>
2025-12-10 11:18:50 -05:00
Peter F. Patel-Schneider 2e549371ef device: fix typing issue with notification flags 2025-12-10 07:31:48 -05:00
Peter F. Patel-Schneider 50fed28b3b device: permit onboard profiles data version 5 2025-12-04 04:04:27 -05:00
Peter F. Patel-Schneider 3686920e85 settings: add onboard profiles warning to sensitivity tooltip 2025-11-25 09:26:45 -05:00
Peter F. Patel-Schneider dc3412c83b device: remove Solaar name for mice with WPID 4008 2025-11-15 19:32:18 -05:00
Peter F. Patel-Schneider 29bf463509 settings: prevent lock failure when showing debug messages 2025-11-15 18:21:18 -05:00
danicc097 817c90e561
replace color picker (#3028)
* replace color picker
2025-11-15 11:05:59 -05:00
Peter F. Patel-Schneider 0fd262424e settings: add setting for HAPTIC feature 2025-11-12 14:50:46 -05:00
Peter F. Patel-Schneider 97b6b958c8 settings: expand new settings type 2025-11-12 14:33:34 -05:00
Peter F. Patel-Schneider f739331dc2 settings: add new settings type for structure-backed setting 2025-11-12 14:33:34 -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 b96d0bbe0b rules: fix debug messages for MouseClick rule 2025-11-02 21:01:33 +09:00
Peter F. Patel-Schneider 96adf6a026 rules: improve debug message for rule evaluation 2025-11-02 20:58:44 +09:00
Peter F. Patel-Schneider 2cb5fa4b97 settings: ignore hidden features 2025-10-27 15:27:13 -04:00
Peter F. Patel-Schneider 44a647499c ui: don't pop up window in response to ADC changes 2025-10-25 10:41:35 -04:00
Peter F. Patel-Schneider 5c94cf4d9f device: fix error in low-level request for device with no recevier 2025-10-23 12:58:01 -04:00
Peter F. Patel-Schneider 51630421b2 device: add new flags for reprogrammable keys feature 2025-10-22 16:46:40 -04:00
Peter F. Patel-Schneider ab517577b5 device: correctly handle missing battery feature 2025-10-22 16:46:40 -04:00
Peter F. Patel-Schneider a866de47fb udev: correctly re-raise access exception 2025-10-17 19:41:23 -04:00
Peter F. Patel-Schneider f942dbec41 device: add special keys from Logitech 2025-10-16 20:57:15 -04:00
Peter F. Patel-Schneider 783bd5e4da device: fix bug with unknown tasks 2025-10-05 08:05:15 -04:00
Peter F. Patel-Schneider dc28ab61c2 device: add shape keys from Key POP Icon 2025-09-30 10:34:23 -04:00
Peter F. Patel-Schneider 94f4c3230b rules: Device and Action rule conditions match on codename and name 2025-09-30 10:23:50 -04:00
Peter F. Patel-Schneider bebadc219c
fixes battery setting when device is not available (#2890)
* device: fix battery setting when device is not available
2025-06-09 05:31:52 -04:00
Peter F. Patel-Schneider 694513832d
device: report symbolic names for pairing errors (#2886)
* device: report symbolic names for pairing errors

* testing: fix testing of notifications
2025-05-31 08:12:42 -04:00
Alban Browaeys 7066ec40c9
device: Fix listing hidpp10 devices - bytes vs string concatenation (#2856)
* Fix listing hidpp10 devices - bytes vs string concatenation

Fix error concatenating a bytes with a string.

Closes #2855.

Fixes: 5e0c85a6 receiver: Refactor extraction of serial and max. devices

* Update lib/logitech_receiver/receiver.py

---------

Co-authored-by: Peter F. Patel-Schneider <pfpschneider@gmail.com>
2025-04-22 08:47:26 -04:00
Peter F. Patel-Schneider abea1c4341 device: add present flag, unset when internal error occurs, set when notification appears 2025-04-22 08:45:55 -04:00