Repository navigation
Conversation
- GamepadMapService (dispatcher module 11, protocol espp.gamepad_map v1, wire spec + host-buildable codec in include/detail/gamepad_map_protocol.hpp): GET_INFO (limits, connected controller, whether it has a profile), GET_MAP / SET_MAP (default map or a per-controller profile; validated, saved through GamepadProfiles), ERASE_PROFILE, LIST_PROFILES, RESET_ALL, and SET_STREAM: INPUT events (raw + mapped state) every period, ended by the device when the host stops renewing the lease, plus an unsolicited INFO when the controller changes while streaming. MAP says whether the requested profile exists. Host decoders ignore appended fields of device -> host messages, so the protocol can grow. - Application side: set_controller() / clear_controller() (returns the map to apply), publish_input() (an atomic load while nobody streams), Config::on_active_map_changed when a host changes the connected controller's map. - GamepadMapRule::valid() also rejects a negative threshold on a trigger and KEEP_SOURCE with no target (rules that could never do anything). - web/gamepad_map_console.html: live raw / mapped input (button grid, stick pads, axis bars), map picker (default / connected controller / stored profiles / new), rule editor with per-kind parameters, learn by pressing, presets, dead zones, local validation, save / revert / erase / reset with inline confirms; shared discovery / connection / navigation / hand-back blocks byte-identical to the other consoles. - webapp_example (esp32s3 / esp32p4, USB vendor + CDC, the standard system / monitor / OTA / core dump services, profiles on LittleFS, a demo controller with the BOOT button as South). - Tests: gamepad_map_protocol_host_test.cpp (golden encodings), the web codec test (node), both in gamepad_map_tests.yml; the console is in the dispatcher web tests' console list; apps_registry_test's undeclared- protocol check now matches protocol ids with '_'. - Docs: module 11 in the dispatcher module tables (and the missing module 10 row in the README), web_apps.rst, gamepad_map.rst + example page, Doxyfile; CI build entry for the example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
# Conflicts: # .github/workflows/gamepad_map_tests.yml
- set_controller() / clear_controller() never send: a controller change flags an INFO that the stream task sends, so they are safe on a radio / host task (they used to do blocking transport I/O on the caller). - publish_input() always keeps the latest state (a 32-byte copy under a lock), and a controller change resets it, so a stream that starts later or a new controller never shows stale input. - INPUT's changed flag is only forced when the stream (re)starts, not on every lease renewal; INFO is also sent when a stream starts. - The lease expiry is decided under the service mutex (where renewals take it), so a renewal is never undone; an expired stream ends its task (no idle wake-ups for the rest of the uptime) and the next SET_STREAM starts a new one; the period is clamped to Config::max_stream_period (1 s). - GET_INFO / LIST_PROFILES / RESET_ALL reject a payload (a newer protocol's request is never acted on as a v1 one). - Changes and the notifications they cause are serialized on the store's new GamepadProfiles::change_mutex(), so services sharing a store notify in order and the last notification carries the stored map. - INFO uses GamepadProfiles::profile_count() / has_profile() (no copies). - Example: one TX mutex per transport, and a frame that does not fit the TX FIFO is dropped instead of blocking the sender; the demo input stays below the console's 50% learn threshold so learn picks the BOOT button; BOOT is GPIO 35 on the ESP32-P4; README snippet takes the map mutex. - Protocol: Reader::ok() (unused) removed; doc updates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
This branch has not been deployed
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.
Description
Stacked on #918 (base
feat/gamepad-map). Retarget it tomainonce #918 merges.This adds a device-side service and a hosted web console, so a user can edit gamepad maps in the browser and watch a controller's input before and after mapping, live.
espp::GamepadMapServiceIt uses dispatcher module 11 and protocol
espp.gamepad_mapv1. The wire spec and a host-buildable codec are ininclude/detail/gamepad_map_protocol.hpp.Requests and what they do:
GET_INFOGET_MAPSET_MAPGamepadMap::valid(), then saves it throughGamepadProfilesERASE_PROFILE/RESET_ALLLIST_PROFILESSET_STREAMProtocol behaviour:
Config::stream_lease), so a closed tab does not leave it streaming.Application side:
set_controller()/clear_controller().set_controller()returns the map to apply.publish_input(raw, mapped)is a single atomic load while nobody is streaming.Config::on_active_map_changedfires when a host's change gives the connected controller a new map.GamepadMapRule::valid()also now rejects two rules that could never do anything: a negative threshold on a trigger, andKEEP_SOURCEwith no target.web/gamepad_map_console.htmlvalid(). Save, revert, erase and reset use inline confirms (no blocking dialogs).webapp_exampleTests, docs, CI
gamepad_map_protocol_host_test.cppchecks golden encodings and decoding leniency.web/test/gamepad_map_codec_test.js(node) tests the console's copy of the codec, the validation, the presets and the learn logic.gamepad_map_tests.yml.apps_registry_test's undeclared-protocol check now also matches protocol ids containing_(it silently skipped them before).web_apps.rstgamepad_map.rstand an example pageIDF_COMPONENT_MANAGER=0).Motivation and Context
Users need to configure per-controller button / axis mapping from a web page, both on the BLE -> USB controller bridge and in emulators. This is the reusable service and console that any espp USB / serial device can register.
How has this been tested?
-std=c++23 -Wall -Wextra -Werror:gamepad_map_protocol_host_testgamepad_map_host_test(with the new validation rules)gamepad_map_codec_test.jsresolve_module_id_test.js(11 consoles)apps_registry_test.js(19 apps)webapp_examplebuilds for esp32s3 withIDF_COMPONENT_MANAGER=0and no warnings.cppcheckwith the CI flags is clean on the component.?autoconnect=1. A scripted fake device exercised it as well: connect, load / save / erase / reset, presets, validation, learn, lease renewal and an unsolicited INFO.Types of changes
Checklist:
.github/workflows/build.ymlfile to add my new test to the automated cloud build github action.🤖 Generated with Claude Code
https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU