Skip to content

feat(core): add G502 HERO gaming layout - #2293

Open
MikiDevAHM wants to merge 10 commits into
AprilNEA:masterfrom
MikiDevAHM:feat/g502-hero-support
Open

MikiDevAHM wants to merge 10 commits into
AprilNEA:masterfrom
MikiDevAHM:feat/g502-hero-support

Conversation

@MikiDevAHM

@MikiDevAHM MikiDevAHM commented Nov 3, 2026 •

Copy link
Copy Markdown

Summary

Adds a GamingLayout for the wired Logitech G502 HERO (HID++ model key 0c08b), so its extra buttons (G6–G9, wheel tilts) become remappable through host mode and the Buttons panel renders the full 11-button silhouette instead of only the 5 OS-hook buttons. The device was already detected; the missing piece was the per-model 0x8110 slot table.

Device

  • Model: Logitech G502 HERO (wired USB)
  • Connection tested: wired USB
  • VID:PID: 046d:c08b (device reports G502 HERO Gaming Mouse)
  • OS tested: Linux (CachyOS, kernel 7.3)
  • HID++ feature table: 0x0000, 0x0001, 0x0003, 0x0005, 0x00c2, 0x1300, 0x1801, 0x1802, 0x1806, 0x18a1, 0x18b1, 0x1e00, 0x1e22, 0x1eb0, 0x2201, 0x8060, 0x8070, 0x8100, 0x8110

Changes

  • crates/openlogi-core/src/binding/gaming.rs: added G502_HERO GamingLayout (model key 0c08b, 11 slots) and registered it in LAYOUTS; added a resolving test.
  • crates/openlogi-core/src/binding.rs: re-exported G502_HERO.

Hardware verification

Feature Before After
Detected / correct name G502 HERO Gaming Mouse G502 HERO Gaming Mouse
DeviceKind Mouse Mouse
DPI read / set 2400 read, 2450 write/read-back/restore OK (unchanged, verified)
Button capture/remap only 5 OS-hook buttons full 11-button layout (host mode)
GUI panels shown Buttons (5 buttons) Buttons (11 buttons)

CLI output (before / after): feature table unchanged (19 entries incl. 0x8100/0x8110); diag mouse-buttons measured slots: 11, host-mode mapping 01 02 03 04 05 06 07 08 09 0a 0b.

Testing

  • cargo fmt --all -- --check — pass
  • cargo clippy -p openlogi-core -p openlogi-agent-core -p openlogi-desktop --all-targets -- -D warnings — pass
  • cargo test -p openlogi-core — 488 passed
  • cargo test -p openlogi-agent-core — 842 passed
  • cargo test -p openlogi-desktop (geometry) — 21 passed
  • cargo check -p openlogi-core --no-default-features --target wasm32-unknown-unknown — pass
  • RUSTDOCFLAGS="-D warnings" cargo doc -p openlogi-core --no-deps --document-private-items — pass
  • cargo xtask ci ast-grep / typos — skipped (tools not installed on this host)
  • Not run locally: MSRV, clippy (windows/macos), tests (macos/windows), cargo-deny, shell, publish-closure, nix/devenv CI.

Notes for reviewers

  • The slot-to-ButtonId mapping mirrors G502_LIGHTSPEED because the G502 HERO has the same physical button layout and the same identity host-mode mapping (01..0b). The slot count and host-mode mapping were measured on real hardware; the per-slot ButtonId assignment follows the shared physical layout and was not independently re-verified button-by-button. If a reviewer with a G502 HERO finds a button mislabeled, the slots array is the only thing to adjust.
  • stock_dpi_presets is left empty: the on-mouse ROM profile 1 DPI levels were not read on this hardware, so the DPI cycle falls back to user-configured presets rather than guessing.
  • Asset renders (device image/hotspots) live in the external OpenLogi asset mirror; the in-repo side is model-key-driven and needs no change here, but the mirror may need a 0c08b entry for a photo to show. Flagging for maintainers.
  • No new user-visible strings; no locale changes.

Warning to reviewers

During verification, the Buttons panel initially showed only 6 of 11 buttons. Root cause: the asset depot g502_hero stores its side render at a nested path (images/device/side_hero.png), but safe_component_path rejected any path containing /, so the runtime sync could never fetch it and resolve_side_view returned None. I added a second commit to this PR that makes safe_component_path accept nested (but traversal-safe) paths and write_replace create parent directories; the sync now fetches side_hero.png successfully and all 11 buttons render. The change is security-reviewed (each path component is validated as a normal segment; .., ., empty segments and backslashes are still rejected), but please double-check the security implications. The corresponding test was updated to reflect the new (still safe) contract.

AI assistance

Prepared with an AI coding agent; verified on real hardware by the contributor.

@MikiDevAHM
MikiDevAHM requested a review from AprilNEA as a code owner November 3, 2026 10:16
@greptile-apps

greptile-apps Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Confidence Score: 3/5RetriggerView in Greptile

[Medium impact] The changes reach G502 HERO button mapping and shared device-asset workflows.

The PR still needs the missing resolver regression test and the required test counter-proof before merging.

Findings

  1. P1 Nested downloads lack regression tests ▶
  2. P1 Side-view fix lacks regression coverage. ▶

Summary

Adds the wired G502 HERO’s eleven-button layout and supports nested side-render files.

  • G502 HERO buttons can now use their full 11-slot layout.
  • Nested side images can now reach the device view.

Reviews (13) · Last reviewed commit: "Merge branch 'master' into feat/g502-her..." · Reviewed by Greptile

@AprilNEA AprilNEA added needs: decision Needs a maintainer/product decision type: feature New feature request area: hidpp HID++ protocol and device feature support platform: all Cross-platform issue labels Nov 3, 2026 — with Manus Connector
@AprilNEA AprilNEA added area: assets Icons, images, and bundled assets area: cli Command-line interface labels Nov 3, 2026 — with Manus Connector
@MikiDevAHM
MikiDevAHM force-pushed the feat/g502-hero-support branch from 35d1150 to b421809 Compare November 8, 2026 13:00
Comment on lines +346 to +348
if let Some(parent) = dst.parent() {
std::fs::create_dir_all(parent).map_err(fail)?;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Nested downloads lack regression tests

Blocking. The repository requires each bug fix to have a regression test that fails without it. The new safe_component_path assertion only compares paths. Both existing write_replace tests use an existing parent directory, and every is_optional_asset test uses a flat name. Those tests still pass if parent creation or nested side-render selection is removed.

Add write_replace_creates_nested_parents and nested_side_render_is_optional, then record which reverted lines make them fail in the PR.

Rule Used: Severity: medium. Every bug fix ships a regression test that fails without the fix, and the PR states the counter-proof (the reverted line or the killed mutant). A test that passes with the fix reverted is not a regression test: ask for inputs where ... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@iahoeu

iahoeu commented Nov 18, 2026

Copy link
Copy Markdown

Hardware check on Windows, since the PR notes the per-button labels were not confirmed one by one.

Setup

  • G502 HERO, wired, 046d:c08b, model key 0c08b, firmware U1 27.03_B0010
  • Windows 11 (build 26320)
  • Built from master 9ca7ef0 with this PR merged in (MSVC, Rust 1.99.1)

openlogi diag mouse-buttons (0.9.0 release binary), each button pressed and released on its own:

slot button
0 left
1 right
2 wheel click
3 back (rear thumb)
4 forward (front thumb)
5 sniper / DPI shift
6 G7
7 G8
8 G9
9 wheel tilt right
10 wheel tilt left

That matches the G502_HERO table in this PR, including tilt right on slot 9 and tilt left on slot 10 (both tilts pressed twice, same result).

One difference: my unit reports host-mode mapping: 01 02 03 04 05 00 00 00 00 00 00, not the identity 01 … 0b from the description. With this build the agent also logs 0x8110 mapping found onboard is the one host mode writes: not a baseline before G-series host mode active captured=6. G HUB had been installed on this machine before, in case that matters.

Remapping: with this build every remappable button works: wheel click, back, forward, G6 to G9 and both wheel tilts.

GUI: with this PR alone the Buttons panel showed 6 of the 9 remappable buttons. images/device/side_hero.png did download, but the side view was not drawn, so back, forward and G6 had no hotspot. The g502_hero manifest keys its variants by depot name, while resolve_side_view only tried the registry model ids (c08b, aae6). Resolving it through find_variant_in_manifest(…, side_image_for), which is what #2461 does, brings the side view and the three buttons back. So for the HERO this PR needs #2461 to show every button.

Not measured: stock DPI presets.

@MikiDevAHM
MikiDevAHM force-pushed the feat/g502-hero-support branch from 0595ed8 to 402ae8d Compare November 18, 2026 15:12
@MikiDevAHM

Copy link
Copy Markdown
Author

@iahoeu I implemented the suggested fix, and it’s working perfectly for me.
image
Could you test it for me to see if it works on your computer?

@MikiDevAHM
MikiDevAHM force-pushed the feat/g502-hero-support branch from 5dbf4bf to 0a83bde Compare November 19, 2026 11:49
Comment on lines +183 to +184
let variant = manifest
.and_then(|m| find_variant_in_manifest(m, entry, depot, extended_model_id, side_image_for));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Side-view fix lacks regression coverage. Blocking. Add a test such as depot_named_nested_side_view_resolves that calls AssetResolver::resolve with a depot-named manifest entry, a nested side render, and no side.png. Assert the returned side_view path and dimensions.

I checked the existing tests: the depot-named base render uses side.png, which the old fallback already finds; the drawable colour test never checks side_view; and the WebP test uses a registry model ID. None catches removal of this depot-name lookup. The repository requires every bug fix to include a test that fails without it. Record that counter-proof in the PR too.

Rule Used: Severity: medium. Every bug fix ships a regression test that fails without the fix, and the PR states the counter-proof (the reverted line or the killed mutant). A test that passes with the fix reverted is not a regression test: ask for inputs where ... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@iahoeu

iahoeu commented Nov 20, 2026 •

Copy link
Copy Markdown

@MikiDevAHM Tested the current head on my G502 HERO. The side view now resolves with this PR alone.

Setup

Result

  • Download: the depot came back complete, including images/device/side_hero.png (884,767 bytes). GUI log: downloaded file="images/device/side_hero.png".
  • Buttons panel: the side view is drawn next to the top view, and all 9 remappable buttons have a hotspot: wheel click, back, forward, G6, G7, G8, G9, tilt left, tilt right.
  • Logs: no WARN or ERROR in the GUI or agent log at OPENLOGI_LOG=debug, and nothing about failed variant fetches or unsafe paths. Agent: G-series host mode active captured=6.
  • Bindings: G6 (on the side view), G7, G8 and G9 carry non-default bindings from my config (Close Tab, Reload Page, New Tab, Cycle DPI Presets). Each fired its bound action, and both wheel tilts scrolled. G9 switched between my two saved presets (850 / 3200).

Not tested

  • Creating a new binding in this build's GUI. The bindings above were set earlier, with my previous build.
  • The new docs/CONFIGURATION.md paragraph: my config has G6 to G8 rebound and two DPI presets saved, so I did not check the DPI Shift default or the no-presets case.
  • Slot table and host-mode mapping were not measured again.
pr2293-buttons-panel-5999cbb

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: assets Icons, images, and bundled assets area: cli Command-line interface area: hidpp HID++ protocol and device feature support needs: decision Needs a maintainer/product decision platform: all Cross-platform issue type: feature New feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants