esp32S2 USB HID host example.

Simple usb host HID example

Since usb host support is still beta stage and include file is in private_include i copied component to this example. Code has been refactored to use events in client code.

Example logs:

Before connecting device

Hello world USB host!
start pipe event task
I (332) : USB host setup properly
I (332) : Port is power ON now
I (342) : port event: 1
start pipe event task

After connecting device

I (592) : HCD_PORT_EVENT_CONNECTION
I (592) : HCD_PORT_STATE_DISABLED
I (652) : USB device reset
I (652) : HCD_PORT_STATE_ENABLED
I (652) : Creating default pipe
...
I (689) STRING CB: [4] 
strings: 
I (693) STRING CB: [4] 
strings: 
I (697) STRING CB: [46] . USB OPTICAL MOUSE
strings:  USB OPTICAL MOUSE
I (705) ADDRESS: 1
I (708) SET CONFIG: 1

Example reading device descriptors and strings

  • device descriptor on EP0
Device descriptor:
Length: 18
Descriptor type: 1
USB version: 1.10
Device class: 0x00 (>ifc)
Device subclass: 0x00
Device protocol: 0x00
EP0 max packet size: 8
VID: 0x0000
PID: 0x6800
Revision number: 1.00
Manufacturer id: 0
Product id: 1
Serial id: 0
Configurations num: 1
  • configuration descriptor
Config:
Number of Interfaces: 1
Attributes: 0xa0
Max power: 100 mA

Interface:
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 0x03 (HID)
bInterfaceSubClass: 0x01
bInterfaceProtocol: 0x02
I (750) : HID descriptor
I (753) Report map size: 0x42

Endpoint:
bEndpointAddress: 0x81
bmAttributes: 0x03
bDescriptorType: 5
wMaxPacketSize: 6
bInterval: 10 ms

Mouse reports

Mouse reports may vary, depending on connected device. My mouse is sending 6 bytes report. 1st byte is always report ID, then depending on HID report map we can have 1 byte for buttons, 2 x 12 bits (in my case) for X and Y axes delta and 1 byte for wheel delta:

I (3256) HID REPORT ID: 1
I (3256) Mouse buttons: 0
I (3257) X/Y axes: 45/112/254 (3 bytes)
I (3257) Mouse wheel: 0

I (3264) HID REPORT ID: 1
I (3264) Mouse buttons: 0
I (3265) X/Y axes: 63/160/253
I (3269) Mouse wheel: 0

I (3280) HID REPORT ID: 1
I (3280) Mouse buttons: 0
I (3281) X/Y axes: 81/112/252
I (3283) Mouse wheel: 0

I (3288) HID REPORT ID: 1
I (3289) Mouse buttons: 0
I (3292) X/Y axes: 3/240/255
I (3296) Mouse wheel: 0

Have a nice play.

Similar Resources

Ramp is a HID attack program that steals all connected WiFi passwords within 13 seconds.

Ramp is a HID attack program that steals all connected WiFi passwords within 13 seconds.

Ramp Ramp is a HID attack program that steals all connected WiFi passwords within 13 seconds. Tested Windows 10 Warning Ramp has been created for the

Aug 23, 2022

An USB Rubberducky example for ESP32-S2 module with SD Card 🦆

An USB Rubberducky example for ESP32-S2 module with SD Card 🦆

ESP32-S2 WUD-Ducky This project is an attempt to add USB HID to the default example provided with @AprilBrother's WUD (*), however it also supports an

Sep 25, 2022

Example-application - Example out-of-tree application that is also a module

Zephyr Example Application This repository contains a Zephyr example application. The main purpose of this repository is to serve as a reference on ho

Sep 14, 2022

PoC for CVE-2021-28476 a guest-to-host "Hyper-V Remote Code Execution Vulnerability" in vmswitch.sys.

PoC for CVE-2021-28476 a guest-to-host

CVE-2021-28476: a guest-to-host "Microsoft Hyper-V Remote Code Execution Vulnerability" in vmswitch.sys. This is a proof of concept for CVE-2021-28476

Sep 15, 2022

ESP32 S2 C++ host library compatible with arduino, esp-idf.

Info I would like to announce USB host library for esp32 S2 compatible with arduino, esp-idf and PIO (when pio will be updated to most recent esp-idf)

Jun 2, 2022

Phage-Host Interaction Search Tool

Phage-Host Interaction Search Tool

PHIST Phage-Host Interaction Search Tool A tool to predict prokaryotic hosts for phage (meta)genomic sequences. PHIST links viruses to hosts based on

Aug 19, 2022

mini-plugin host as plugin

mini-plugin host as plugin

DISTRHO Ildaeil DISTRHO Ildaeil is mini-plugin host working as a plugin, allowing one-to-one plugin format reusage. Load a VST2 plugin inside a LV2 ho

Sep 19, 2022

Header-only VMWare Backdoor API Implementation & Effortless VMX Patcher for Custom Guest-to-Host RPCs

 Header-only VMWare Backdoor API Implementation & Effortless VMX Patcher for Custom Guest-to-Host RPCs

VmxHijack Header-only VMWare Backdoor API Implementation & Effortless VMX Patcher for Custom Guest-to-Host RPCs Sample // --- RPC Server Code (VmxHija

Sep 9, 2022

Parsec Soda is a custom open-source game streaming app that integrates with Parsec API and is focused in Host experience.

Parsec Soda is a custom open-source game streaming app that integrates with Parsec API and is focused in Host experience.

Parsec Soda is a custom open-source game streaming app that integrates with Parsec API and is focused in Host experience.

Sep 28, 2022
ESP8266 software USB host through general IO pins. We can connect up to 2 USB-LS HID (keyboard mouse joystick) devices simultaneously.
ESP8266 software USB host through general IO pins. We can connect up to 2 USB-LS HID (keyboard mouse joystick) devices simultaneously.

esp8266_usb_soft_host Test for esp8266 usb host . Works with ESP-IDF v3.4 80MHz and 160MHz. WorkInProgress Test run with mouse & combined mouse & keyb

Sep 1, 2022
ESP32S2 Arduino USB host printer, MIDI, and keyboard demos
ESP32S2 Arduino USB host printer, MIDI, and keyboard demos

ESP32 S2 USB Host Jumpstart A collection of experiments and demos using Espressif ESP32 S2 in USB host mode. Most of the sketches have little or no C+

Sep 15, 2022
esp32s2 implement a usb port display with 320*240 size with ~13pfs
esp32s2 implement a  usb port display with 320*240 size with ~13pfs

esp32s2_usb_display overview it's a USB mini display for Linux platform, such as raspberry Pi, Centos X86 server. it refer many opensource projects: r

Aug 9, 2022
Tiny and portable usb host and device stack for mcu with usb ip

Tiny and portable usb host and device stack for mcu with usb ip

Sep 25, 2022
IR2USB - IR to USB HID Converter based on ATtiny45/85
 IR2USB - IR to USB HID Converter based on ATtiny45/85

IR2USB - IR to USB HID Converter based on ATtiny45/85 IR2USB receives signals from an infrared remote control and converts them into keyboard inputs,

Aug 10, 2022
Raw HID keyboard forwarder to turn the Pi 400 into a USB keyboard

Raspberry Pi 400 as a USB HID Keyboard Hook your Pi 400 up to your PC somehow, using a USB Type-C cable into the power port. Anker make good ones- I u

Sep 28, 2022
ESP32 S2 USB host with examples.

This new USB host library based is based on changed and hopefully somehow final API from espressif. The idea is to make this library usable with esp-i

Sep 21, 2022
USB host implementation using PIO of raspberry pi pico (RP2040).

Pico-PIO-USB USB host implementation using PIO of raspberry pi pico (RP2040). You can add additional USB port to RP2040. ?? This library is WIP. API m

Sep 23, 2022
USB-C_PCB_experiments - USB-C ports made from a flex PCB and an ATtiny84A
USB-C_PCB_experiments - USB-C ports made from a flex PCB and an ATtiny84A

USB-C PCB Experiments This is part of an ongoing series of projects involving creative interpretations of the USB mechanical standards. You've probabl

Sep 5, 2022
Anotter USB temperature logger that can record up to four channels with thermocouple or NTCs connected via CDC directly or SCPI to USB.
Anotter USB temperature logger that can record up to four channels with thermocouple or NTCs connected via CDC directly or SCPI to USB.

temperature-logger Anotter USB temperature logger that can record up to four channels with thermocouple or NTCs connected via CDC directly or SCPI to

Aug 11, 2022