Repository navigation
Conversation
…witchProHost / XboxHost) A Switch Pro controller reports nothing useful until a host runs its handshake, and Xbox controllers are not HID devices at all, so neither worked on the USB-A port. espp 1.5.0 has the host side of both (esp-cpp/espp#966). - usb_hid.cpp: a Switch Pro controller (057E:2009) gets an espp::SwitchProHost instead of the HID decoder: its OUTPUT reports go out with UsbHost::HidDevice::send_output_report(), a 20 ms timer runs only while one is mid-handshake, and its player lights show. An espp::XboxHost beside the HID driver takes wired Xbox 360 / X-input mode controllers and Xbox One / Series (GIP). Both feed the same gamepad path as the HID pads (positions, sticks past 40% as the d-pad, capture / home or select+start for the pause menu). - The USB host's tasks (and XboxHost's) at priority 21, above the games' main and video tasks (20), like the BSP's touch task: at 5, a busy core (Jedi Knight) starved the dispatch task, a controller that reports at a fixed rate (the Switch Pro) overflowed its queue, and its input stopped. - include/gamepad_state.hpp -> emu_gamepad_state.hpp: the name clashed with gamepad_map's gamepad_state.hpp, which the new components bring. - idf_component.yml: espp/switch_pro and espp/xbox_host >= 1.5.0, and espp/usb_device >= 1.5.0 (its xinput.hpp moved to espp/xinput; an older usb_device brings a second, clashing copy). - README: the controllers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
There was a problem hiding this comment.
🟡 Changes recommended
Critical timer lifecycle races can stall Switch Pro handshakes or cause null/dangling-pointer access during concurrent connections and teardown.
3 open issues
What changed in this PR
Adds Switch Pro and wired Xbox support on the USB-A port, feeding both into the existing gamepad input path.
Changes:
- Adds controller-specific hosts, Switch Pro handshake timing, and higher USB task priorities.
- Updates espp dependencies and renames the emulator’s gamepad header to avoid a collision.
- Documents supported controllers and controls.
| File | Description |
|---|---|
| README.md | Documents Switch Pro and wired Xbox support. |
| components/tab5-emu/src/usb_hid.cpp | Integrates controller hosts, input mapping, and lifecycle handling. |
| components/tab5-emu/include/touch_controls.hpp | Uses the renamed gamepad header. |
| components/tab5-emu/include/tab5-emu.hpp | Uses the renamed gamepad header. |
| components/tab5-emu/include/emu_gamepad_state.hpp | Provides emulator input types under a collision-free filename. |
| components/tab5-emu/idf_component.yml | Adds host dependencies and requires compatible USB-device support. |
| components/tab5-emu/CMakeLists.txt | Registers the new controller components. |
Review effort: Balanced
| p->update(); | ||
| handshaking |= !p->running(); | ||
| } | ||
| return !handshaking; |
| } | ||
| // runs only while a Switch Pro controller is mid-handshake (started when one | ||
| // connects, stops itself once every one is running) | ||
| hid->switch_pro_ticker = std::make_unique<espp::Timer>(espp::Timer::AdvancedConfig{ |
| } | ||
| logger_.info("stopping the USB host"); | ||
| std::error_code ec; | ||
| hid->switch_pro_ticker.reset(); |
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.

Summary
Switch Pro controllers and wired Xbox controllers now work on the USB-A port, using espp 1.5.0's new host components (esp-cpp/espp#966):
espp::SwitchProHostfromswitch_pro. Until a host runs its handshake, a Switch Pro controller reports nothing useful.espp::XboxHostfromxbox_host. Xbox controllers are not HID devices at all.Changes
Switch Pro (
057E:2009), inusb_hid.cpp:espp::SwitchProHostinstead of the HID decoder.UsbHost::HidDevice::send_output_report().Xbox:
espp::XboxHostruns beside the HID driver as a second USB Host Library client. It handles:Same mapping as the HID pads: both feed the existing gamepad path:
USB task priority: the USB host's tasks, and XboxHost's, now run at priority 21. That is above the games' main and video tasks (20), like the BSP's touch task.
Header rename:
include/gamepad_state.hppis nowemu_gamepad_state.hpp. The old name clashed withgamepad_map'sgamepad_state.hpp, which the new components bring in.idf_component.yml:espp/switch_proandespp/xbox_host>=1.5.0.espp/usb_device>=1.5.0: itsxinput.hppmoved toespp/xinput, so an olderusb_devicebrings a second, clashing copy. The component manager pickedusb_device1.4.9 right after the release, and the build failed.README: documents the new controllers.
Testing
On the Tab5, built against the registry's espp 1.5.0:
ota_0from Partitions: ota_0 14 MB, ota_1 1 MB, so every core and the TPM engine fit #53.Earlier, the same code against a local espp checkout:
057E:2009with a full-range factory calibration)SwitchProHost045e:028e)XboxHostNot tested on hardware: a genuine Xbox One / Series (GIP) pad. The GIP wire format is covered by espp's host tests.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY