Skip to content

feat(gui): add support for standalone RS Handbrake and Logitech Racing Adapter - #139

Merged
mescon merged 1 commit into
mescon:masterfrom
gonzaloadrio:feature/standalone-handbrake-and-adapter
Nov 9, 2026
Merged

mescon merged 1 commit into
mescon:masterfrom
gonzaloadrio:feature/standalone-handbrake-and-adapter

Conversation

@gonzaloadrio

@gonzaloadrio gonzaloadrio commented Nov 1, 2026 •

Copy link
Copy Markdown

Summary

Builds on the accessory infrastructure to add userspace discovery, axis/button decoding, and UI monitoring for the remaining Logitech racing ecosystem peripherals when connected via standalone USB or direct-drive wheel base:

  • Logitech G RS Shifter & Handbrake (046d:c278)
  • Logitech G Racing Adapter (046d:c273)

Changes

  1. Logitech RS Shifter & Handbrake (046d:c278):
    • Auto-discovery via evdev device name matching.
    • 10-bit analog scaling (0..1023) for handbrake mode (ABS_Z), displayed with a live progress bar.
    • Sequential shift detection (BTN_TRIGGER / BTN_THUMB) with directional badge indicators in the GUI (gated on standalone handbrake detection).
  2. Logitech G Racing Adapter (046d:c273):
    • Auto-discovery and 12-bit analog scaling (0..4095) for legacy 3-pedal sets: Throttle (ABS_Y), Brake (ABS_Z), and Clutch (ABS_RX).
    • Decoding of the DB9 Driving Force 6+R shifter port (0x120..0x126 standalone, 0x12c..0x2c4 via base) into the UI H-gate monitor.
  3. Kernel Driver (mainline/hid-logitech-hidpp.c):
    • Auto-detect Racing Adapter attached to direct-drive base via 0x8120 (GAMING_ATTACHMENTS) confirmed by feature 0x0005 device name ("Racing Adapter"), preventing any false positive matches on internal sub-devices.
    • Publish comma-separated active accessories in wheel_accessory sysfs attribute without placeholder writes.
    • Enable Desktop mode slot routing (0x8120 + 0x1BC0) when either RS H-Shifter or Racing Adapter is attached.
  4. GUI Monitor (logi-wheel-gui):
    • Pass selected device into Reader::start so accessory polling is anchored to the active wheel and avoids 1 Hz flicker with multiple attached wheels.
    • Preserve press-driven connection state in refresh_accessories.
    • Separate 7+R and 6+R diagrams dynamically based on connected hardware.
  5. Documentation (docs/BUTTON_MAPPING.md & docs/SYSFS_API.md):
    • Documented pinout and reporting behaviour for standalone USB mode vs base accessory port mode for both the RS Shifter & Handbrake and the Racing Adapter.
    • Documented wheel base pedal port axes matching pedal_axes (ABS_RX, ABS_RY, ABS_RZ, ABS_Z on RS50 / G PRO, and G923 PlayStation / Xbox layouts).
    • Updated wheel_accessory values description to comma-separated list or none.

Testing

  • Passes 100% of workspace tests (cargo test --workspace: 219 passed, 0 failed).
  • Hardware-tested with the physical Logitech Racing Adapter, RS Pedals, RS H-Shifter, and RS Shifter & Handbrake.

Closes #144

@gonzaloadrio
gonzaloadrio force-pushed the feature/standalone-handbrake-and-adapter branch 4 times, most recently from 93957b4 to 85b9b9a Compare November 1, 2026 19:13
@gonzaloadrio
gonzaloadrio force-pushed the feature/standalone-handbrake-and-adapter branch 6 times, most recently from 934133f to e88f82a Compare November 4, 2026 22:25

@mescon mescon 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.

Now that #140 is in, this is down to one commit (e88f82a) and merges cleanly. Code looks good; the blockers are in the doc and one code/doc mismatch:

  1. "Pedals Connected to Wheel Base" table contradicts the hardware-verified mapping the Test page itself uses (pedal_axes in evtest.rs, proven per axis in the driver comment above HIDPP_DD_PEDAL_BASE_AXIS): RS50/G PRO throttle ABS_RX, brake ABS_RY, clutch ABS_RZ, handbrake ABS_Z. The G923 editions differ again. Please drop the table or copy those rows.
  2. DB9 Reverse: the doc says 0x127, gear_from_adapter_code says 0x126 and the test asserts 0x127 is nothing. Which did evtest show on your adapter? Fix the other one.
  3. 0x124 is BTN_TOP2 and 0x125 is BTN_PINKIE, not BTN_BASE5/6.
  4. The Shift Up/Down badges follow the paddle codes on every wheel, so they flash on a bare RS50 under a "Shifter & Handbrake" heading. Gate the row on a handbrake-detected flag (you have it from open_standalone_handbrake) or label it as paddles.
  5. One label per source: "Logitech Racing Adapter" at start becomes "Racing Adapter (Driving Force)" after the first gear.

@gonzaloadrio
gonzaloadrio force-pushed the feature/standalone-handbrake-and-adapter branch 2 times, most recently from 2fada03 to eae783f Compare November 7, 2026 10:52
@gonzaloadrio

Copy link
Copy Markdown
Author

Thanks for the thorough review @mescon! I've updated the PR and verified all combinations on live hardware (RS50 Base 046d:c276, RS Shifter & Handbrake, RS H-Shifter, Logitech Racing Adapter 046d:c273, and DB9 Driving Force Shifter):

  1. Base-connected vs standalone pedal axes (docs/BUTTON_MAPPING.md): Fixed the base-connected pedal axis table to match pedal_axes in logi_wheel_core::evtest and HIDPP_DD_PEDAL_BASE_AXIS in hid-logitech-hidpp.c (ABS_RX Throttle, ABS_RY Brake, ABS_RZ Clutch, ABS_Z Handbrake on RS50/G PRO, plus the G923 PlayStation and Xbox mappings), keeping ABS_Y / ABS_Z / ABS_RX (0..4095) under the standalone USB Racing Adapter section.
  2. DB9 Driving Force Shifter Reverse via Racing Adapter (docs/BUTTON_MAPPING.md): Updated the table to 0x126 (BTN_BASE, DirectInput Button 6) to match both the hardware and testio.rs.
  3. Sequential paddle evdev names (docs/BUTTON_MAPPING.md): Corrected 0x124 (BTN_TOP2) and 0x125 (BTN_PINKIE).
  4. Dynamic Shifter & Handbrake card & wheel-base accessory detection (mainline/hid-logitech-hidpp.c, testio.rs, info_page.slint):
    • Extended hid-logitech-hidpp.c (wheel_accessory) to also detect the Racing Adapter on the wheel base (0x8120 GAMING_ATTACHMENTS on sub-device 0x01..0x04), emit a comma-separated list of all connected base accessories (RS Shifter & Handbrake, RS H-Shifter, Racing Adapter), and enable Desktop mode slot routing (0x8120 + 0x1BC0) when either the RS H-Shifter or the Racing Adapter is plugged into the base.
    • Gated 0x124 / 0x125 sequential ▲ Shift Up / ▼ Shift Down badges on actual RS Shifter & Handbrake presence (standalone USB or wheel base via wheel_accessory), so bare wheel paddles no longer light them up.
    • Separated the 7+R (RS H-Shifter) and 6+R (Racing Adapter / Driving Force Shifter) H-gate diagrams and hid the card (or individual subsections) dynamically when the corresponding hardware is not connected. When both the RS H-Shifter and Racing Adapter are plugged into the wheel base at the same time, it collapses to a single H-gate diagram since the base firmware merges both onto the same gear button slots.
  5. #[cfg(test)] in testio.rs: Removed the duplicate attribute.

@mescon mescon 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.

Doc fixes and the badge gating check out against the source. The kernel probe is new in this revision, so two points there, then three small ones:

  1. Adapter detection = Root.getFeature(0x8120) on a candidate sub-device. 0x8120 is a base feature (root index 0x0F on both wheels), and the candidate order probes the base's own 0x01 and 0x05 before 0x04; their catalogs were never enumerated. If either answers, every bare base reports Racing Adapter and gets the desktop routing sequence, and a real adapter at 0x04 is never looked for. Please paste the dmesg pair Racing Adapter at dev 0x0N / Racing Adapter removed from your unplug test, plus a pedals-only boot with no Racing Adapter line. If 0x01 or 0x05 answers, confirm by the 0x0005 name as the S&H does (hidpp_dd_query_accessory_name).
  2. wheel_accessory can print Racing Adapter, Racing Adapter: the S&H name query can leave accessory_name empty, then probe_adapter fills the placeholder and has_shifter emits it. The list is built from the three indices now, so drop the placeholder writes and the rescan juggling; accessory_name holds the S&H's queried name only.
  3. refresh_accessories overwrites shifter_connected/adapter_connected every second, undoing the press-driven true in apply_event. With two wheels Device::discover() answers for whichever sorts first (see the comment above caps in main.rs), so the card flickers at 1 Hz. Pass the selected device into Reader::start and keep one source of truth.
  4. BUTTON_MAPPING says the DB9 Reverse through the base lands on 0x2c3; apply_event maps gate 7 (0x2c2) to R. Which did evtest show? Keep that one.
  5. "(RS50 / G PRO, sub-device 02)": the index is the port, not the device (spec 5.3). Also add Closes #144 to the description, and the SYSFS_API "Values" line still says a single name.

…r base

- Detect Logitech Racing Adapter attached to RS50 / G PRO wheel base via
  HID++ page 0x8120 (GAMING_ATTACHMENTS) confirmed by 0x0005 device name,
  report comma-separated active accessories in sysfs wheel_accessory,
  and enable Desktop mode slot routing (0x8120 + 0x1BC0) when either
  RS H-Shifter or Racing Adapter is connected to the base.
- Add evdev discovery and decoding for standalone RS Shifter & Handbrake
  (046d:c275/046d:c278) and Logitech Racing Adapter (046d:c273).
- Dynamically show/hide the Shifter & Handbrake card sections in
  logi-wheel-gui based on connected accessories (via USB or wheel base):
  - Sequential Shift Up / Shift Down badges only appear and respond when
    RS Shifter & Handbrake is connected (so bare wheel paddles do not
    trigger them).
  - Separate 7+R (RS H-Shifter) and 6+R (Racing Adapter / Driving Force
    Shifter) H-gate diagrams, collapsing to a single diagram when both
    are plugged into the wheel base simultaneously.
  - Pass the selected device into Reader::start to avoid multi-wheel 1 Hz
    flicker, and preserve press-driven accessory connection state.
  - Decode DB9 Driving Force Shifter Reverse through the wheel base on
    0x2c4 (BTN_TRIGGER_HAPPY5).
- Document standalone and base-connected accessories, DB9 6+R shifter
  buttons (0x120..0x126 standalone, 0x12c..0x2c4 via base), and base pedal
  axes in docs/BUTTON_MAPPING.md and docs/SYSFS_API.md.

Closes mescon#144
Signed-off-by: Gonzalo Adrio <gonzaloadrio@gmail.com>
@gonzaloadrio
gonzaloadrio force-pushed the feature/standalone-handbrake-and-adapter branch from eae783f to f740d65 Compare November 9, 2026 17:54
@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

@gonzaloadrio

Copy link
Copy Markdown
Author

Thanks for the thorough review, @mescon! We've addressed all 5 points in the amended commit, verified each one on physical hardware, and confirmed all 219 tests pass green (cargo test --manifest-path userspace/logi-wheel/Cargo.toml --workspace).

Here is the breakdown with hardware evidence:


1. Adapter Detection & 0x8120 Validation

We verified with HID++ feature discovery on /dev/hidraw1 that base sub-devices 0x01 ("RS Wheel Hub") and 0x05 ("RS50 Drive") return 0 (unsupported) for feature 0x8120.
However, to eliminate any possibility of a false positive, hidpp_dd_probe_adapter now queries feature 0x0005 (DEVICE_NAME) via hidpp_dd_read_device_name and strictly validates that the returned name is "Racing Adapter".

Hardware dmesg Captures:

  • Unplug & Reconnect of Logitech Racing Adapter:
    [  259.986872] logitech-hidpp-device 0003:046D:C268.0007: Racing Adapter removed
    [  268.563030] logitech-hidpp-device 0003:046D:C268.0007: Racing Adapter at dev 0x04 (port 2)
    
  • Pedals-Only (no Racing Adapter plugged in):
    $ cat /sys/devices/pci0000:00/.../wheel_accessory
    none
    
    (Kernel log is clean; no Racing Adapter is detected or reported).
  • Simultaneous RS H-Shifter + Racing Adapter plugged into the base:
    $ cat /sys/devices/pci0000:00/.../wheel_accessory
    RS H-Shifter, Racing Adapter
    

2. Dropped Placeholder Writes and Rescan Juggling

  • Removed placeholder writes into ff->accessory_name from hidpp_dd_probe_adapter.
  • Removed accessory name swapping in hidpp_dd_rescan_accessory.
  • ff->accessory_name now exclusively stores the queried name of the RS Shifter & Handbrake. The sysfs comma-separated list is built directly from ff->has_shifter, ff->has_rs_h_shifter, and ff->has_adapter.

3. Gui 1 Hz Polling & Connection State

  • In main.rs, the selected device's sysfs path is resolved and passed into Reader::start(..., sysfs_dir, ...).
  • In testio.rs, probe_base_accessories(sysfs_dir) reads /wheel_accessory directly from the selected wheel's directory rather than triggering Device::discover(), preventing 1 Hz card flicker on multi-wheel systems.
  • In refresh_accessories, press-driven state is preserved:
    snapshot.shifter_connected = snapshot.shifter_connected || base_hs;
    snapshot.adapter_connected = snapshot.adapter_connected || base_ad;

4. Reverse Gear Button Codes: Investigation & Resolution

You were spot on to question the discrepancy between 0x2c3 in BUTTON_MAPPING.md and apply_event mapping gate 7 (0x2c2) to R.

Here is what happened and what the live hardware capture revealed:

  1. Origin of the discrepancy:

  2. Live Hardware Capture (evtest on /dev/input/event2 and raw HID report 0x08 on /dev/hidraw0):
    When physically engaging gears on the base:

    • Gears 1–6: 0x12c..0x12f, 0x2c0..0x2c1
    • Gate 7 (RS H-Shifter): 0x2c2 (BTN_TRIGGER_HAPPY3)
    • Reverse (both RS H-Shifter and DB9 Driving Force Shifter via Racing Adapter): 0x2c4 (BTN_TRIGGER_HAPPY5).

    Raw HID Report 0x08 for Reverse:
    08 00 00 01 20 80 00 00 -> Byte 3 bit 0.
    In the RS50 HID descriptor (4 hat bits + 28 buttons), Byte 3 bit 0 corresponds to button 21, which evdev maps to 0x2c4 (BTN_TRIGGER_HAPPY5), not 0x2c3.

    (Note: Swapping physical USB ports on the base yields the exact same 0x2c4 evdev code).

  3. Fix:

    • evtest::gear_from_wheel_code: mapped 0x2c3 | 0x2c4 => Some(8) so 0x2c4 is decoded directly as Reverse (while keeping 0x2c3 for compatibility).
    • testio.rs: removed if gear == 7 { 8 }; gate 7 cleanly decodes to 7, and Reverse decodes natively via 0x2c4.
    • docs/BUTTON_MAPPING.md: updated to document 0x2c4 as Reverse through the base.

5. Documentation & PR Description

  • In docs/BUTTON_MAPPING.md, corrected "sub-device 02" to refer to accessory ports / pedal ports per spec 5.3.
  • In docs/SYSFS_API.md, updated the wheel_accessory "Values" line to specify a comma-separated list of connected accessory names or none.
  • Added Closes #144 to the amended commit message and PR description.

@mescon mescon 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.

All five addressed, and the 0x0005 name check settles the probe question without the dmesg. Thanks for pinning Reverse to 0x2c4 on hardware for both shifters; that corrects a row from #140 as well. One leftover in BUTTON_MAPPING: rows 19 and 20 and the "12 to 19" sentence still describe the old theory. I will fold that into the release docs together with the same wording in the README, changelog and wiki, and the two en-dashes. Merging; this goes into 0.43.0 with the H-Shifter.

@mescon
mescon merged commit cd80b18 into mescon:master Nov 9, 2026
17 checks passed
mescon added a commit that referenced this pull request Nov 9, 2026
…lone handbrake)

Resolve the two doc hunks in favour of the hardware-verified facts from
#139: Reverse is button 20 (evdev 0x2c4) on the H-Shifter and on a DB9
shifter through the Racing Adapter, index 19 is not used, and
wheel_accessory lists every attached accessory in a fixed order.
mescon added a commit that referenced this pull request Nov 9, 2026
Add the 0.43.0 changelog items for #139: the Racing Adapter on the base,
the standalone RS Shifter & Handbrake and adapter on the Test page, and
wheel_accessory listing every attached accessory (closes #144). Correct
the H-Shifter button range to 12 to 20 with Reverse on button 20 (evdev
0x2c4) in the README and changelog, add the adapter to the README matrix
and paragraph, and bring the FEATURE_MATRIX note and the two driver
comments above wheel_accessory in line with the three-accessory list.
Set the release date.
@mescon mescon mentioned this pull request Nov 13, 2026
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.

Expose both accessories when an RS H-Shifter and an RS Shifter & Handbrake are attached together

2 participants