Repository navigation
feat(hid-rp): a HID Descriptor Inspector web app, on the firmware's own parser - #965
Merged
Merged
Conversation
finger563
force-pushed
the
feat/hid-descriptor-inspector
branch
from
December 2, 2026 02:01
c18f701 to
48419f8
Compare
…wn parser Paste a USB / BLE HID report descriptor and see it the way espp's firmware reads it: every item (named, with usage page / usage names, collections nested), the Input and Output fields hid-rp's ReportMap maps (report ID, bit offset and size, usage, logical range), the report sizes, what the decoders take it for (gamepad and its button layout, keyboard, mouse), and an input report decoded into the GamepadState a remapper sees - typed in, or live from a HID device over WebHID (the descriptor is pasted: browsers do not expose it). Presets: hid-rp's generated Xbox / DualSense BLE / SpaceMouse descriptors and a real controller's (ShanWan BM-769 over BLE, with a report). - inspector/hid_inspector.hpp: parse_json() / decode_json() / presets_json() over ReportMap, GamepadDecoder, KeyboardDecoder, MouseDecoder and gamepad_map's to_gamepad_state(); the item walk reports where a descriptor is cut. hid_inspector_wasm.cpp + build_wasm.sh (Emscripten 4.0.10, -fno-exceptions like the firmware): web/hid_inspector.js, 84 KB, gitignored; the docs build publishes it. - web/hid_descriptor_inspector.html: renders the JSON; says how to build the module when it is missing. - tests: test/hid_inspector_host_test.cpp (C++), web/test/hid_inspector_ui_test.js (the page in headless Chrome); CI's WebAssembly job builds the module and requires the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
…erence) g++ flags binding a reference to what a call taking a temporary returns, though preset() returns into a static; take a copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
finger563
force-pushed
the
feat/hid-descriptor-inspector
branch
from
December 2, 2026 03:18
44f0098 to
e0995c2
Compare
finger563
marked this pull request as ready for review
December 2, 2026 03:18
|
✅Static analysis result - no issues found! ✅ |
Contributor
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
4 open issues
Uint8Array.of(e.reportId, ...data)spreads the report into JS arguments and allocates/copies on… · New If module initialization rejects (e.g., wasm compilation failure, bad/missing JS glue, CSP… · Newhid_rp::ReportMap::well_formed(descriptor)is computed twice (once for the JSON field and once… · NewFAIL(...)does not necessarily abort the test immediately, so the function continues and returns… · New
What changed in this PR
Adds a new “HID Descriptor Inspector” web app that runs hid-rp’s on-device descriptor parsing + decoding logic in the browser via WebAssembly, plus CI and documentation updates to build and validate it.
Changes:
- Add C++ inspector API (
parse_json,decode_json, presets) and WebAssembly entrypoints + build script. - Add the web UI page and headless-Chrome UI test coverage.
- Wire module build + UI test into CI/docs, and document the new app.
| File | Description |
|---|---|
| doc/en/web_apps.rst | Document the new HID Descriptor Inspector web app in the web apps list. |
| components/hid-rp/web/test/hid_inspector_ui_test.js | Add headless Chrome UI test for the inspector page + wasm module. |
| components/hid-rp/web/hid_descriptor_inspector.html | Add the inspector UI (descriptor parsing, field display, decoding, WebHID live mode). |
| components/hid-rp/test/hid_inspector_host_test.cpp | Add host-side doctest coverage for inspector JSON outputs and presets. |
| components/hid-rp/test/CMakeLists.txt | Register the new inspector host test and include inspector headers. |
| components/hid-rp/inspector/hid_inspector_wasm.cpp | Add wasm C ABI exports bridging to the inspector JSON functions. |
| components/hid-rp/inspector/hid_inspector.hpp | Implement JSON writer + inspector parse/decode/presets logic in C++. |
| components/hid-rp/inspector/build_wasm.sh | Add a pinned Emscripten build script producing web/hid_inspector.js. |
| components/hid-rp/README.md | Document the inspector app, its purpose, and how to build/test it. |
| components/dispatcher/web/test/shared_blocks_test.js | Update expected shared-block splice counts for app navigation. |
| .gitignore | Ignore generated components/hid-rp/web/hid_inspector.js. |
| .github/workflows/host_tests.yml | Build the inspector wasm module and run the inspector UI test in CI. |
| .github/workflows/build_and_publish_docs.yml | Build the inspector wasm module as part of docs publishing. |
Review effort: Lite
- a module that fails to load shows the notice with the reason and disables Inspect / Decode / live (it looked like a hang); - live reports with an ID are built without argument spreading; - parse_json() computes well_formed() once; - the host test's preset() uses std::find_if (cppcheck) and REQUIRE, and never dereferences an empty list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
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.


Summary
This adds a new web app, the HID Descriptor Inspector. You paste a USB or BLE HID report descriptor and see it the way espp's firmware reads it. The parsing is hid-rp's own C++, the code the firmware runs on a device's descriptor, compiled to WebAssembly. hid-rp can't be exposed to Python, and the browser's WebHID API doesn't hand a page the raw descriptor bytes, so this is parsing a web page couldn't otherwise do.
It's part of step 4d of the testing plan (previews of on-device code in the browser), and it's the "HID descriptor inspector" tool the plan names.
What it shows
Data, Var, Abs. A cut-off descriptor is listed up to where it's cut, with the reason.ReportMapmaps, inputs and outputs: report ID, bit offset and size, usage, logical range, array or variable.GamepadStatea remapper (gamepad_map) sees:What's in it
inspector/hid_inspector.hpp:parse_json(),decode_json()andpresets_json();ReportMap,GamepadDecoder,KeyboardDecoder,MouseDecoderand gamepad_map'sto_gamepad_state().inspector/hid_inspector_wasm.cppandbuild_wasm.sh:-fno-exceptionslike the firmware;web/hid_inspector.js, 84 KB and gitignored; the docs build publishes it beside the page.web/hid_descriptor_inspector.html: the page. Without the module, it explains how to build it or links the published copy.Tests
test/hid_inspector_host_test.cpp(C++):web/test/hid_inspector_ui_test.js(headless Chrome): the presets, the real controller (classification, 60 items, 24 fields, its report decoded, R2 when combined), item naming, hex with commas /0x/ comments, a truncated descriptor refused with where it's cut, and bad hex.decode_jsonfails the UI test.Worth knowing
The inspector shows what the decoders conclude, not what a device is:
🤖 Generated with Claude Code
https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU