docs(core): correct the model_ids transport ordering, and fix the MX Keys mock - #668
Open
yuzi-co wants to merge 1 commit into
Open
docs(core): correct the model_ids transport ordering, and fix the MX Keys mock#668yuzi-co wants to merge 1 commit into
yuzi-co wants to merge 1 commit into
Conversation
…Keys mock
DeviceModelInfo::model_ids was documented as "ordered to match transports
(USB, eQuad, BTLE, Bluetooth); slots for disabled transports stay 0".
Both halves of that are wrong.
Order. The PIDs are packed in ascending HID++ transport-bit order, and
DeviceTransport declares USB as the *high* bit: USB = 1 << 3, E_QUAD =
1 << 2, BTLE = 1 << 1, BLUETOOTH = 1 << 0. So the wire order is
Bluetooth, BTLE, eQuad, USB — the reverse of what was documented. The
documented order appears to have been copied from the DeviceTransports
struct field order, which lists usb first.
Packing. openlogi-hidpp's own doc for the same field is right: the PID
"will be appended into this array". Disabled transports are skipped, not
zero-filled, which is also why three slots suffice for four transports.
Confirmed on two devices with different transport pairs:
G502 LIGHTSPEED transports=usb+equad model_ids=[407f,c08d,0000]
c08d is the USB PID (it enumerates as 046d:c08d when cabled);
407f is the wireless PID (reported as wpid=407f). eQuad precedes USB.
MX Master transports=equad+btle model_ids=[b012,4041,0000]
b012 is the BLE PID (Windows enumerates it as BTHLEDEVICE ...PID&B012);
4041 is the eQuad PID. BTLE precedes eQuad.
Both are packed, ascending-bit, with a trailing zero.
The ambiguity has already produced contradictory fixtures in mock_agent:
MX Master 3S declares equad+btle as [0xb034, 0x4082, 0] (BTLE first,
correct) while MX Keys declares the identical transport set as
[0x408a, 0xb35b, 0] (eQuad first). Swap the MX Keys pair. No test asserts
on these values; channel_registry's tests independently treat 0xb35b as a
direct-attach PID, consistent with it being the BTLE entry.
No functional change: every consumer of model_ids formats or iterates all
three slots, none indexes by transport.
Greptile SummaryCorrects the documented HID++
Confidence Score: 5/5The PR appears safe to merge; the documentation and mock-data correction are consistent with the HID++ transport representation. The changed ordering matches the protocol’s ascending transport-bit packing, and the reviewed consumers provide no concrete path where correcting this mock fixture causes an observable failure.
|
| Filename | Overview |
|---|---|
| crates/openlogi-core/src/device.rs | The expanded documentation accurately describes the HID++ transport bits, packed PID ordering, skipped disabled transports, and three-entry limit. |
| crates/openlogi-agent/src/bin/mock_agent.rs | The MX Keys fixture now places its BTLE PID before its eQuad PID, consistently with its enabled transports and the documented wire ordering. |
Reviews (1): Last reviewed commit: "docs(core): correct the model_ids transp..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
DeviceModelInfo::model_ids(crates/openlogi-core/src/device.rs) was documented as:Both halves are wrong.
1. The order is reversed
DeviceTransportinopenlogi-hidppdeclares USB as the high bit:PIDs are packed in ascending bit order, so the wire order is Bluetooth, BTLE, eQuad, USB — the reverse of the doc.
The documented order looks like it was copied from the
DeviceTransportsstruct field order, which happens to listusbfirst. Understandable, but it does not match the wire.2. The array is packed, not positional
openlogi-hidpp's doc for the same field is already correct:Disabled transports are skipped, not zero-filled — which is also why three slots are enough for four transports. "Slots for disabled transports stay
0" would require four.Hardware confirmation
Two devices, two different transport pairs, same rule:
transportsmodel_idsusb+equad[407f, c08d, 0000]c08dis the USB PID — it enumerates as046d:c08dwhen cabled.407fis the wireless PID (wpid=407f). eQuad precedes USB.equad+btle[b012, 4041, 0000]b012is the BLE PID — Windows enumerates it asBTHLEDEVICE\…_PID&B012_….4041is the eQuad PID. BTLE precedes eQuad.Both packed from the front with a trailing zero. Under the old doc,
model_ids[0]would be "the USB PID" — on the G502 that reads407f, the wireless PID, and on the MX Master it reads a PID for a transport the device says it does not support (usb = false).The ambiguity already caused a bug
mock_agent.rscontains two fixtures with the identical transport setusb=false, equad=true, btle=true, bluetooth=falseand opposite orderings:This PR swaps the MX Keys pair to
[0xb35b, 0x408a, 0].No test asserts on these values. Independently,
channel_registry.rs's tests usedirect(0xb35b)— treating0xb35bas MX Keys' direct-attach PID, consistent with it being the BTLE entry.Scope
Documentation and mock data only — no functional change.
I grepped every consumer of
model_ids:openlogi-cli/src/cmd/list.rs:144andopenlogi-core/src/diagnostics.rs:362both format or iterate all three slots. Nothing indexes the array by transport, so nothing was reading the wrong PID at runtime.It still matters, because the doc is what the next implementer follows. In particular #667 proposes using
model_idsto correlate one physical device across transports — doing that against the documented order would pick the wrong PID.Local gate
Per AGENTS.md, Windows 11 / x86_64-pc-windows-msvc:
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspaceRUSTDOCFLAGS="-D warnings" cargo doc -p openlogi-hid …The rustdoc failure is the
AsyncHidChannel::supports_short_long_hidpplink error that reproduces on a cleanmasteron Windows and is fixed by #661; CI does not see it because the docs job runs on ubuntu.I also built docs for the crate this PR actually touches.
cargo doc -p openlogi-corereports 5 unresolved-link errors on this branch and the same 5 on cleanmaster(ButtonId,Action::category,Binding::fill_gesture_defaults, …) — all pre-existing, none added here, andopenlogi-coreis not part of the AGENTS.md doc gate. The new[DeviceTransports]link resolves cleanly.Related: #667.