fix: detect wired battery-less devices and resolve registry-absent images#281
fix: detect wired battery-less devices and resolve registry-absent images#281davidbudnick wants to merge 2 commits into
Conversation
Greptile SummaryThis PR fixes two issues with directly-connected (wired, battery-less) Logitech devices: a HID++ inventory path that dropped real peripherals when their feature-table walk failed, and a missing image for the G502 HERO in the GUI asset resolver.
Confidence Score: 3/5Safe to merge for the GUI change; the HID fallback has a gap that could leave certain wired keyboards undetected. The crates/openlogi-hid/src/inventory.rs — specifically the Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[probe_direct called] --> B[probe_or_reuse: full FeatureSet walk]
B --> C{walk_succeeded?\nprobe.capabilities.is_some}
C -- Yes --> D[effective_caps = probe.capabilities]
C -- No --> E[peripheral_caps_via_root fallback\n8x root.getFeature round-trips]
E --> F{any PERIPHERAL_FEATURE_IDS\nresponded?}
F -- Yes --> G[fallback_caps = Some caps]
F -- No --> H[fallback_caps = None]
G --> I[effective_caps = fallback_caps]
H --> J[effective_caps = None\ncaps = default]
D --> K{is_peripheral?\nbattery OR buttons OR pointer OR lighting}
I --> K
J --> L[Rejected — not a peripheral\nhealthy = walk_succeeded = false\nreplay last inventory]
K -- No --> L
K -- Yes --> M[Admitted as PairedDevice\ncapabilities = effective_caps\nhealthy = true]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[probe_direct called] --> B[probe_or_reuse: full FeatureSet walk]
B --> C{walk_succeeded?\nprobe.capabilities.is_some}
C -- Yes --> D[effective_caps = probe.capabilities]
C -- No --> E[peripheral_caps_via_root fallback\n8x root.getFeature round-trips]
E --> F{any PERIPHERAL_FEATURE_IDS\nresponded?}
F -- Yes --> G[fallback_caps = Some caps]
F -- No --> H[fallback_caps = None]
G --> I[effective_caps = fallback_caps]
H --> J[effective_caps = None\ncaps = default]
D --> K{is_peripheral?\nbattery OR buttons OR pointer OR lighting}
I --> K
J --> L[Rejected — not a peripheral\nhealthy = walk_succeeded = false\nreplay last inventory]
K -- No --> L
K -- Yes --> M[Admitted as PairedDevice\ncapabilities = effective_caps\nhealthy = true]
Reviews (1): Last reviewed commit: "fix(gui): alias the G502 HERO to the g50..." | Re-trigger Greptile |
| const PERIPHERAL_FEATURE_IDS: [u16; 8] = [ | ||
| 0x1b00, 0x1b01, 0x1b02, 0x1b03, 0x1b04, 0x2201, 0x2202, 0x8080, | ||
| ]; |
There was a problem hiding this comment.
PERIPHERAL_FEATURE_IDS is missing 0x8070 (ColorLedEffects), which Capabilities::from_feature_ids recognises as a driving lighting feature alongside 0x8080. A wired keyboard that exposes only 0x8070 and whose feature-table walk fails would have an empty present list after the fallback probe, causing peripheral_caps_via_root to return None and the device to be dropped — the exact failure mode this PR is designed to fix.
| const PERIPHERAL_FEATURE_IDS: [u16; 8] = [ | |
| 0x1b00, 0x1b01, 0x1b02, 0x1b03, 0x1b04, 0x2201, 0x2202, 0x8080, | |
| ]; | |
| const PERIPHERAL_FEATURE_IDS: [u16; 9] = [ | |
| 0x1b00, 0x1b01, 0x1b02, 0x1b03, 0x1b04, 0x2201, 0x2202, 0x8070, 0x8080, | |
| ]; |
| NAME_ALIASES | ||
| .iter() | ||
| .find(|(needle, _)| name.contains(needle)) | ||
| .map(|&(_, depot)| depot) |
There was a problem hiding this comment.
Codename alias uses substring match —
name.contains(needle) means any future device whose OS product string happens to contain "g502 hero" (e.g. a hypothetical "G502 HERO SE" with a different chassis) would borrow the wrong render without any explicit entry. Since the PID path is authoritative and takes priority, the risk is low today, but as the alias table grows, an exact-match or anchored check would be safer and communicate intent more clearly.
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!
Context
Testing