Skip to content

Usb host support#527

Open
Shadowtrance wants to merge 7 commits into
TactilityProject:mainfrom
Shadowtrance:usb-host
Open

Usb host support#527
Shadowtrance wants to merge 7 commits into
TactilityProject:mainfrom
Shadowtrance:usb-host

Conversation

@Shadowtrance
Copy link
Copy Markdown
Contributor

@Shadowtrance Shadowtrance commented Jun 1, 2026

Only tested on panda touch and tab5 which works as expected with all 3 modes, HID (keyboard / mouse), MSC, Mouse.
Hubs also work with limitations (see my notes snippet below).

Good luck finding a USB 1.1 / Full-Speed hub to get around this issue.
Multiple usb flash drives connected to a hub work fine.
Things will vary wildly depending on hub and devices i guess.
My diy corne keyboard works via a hub for example but not my keychron Q1 V2 or even a cheap generic hp office keyboard and none of the mice i can find around the house work via a hub either. lol

Hub limitation: The ESP-IDF USB host stack does not implement Transaction Translator (TT) support.
This means Full-Speed (keyboards, mice, HID dongles) and Low-Speed devices connected through a USB 2.0 High-Speed hub will fail with "TT is not supported".
High-Speed devices such as USB flash drives work fine through a hub.
All HID devices must be connected directly to the host port until TT support is added upstream in ESP-IDF.
https://docs.espressif.com/projects/esp-usb/en/latest/esp32p4/usb_host.html#features-limitations
https://docs.espressif.com/projects/esp-usb/en/latest/esp32s3/usb_host.html#features-limitations

Summary by CodeRabbit

  • New Features
    • USB Host support enabled for Panda Touch and M5Stack Tab5 devices.
    • System-level USB host drivers added for HID (keyboard/mouse), MIDI, and Mass Storage.
    • HID input integrated into the UI with start/stop lifecycle and LVGL keyboard/mouse handling.
    • MIDI input exposed via a public API for apps.
    • Mass Storage auto-mount with an Eject action in Files.
    • Status bar gains a USB icon to reflect USB connectivity.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bcb908d1-00aa-45b6-8eb0-ea3490e1481f

📥 Commits

Reviewing files that changed from the base of the PR and between e402d54 and a305344.

📒 Files selected for processing (1)
  • Platforms/platform-esp32/source/drivers/usb/esp32_usbhost.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • Platforms/platform-esp32/source/drivers/usb/esp32_usbhost.cpp

📝 Walkthrough

Walkthrough

This PR adds ESP32 USB host support: devicetree bindings and device properties, platform build manifest and CMake wiring, a USB host controller driver and class drivers for HID, MIDI, and MSC, C ABI kernel wrappers, LVGL HID input integration and statusbar USB icon/font updates, file-manager eject action invoking the MSC eject API, GUI lifecycle start/stop for HID input, and sdkconfig generation when usbHostEnabled is set.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Usb host support' directly corresponds to the main objective: adding USB host support with HID, MIDI, and MSC class drivers across multiple device configurations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (1)
Tactility/Source/lvgl/UsbHidInput.cpp (1)

194-194: 💤 Low value

Move CURSOR_SIZE to file or function scope.

The constexpr is defined inside a switch case (line 194), which is unusual. Consider moving this constant to file scope alongside the other constants (lines 23-29) for consistency and clarity.

Suggested refactor

At the top with other constants:

constexpr uint32_t KEY_REPEAT_DELAY_MS = 500;
constexpr uint32_t KEY_REPEAT_RATE_MS  = 50;
constexpr int32_t CURSOR_SIZE          = 16;

Then use it without redeclaration:

         case USB_HID_EVENT_MOUSE_MOVE: {
             lv_display_t* disp = lv_display_get_default();
-            constexpr int32_t CURSOR_SIZE = 16;
             if (!disp) break;

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a71f1900-117a-4b8d-be7d-9e38cd788c9e

📥 Commits

Reviewing files that changed from the base of the PR and between a59fbf4 and 52aa2da.

📒 Files selected for processing (37)
  • Devices/btt-panda-touch/bigtreetech,panda-touch.dts
  • Devices/btt-panda-touch/device.properties
  • Devices/m5stack-tab5/device.properties
  • Devices/m5stack-tab5/m5stack,tab5.dts
  • Firmware/idf_component.yml
  • Modules/lvgl-module/assets/generate-all.py
  • Modules/lvgl-module/include/tactility/lvgl_icon_statusbar.h
  • Modules/lvgl-module/source-fonts/material_symbols_statusbar_12.c
  • Modules/lvgl-module/source-fonts/material_symbols_statusbar_16.c
  • Modules/lvgl-module/source-fonts/material_symbols_statusbar_20.c
  • Modules/lvgl-module/source-fonts/material_symbols_statusbar_30.c
  • Platforms/platform-esp32/CMakeLists.txt
  • Platforms/platform-esp32/bindings/espressif,esp32-usbhost-hid.yaml
  • Platforms/platform-esp32/bindings/espressif,esp32-usbhost-midi.yaml
  • Platforms/platform-esp32/bindings/espressif,esp32-usbhost-msc.yaml
  • Platforms/platform-esp32/bindings/espressif,esp32-usbhost.yaml
  • Platforms/platform-esp32/include/tactility/bindings/esp32_usbhost.h
  • Platforms/platform-esp32/include/tactility/drivers/esp32_usbhost.h
  • Platforms/platform-esp32/source/drivers/usb/esp32_usbhost.cpp
  • Platforms/platform-esp32/source/drivers/usb/esp32_usbhost_hid.cpp
  • Platforms/platform-esp32/source/drivers/usb/esp32_usbhost_midi.cpp
  • Platforms/platform-esp32/source/drivers/usb/esp32_usbhost_msc.cpp
  • Platforms/platform-esp32/source/module.cpp
  • Tactility/Include/Tactility/lvgl/UsbHidInput.h
  • Tactility/Private/Tactility/app/files/View.h
  • Tactility/Source/app/files/View.cpp
  • Tactility/Source/lvgl/UsbHidInput.cpp
  • Tactility/Source/service/gui/GuiService.cpp
  • Tactility/Source/service/statusbar/Statusbar.cpp
  • TactilityKernel/include/tactility/drivers/usb_host_hid.h
  • TactilityKernel/include/tactility/drivers/usb_host_midi.h
  • TactilityKernel/include/tactility/drivers/usb_host_msc.h
  • TactilityKernel/source/drivers/usb_host_hid.cpp
  • TactilityKernel/source/drivers/usb_host_midi.cpp
  • TactilityKernel/source/drivers/usb_host_msc.cpp
  • TactilityKernel/source/kernel_symbols.c
  • device.py

Comment thread Platforms/platform-esp32/source/drivers/usb/esp32_usbhost_hid.cpp
Comment thread Platforms/platform-esp32/source/drivers/usb/esp32_usbhost_midi.cpp
Comment thread Platforms/platform-esp32/source/drivers/usb/esp32_usbhost_msc.cpp Outdated
Comment thread Tactility/Source/lvgl/UsbHidInput.cpp
Comment thread Tactility/Source/lvgl/UsbHidInput.cpp
Comment thread TactilityKernel/source/drivers/usb_host_midi.cpp
Comment thread TactilityKernel/source/drivers/usb_host_msc.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant