Skip to content

USB device-mode support - #613

Merged
KenVanHoeylandt merged 11 commits into
TactilityProject:mainfrom
Shadowtrance:usb-device
Aug 12, 2026
Merged

USB device-mode support#613
KenVanHoeylandt merged 11 commits into
TactilityProject:mainfrom
Shadowtrance:usb-device

Conversation

@Shadowtrance

@Shadowtrance Shadowtrance commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Adds the ability for Tactility to present itself as a USB device to a host: mass storage (MSC), HID keyboard/mouse/gamepad, MIDI, and an optional CDC-ACM serial console.

USB device-mode stack

  • New usb_device_controller kernel driver: owns the single TinyUSB device-mode slot. Exactly
    one of MSC/HID/MIDI ("primary classes") may be active at a time.
  • New usb_hid_device, usb_msc_device, usb_midi_device, usb_cdc_device kernel driver APIs, each a child
    devicetree node under a board's usbdevice0.
    • HID supports keyboard, mouse, keyboard+mouse, and gamepad report modes, switchable at
      runtime. Shares report descriptor bytes with the existing BLE HID implementation.
    • MSC exposes SD/internal flash storage as USB mass storage (used by the "reboot into MSC
      mode" boot flow).
    • MIDI is a send-only USB-MIDI class device.
    • CDC-ACM console, a board-toggleable USB serial console (mirrors log output) that composites into whichever of HID or MIDI is active, or stands alone.
      MSC is deliberately excluded - an MSC device should look like plain mass storage, nothing extra.
      Required generalizing descriptor building into a small composite-descriptor assembler in the controller.
      (primary classes request interface/endpoint numbers, build their own bytes, the controller assembles and installs the final descriptor).

Multi-touch input (lvgl-module)

  • Pointer driver now supports up to 5 simultaneous touch points per panel (pooled LVGL indevs,
    one shared bus read per polling round).
    • New lvgl_pointer_get_slot_index() lets apps track independent per-finger state.

Toolbar dropdown widget

  • Added lvgl_toolbar_add_dropdown_action() so a dropdown can live correctly inside a toolbar's managed layout instead of being manually positioned.

Devices updated

  • All existing boards with hardware.tinyUsb=true have been updated with hardware.tinyUsbMsc=true and had their .dts updated for the new usbdevice0/usbdevicemsc0 node shape.
  • m5stack-tab5 additionally has usbdevicehid0, usbdevicemidi0, and usbdevicecdc0 enabled.

Summary by CodeRabbit

  • New Features
    • Added USB device-mode support for mass storage, HID keyboards/mice/gamepads, MIDI, and CDC serial connections across supported ESP32 boards.
    • Enabled multi-touch input with up to five simultaneous touch points.
    • Added toolbar dropdown actions with configurable options, width, and display text.
    • Improved keyboard support with HID keycode and modifier reporting.
  • Bug Fixes
    • Corrected USB mass-storage configuration and improved storage mount/eject handling.
    • Fixed function-key mapping for the M5Stack Tab5 keyboard.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

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 Plus

Run ID: ed3df255-fd49-4f4d-afd7-f4953f017dc8

📥 Commits

Reviewing files that changed from the base of the PR and between 5224b82 and ff3436c.

📒 Files selected for processing (7)
  • Modules/lvgl-module/include/lvgl/devices/pointer.h
  • Modules/lvgl-module/source/devices/pointer.cpp
  • Platforms/platform-esp32/source/drivers/usb/esp32_usb_cdc_device.cpp
  • Platforms/platform-esp32/source/drivers/usb/esp32_usb_device_msc.cpp
  • Platforms/platform-esp32/source/drivers/usb/esp32_usb_hid_device.cpp
  • TactilityKernel/include/tactility/drivers/usb_device_controller.h
  • TactilityKernel/include/tactility/drivers/usb_hid_device.h
🚧 Files skipped from review as they are similar to previous changes (7)
  • Platforms/platform-esp32/source/drivers/usb/esp32_usb_device_msc.cpp
  • Platforms/platform-esp32/source/drivers/usb/esp32_usb_cdc_device.cpp
  • TactilityKernel/include/tactility/drivers/usb_device_controller.h
  • Modules/lvgl-module/include/lvgl/devices/pointer.h
  • TactilityKernel/include/tactility/drivers/usb_hid_device.h
  • Platforms/platform-esp32/source/drivers/usb/esp32_usb_hid_device.cpp
  • Modules/lvgl-module/source/devices/pointer.cpp

📝 Walkthrough

Walkthrough

The pull request adds ESP32 TinyUSB controller, HID, MSC, MIDI, and CDC device support. It introduces public kernel APIs, device-tree bindings, platform drivers, and board configurations. It replaces the legacy USB property with separate class properties. It migrates MSC handling to the shared device API. It adds pooled multi-touch support to LVGL and propagates HID key metadata from the Tab5 keyboard.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.24% 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 clearly summarizes the pull request's primary change: adding USB device-mode support.
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.
✨ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 10

🧹 Nitpick comments (1)
Modules/lvgl-module/include/lvgl/devices/pointer.h (1)

16-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Clarify the LVGL multi-touch rationale.

The vendored LVGL is 9.4. lv_indev_data_t still carries one point per read, so the pool remains appropriate for independent per-finger widget interaction. LVGL 9.4 also provides the optional lv_indev_touch_data_t and lv_indev_gesture_recognizers_update() path for multi-touch gestures. State this distinction in the comment. The project currently disables gesture recognition.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bddda1bc-b821-4333-8c11-fbb16fba0899

📥 Commits

Reviewing files that changed from the base of the PR and between 37c5075 and 5224b82.

📒 Files selected for processing (94)
  • Devices/elecrow-crowpanel-advance-28/device.properties
  • Devices/elecrow-crowpanel-advance-28/elecrow,crowpanel-advance-28.dts
  • Devices/elecrow-crowpanel-advance-35/device.properties
  • Devices/elecrow-crowpanel-advance-35/elecrow,crowpanel-advance-35.dts
  • Devices/elecrow-crowpanel-advance-50/device.properties
  • Devices/elecrow-crowpanel-advance-50/elecrow,crowpanel-advance-50.dts
  • Devices/elecrow-crowpanel-basic-50/device.properties
  • Devices/elecrow-crowpanel-basic-50/elecrow,crowpanel-basic-50.dts
  • Devices/es3c28p/device.properties
  • Devices/es3c28p/es3c28p.dts
  • Devices/heltec-wifi-lora-32-v3/device.properties
  • Devices/heltec-wifi-lora-32-v3/heltec,wifi-lora-32-v3.dts
  • Devices/lilygo-tdeck-max/device.properties
  • Devices/lilygo-tdeck-max/lilygo,tdeck-max.dts
  • Devices/lilygo-tdeck-plus/device.properties
  • Devices/lilygo-tdeck-plus/lilygo,tdeck-plus.dts
  • Devices/lilygo-tdeck-pro/device.properties
  • Devices/lilygo-tdeck-pro/lilygo,tdeck-pro.dts
  • Devices/lilygo-tdeck/device.properties
  • Devices/lilygo-tdeck/lilygo,tdeck.dts
  • Devices/lilygo-tdisplay-s3/device.properties
  • Devices/lilygo-tdisplay-s3/lilygo,tdisplay-s3.dts
  • Devices/lilygo-tdongle-s3/device.properties
  • Devices/lilygo-tdongle-s3/lilygo,tdongle-s3.dts
  • Devices/lilygo-thmi/device.properties
  • Devices/lilygo-thmi/lilygo,thmi.dts
  • Devices/lilygo-tlora-pager/device.properties
  • Devices/lilygo-tlora-pager/lilygo,tlora-pager.dts
  • Devices/m5stack-cardputer-adv/device.properties
  • Devices/m5stack-cardputer-adv/m5stack,cardputer-adv.dts
  • Devices/m5stack-cardputer/device.properties
  • Devices/m5stack-cardputer/m5stack,cardputer.dts
  • Devices/m5stack-cores3/device.properties
  • Devices/m5stack-cores3/m5stack,cores3.dts
  • Devices/m5stack-papers3/device.properties
  • Devices/m5stack-papers3/m5stack,papers3.dts
  • Devices/m5stack-stackchan/device.properties
  • Devices/m5stack-stackchan/m5stack,stackchan.dts
  • Devices/m5stack-sticks3/device.properties
  • Devices/m5stack-sticks3/m5stack,sticks3.dts
  • Devices/m5stack-tab5/Source/devices/tab5_keyboard.cpp
  • Devices/m5stack-tab5/device.properties
  • Devices/m5stack-tab5/m5stack,tab5.dts
  • Devices/waveshare-esp32-s3-geek/device.properties
  • Devices/waveshare-esp32-s3-geek/waveshare,esp32-s3-geek.dts
  • Devices/waveshare-s3-lcd-13/device.properties
  • Devices/waveshare-s3-lcd-13/waveshare,s3-lcd-13.dts
  • Devices/waveshare-s3-touch-lcd-128/device.properties
  • Devices/waveshare-s3-touch-lcd-128/waveshare,s3-touch-lcd-128.dts
  • Devices/waveshare-s3-touch-lcd-147/device.properties
  • Devices/waveshare-s3-touch-lcd-147/waveshare,s3-touch-lcd-147.dts
  • Devices/waveshare-s3-touch-lcd-43/device.properties
  • Devices/waveshare-s3-touch-lcd-43/waveshare,s3-touch-lcd-43.dts
  • Devices/wireless-tag-wt32-sc01-plus/device.properties
  • Devices/wireless-tag-wt32-sc01-plus/wireless-tag,wt32-sc01-plus.dts
  • Modules/lvgl-module/include/lvgl/devices/pointer.h
  • Modules/lvgl-module/include/lvgl/widgets/toolbar.h
  • Modules/lvgl-module/source/devices/devices.cpp
  • Modules/lvgl-module/source/devices/pointer.cpp
  • Modules/lvgl-module/source/symbols.c
  • Modules/lvgl-module/source/widgets/toolbar.cpp
  • Platforms/platform-esp32/CMakeLists.txt
  • Platforms/platform-esp32/bindings/espressif,esp32-usbdevice-cdc.yaml
  • Platforms/platform-esp32/bindings/espressif,esp32-usbdevice-hid.yaml
  • Platforms/platform-esp32/bindings/espressif,esp32-usbdevice-midi.yaml
  • Platforms/platform-esp32/bindings/espressif,esp32-usbdevice-msc.yaml
  • Platforms/platform-esp32/bindings/espressif,esp32-usbdevice.yaml
  • Platforms/platform-esp32/include/tactility/bindings/esp32_usbdevice.h
  • Platforms/platform-esp32/include/tactility/drivers/esp32_usbdevice.h
  • Platforms/platform-esp32/include/tactility/drivers/hid_report_descriptors.h
  • Platforms/platform-esp32/source/drivers/bluetooth/esp32_ble_hid.cpp
  • Platforms/platform-esp32/source/drivers/hid_report_descriptors.cpp
  • Platforms/platform-esp32/source/drivers/usb/esp32_usb_cdc_device.cpp
  • Platforms/platform-esp32/source/drivers/usb/esp32_usb_device_controller.cpp
  • Platforms/platform-esp32/source/drivers/usb/esp32_usb_device_msc.cpp
  • Platforms/platform-esp32/source/drivers/usb/esp32_usb_hid_device.cpp
  • Platforms/platform-esp32/source/drivers/usb/esp32_usb_midi_device.cpp
  • Platforms/platform-esp32/source/module.cpp
  • Tactility/Source/hal/usb/UsbTusb.cpp
  • TactilityKernel/include/tactility/drivers/bluetooth_hid_device.h
  • TactilityKernel/include/tactility/drivers/keyboard.h
  • TactilityKernel/include/tactility/drivers/usb_cdc_device.h
  • TactilityKernel/include/tactility/drivers/usb_device_controller.h
  • TactilityKernel/include/tactility/drivers/usb_hid_device.h
  • TactilityKernel/include/tactility/drivers/usb_midi_device.h
  • TactilityKernel/include/tactility/drivers/usb_msc_device.h
  • TactilityKernel/source/drivers/keyboard.cpp
  • TactilityKernel/source/drivers/usb_cdc_device.cpp
  • TactilityKernel/source/drivers/usb_device_controller.cpp
  • TactilityKernel/source/drivers/usb_hid_device.cpp
  • TactilityKernel/source/drivers/usb_midi_device.cpp
  • TactilityKernel/source/drivers/usb_msc_device.cpp
  • TactilityKernel/source/symbols.c
  • device.py

Comment thread Devices/m5stack-tab5/m5stack,tab5.dts
Comment thread Devices/waveshare-s3-touch-lcd-128/device.properties
Comment thread Modules/lvgl-module/source/devices/pointer.cpp Outdated
Comment thread Modules/lvgl-module/source/devices/pointer.cpp
Comment thread Platforms/platform-esp32/CMakeLists.txt
Comment thread Platforms/platform-esp32/source/drivers/usb/esp32_usb_hid_device.cpp Outdated
Comment thread TactilityKernel/include/tactility/drivers/usb_device_controller.h
Comment thread TactilityKernel/include/tactility/drivers/usb_hid_device.h Outdated
Comment thread Platforms/platform-esp32/source/module.cpp
@KenVanHoeylandt

Copy link
Copy Markdown
Contributor

Great stuff once again! Thank you!

@KenVanHoeylandt
KenVanHoeylandt merged commit cc8be3f into TactilityProject:main Aug 12, 2026
63 checks passed
@Shadowtrance
Shadowtrance deleted the usb-device branch August 13, 2026 01:27
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.

2 participants