罗技F710手柄描述符数据抓包 - 以及stm32读取usb-hid数据程序
- 硬件: 罗技F710游戏手柄、一台笔记本电脑
- 软件: USBlyzer分析仪(下载地址)
大家都知道,罗技F710上有D模式和X模式,D模式是普通模式,每帧数据传输8个字节;X模式是xbox手柄模式,有更多的信息,每帧传输15个字节(因为有陀螺仪数据)。
D模式
- 先看8个字节的通讯协议:

- 以下是抓包内容,各种描述符分类清晰,在stm32的usb驱动程序中可以按照命名轻易找到对应的接口来修改。
| Connection Status | Device connected |
|---|---|
| Current Configuration | 1 |
| Speed | Full (12 Mbit/s) |
| Device Address | 14 |
| Number Of Open Pipes | 2 |
Device Descriptor Logitech Cordless RumblePad 2
| Offset | Field | Size | Value | Description |
|---|---|---|---|---|
| 0 | bLength | 1 | 12h | |
| 1 | bDescriptorType | 1 | 01h | Device |
| 2 | bcdUSB | 2 | 0200h | USB Spec 2.0 |
| 4 | bDeviceClass | 1 | 00h | Class info in Ifc Descriptors |
| 5 | bDeviceSubClass | 1 | 00h | |
| 6 | bDeviceProtocol | 1 | 00h | |
| 7 | bMaxPacketSize0 | 1 | 08h | 8 bytes |
| 8 | idVendor | 2 | 046Dh | Logitech, Inc. |
| 10 | idProduct | 2 | C219h | |
| 12 | bcdDevice | 2 | 0305h | 3.05 |
| 14 | iManufacturer | 1 | 01h | “Logitech” |
| 15 | iProduct | 1 | 02h | “Logitech Cordless RumblePad 2” |
| 16 | iSerialNumber | 1 | 00h | |
| 17 | bNumConfigurations | 1 | 01h |
Configuration Descriptor 1 Bus Powered, 98 mA
| Offset | Field | Size | Value | Description |
|---|---|---|---|---|
| 0 | bLength | 1 | 09h | |
| 1 | bDescriptorType | 1 | 02h | Configuration |
| 2 | wTotalLength | 2 | 0029h | |
| 4 | bNumInterfaces | 1 | 01h | |
| 5 | bConfigurationValue | 1 | 01h | |
| 6 | iConfiguration | 1 | 04h | “PACER-X03.05_A” |
| 7 | bmAttributes | 1 | 80h | Bus Powered |
| 4…0: Reserved | …00000 | |||
| 5: Remote Wakeup | …0… | No | ||
| 6: Self Powered | .0… | No, Bus Powered | ||
| 7: Reserved (set to one)(bus-powered for 1.0) | 1… | |||
| 8 | bMaxPower | 1 | 31h | 98 mA |
Interface Descriptor 0/0 HID, 2 Endpoints
| Offset | Field | Size | Value | Description |
|---|---|---|---|---|
| 0 | bLength | 1 | 09h | |
| 1 | bDescriptorType | 1 | 04h | Interface |
| 2 | bInterfaceNumber | 1 | 00h | |
| 3 | bAlternateSetting | 1 | 00h | |
| 4 | bNumEndpoints | 1 | 02h | |
| 5 | bInterfaceClass | 1 | 03h | HID |
| 6 | bInterfaceSubClass | 1 | 00h | |
| 7 | bInterfaceProtocol | 1 | 00h | |
| 8 | iInterface | 1 | 00h |
HID Descriptor
| Offset | Field | Size | Value | Description |
|---|---|---|---|---|
| 0 | bLength | 1 | 09h | |
| 1 | bDescriptorType | 1 | 21h | HID |
| 2 | bcdHID | 2 | 0111h | 1.11 |
| 4 | bCountryCode | 1 | 00h | |
| 5 | bNumDescriptors | 1 | 01h | |
| 6 | bDescriptorType | 1 | 22h | Report |
| 7 | wDescriptorLength | 2 | 0077h | 119 bytes |
Endpoint Descriptor 81 1 In, Interrupt, 4 ms
| Offset | Field | Size | Value | Description |
|---|---|---|---|---|
| 0 | bLength | 1 | 07h | |
| 1 | bDescriptorType | 1 | 05h | Endpoint |
| 2 | bEndpointAddress | 1 | 81h | 1 In |
| 3 | bmAttributes | 1 | 03h | Interrupt |
| 1…0: Transfer Type | …11 | Interrupt | ||
| 7…2: Reserved | 000000… | |||
| 4 | wMaxPacketSize | 2 | 0020h | 32 bytes |
| 6 | bInterval | 1 | 04h | 4 ms |
Endpoint Descriptor 01 1 Out, Interrupt, 8 ms
| Offset | Field | Size | Value | Description |
|---|---|---|---|---|
| 0 | bLength | 1 | 07h | |
| 1 | bDescriptorType | 1 | 05h | Endpoint |
| 2 | bEndpointAddress | 1 | 01h | 1 Out |
| 3 | bmAttributes | 1 | 03h | Interrupt |
| 1…0: Transfer Type | …11 | Interrupt | ||
| 7…2: Reserved | 000000… | |||
| 4 | wMaxPacketSize | 2 | 0020h | 32 bytes |
| 6 | bInterval | 1 | 08h | 8 ms |
Interface 0 HID Report Descriptor Game Pad
结合通讯协议,以及报告描述符,可以轻易写joystick驱动代码(用stm32的usb主机模式,读取usb-hid类设备驱动程序即可)
| Item Tag (Value) | Raw Data |
|---|---|
| Usage Page (Generic Desktop) | 05 01 |
| Usage (Game Pad) | 09 05 |
| Collection (Application) | A1 01 |
| Collection (Logical) | A1 02 |
| Report ID (1) | 85 01 |
| Report Size (8) | 75 08 |
| Report Count (4) | 95 04 |
| Logical Minimum (0) | 15 00 |
| Logical Maximum (255) | 26 FF 00 |
| Physical Minimum (0) | 35 00 |
| Physical Maximum (255) | 46 FF 00 |
| Usage (X) | 09 30 |
| Usage (Y) | 09 31 |
| Usage (Z) | 09 32 |
| Usage (Rz) | 09 35 |
| Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) | 81 02 |
| Report Size (4) | 75 04 |
| Report Count (1) | 95 01 |
| Logical Maximum (7) | 25 07 |
| Physical Maximum (315) | 46 3B 01 |
| Unit (Eng Rot: Degree) | 66 14 00 |
| Usage (Hat Switch) | 09 39 |
| Input (Data,Var,Abs,NWrp,Lin,Pref,Null,Bit) | 81 42 |
| Unit (None) | 66 00 00 |
| Report Size (1) | 75 01 |
| Report Count (12) | 95 0C |
| Logical Maximum (1) | 25 01 |
| Physical Maximum (1) | 45 01 |
| Usage Page (Button) | 05 09 |
| Usage Minimum (Button 1) | 19 01 |
| Usage Maximum (Button 12) | 29 0C |
| Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) | 81 02 |
| Report Count (1) | 95 01 |
| Report Size (8) | 75 08 |
| Usage Page (Vendor-Defined 1) | 06 00 FF |
| Logical Maximum (255) | 26 FF 00 |
| Physical Maximum (255) | 46 FF 00 |
| Usage (Undefined) | 09 00 |
| Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) | 81 02 |
| End Collection | C0 |
| Collection (Logical) | A1 02 |
| Report ID (2) | 85 02 |
| Report Count (7) | 95 07 |
| Report Size (8) | 75 08 |
| Logical Maximum (255) | 26 FF 00 |
| Physical Maximum (255) | 46 FF 00 |
| Usage Page (Vendor-Defined 1) | 06 00 FF |
| Usage (Vendor-Defined 3) | 09 03 |
| Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) | 81 02 |
| End Collection | C0 |
| Collection (Logical) | A1 02 |
| Report ID (3) | 85 03 |
| Usage (Vendor-Defined 4) | 09 04 |
| Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) | 91 02 |
| End Collection | C0 |
| End Collection | C0 |
X模式
- 协议解析:
| 字节 | 0 | 1 | 2 | 3 | 4 | 5 | 6,7 | 8,9 | 10,11 | 12,13 | 14 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 定义 | ID | 0x14 | Buttons | Buttons | LT | RT | Left X Axis | Left Y Axis | Right X Axis | Right Y Axis | Mode |

| Connection Status | Device connected |
|---|---|
| Current Configuration | 1 |
| Speed | Full (12 Mbit/s) |
| Device Address | 15 |
| Number Of Open Pipes | 2 |
Device Descriptor Wireless Gamepad F710
| Offset | Field | Size | Value | Description |
|---|---|---|---|---|
| 0 | bLength | 1 | 12h | |
| 1 | bDescriptorType | 1 | 01h | Device |
| 2 | bcdUSB | 2 | 0200h | USB Spec 2.0 |
| 4 | bDeviceClass | 1 | FFh | Vendor-Specific |
| 5 | bDeviceSubClass | 1 | FFh | |
| 6 | bDeviceProtocol | 1 | FFh | |
| 7 | bMaxPacketSize0 | 1 | 08h | 8 bytes |
| 8 | idVendor | 2 | 046Dh | Logitech, Inc. |
| 10 | idProduct | 2 | C21Fh | |
| 12 | bcdDevice | 2 | 0305h | 3.05 |
| 14 | iManufacturer | 1 | 01h | “Logitech” |
| 15 | iProduct | 1 | 02h | “Wireless Gamepad F710” |
| 16 | iSerialNumber | 1 | 03h | “8F699F3C” |
| 17 | bNumConfigurations | 1 | 01h |
Configuration Descriptor 1 Bus Powered, 98 mA
| Offset | Field | Size | Value | Description |
|---|---|---|---|---|
| 0 | bLength | 1 | 09h | |
| 1 | bDescriptorType | 1 | 02h | Configuration |
| 2 | wTotalLength | 2 | 0030h | |
| 4 | bNumInterfaces | 1 | 01h | |
| 5 | bConfigurationValue | 1 | 01h | |
| 6 | iConfiguration | 1 | 00h | |
| 7 | bmAttributes | 1 | 80h | Bus Powered |
| 4…0: Reserved | …00000 | |||
| 5: Remote Wakeup | …0… | No | ||
| 6: Self Powered | .0… | No, Bus Powered | ||
| 7: Reserved (set to one)(bus-powered for 1.0) | 1… | |||
| 8 | bMaxPower | 1 | 31h | 98 mA |
Interface Descriptor 0/0 Vendor-Specific, 2 Endpoints
| Offset | Field | Size | Value | Description |
|---|---|---|---|---|
| 0 | bLength | 1 | 09h | |
| 1 | bDescriptorType | 1 | 04h | Interface |
| 2 | bInterfaceNumber | 1 | 00h | |
| 3 | bAlternateSetting | 1 | 00h | |
| 4 | bNumEndpoints | 1 | 02h | |
| 5 | bInterfaceClass | 1 | FFh | Vendor-Specific |
| 6 | bInterfaceSubClass | 1 | 5Dh | |
| 7 | bInterfaceProtocol | 1 | 01h | |
| 8 | iInterface | 1 | 00h |
Unrecognized Class-Specific Descriptor
| Offset | Field | Size | Value | Description |
|---|---|---|---|---|
| 0 | bLength | 1 | 10h | |
| 1 | bDescriptorType | 1 | 21h | |
| 2 | 14 | 10 01 01 24 81 14 03 00 03 13 02 00 03 00 |
Endpoint Descriptor 81 1 In, Interrupt, 4 ms
| Offset | Field | Size | Value | Description |
|---|---|---|---|---|
| 0 | bLength | 1 | 07h | |
| 1 | bDescriptorType | 1 | 05h | Endpoint |
| 2 | bEndpointAddress | 1 | 81h | 1 In |
| 3 | bmAttributes | 1 | 03h | Interrupt |
| 1…0: Transfer Type | …11 | Interrupt | ||
| 7…2: Reserved | 000000… | |||
| 4 | wMaxPacketSize | 2 | 0020h | 32 bytes |
| 6 | bInterval | 1 | 04h | 4 ms |
Endpoint Descriptor 02 2 Out, Interrupt, 8 ms
| Offset | Field | Size | Value | Description |
|---|---|---|---|---|
| 0 | bLength | 1 | 07h | |
| 1 | bDescriptorType | 1 | 05h | Endpoint |
| 2 | bEndpointAddress | 1 | 02h | 2 Out |
| 3 | bmAttributes | 1 | 03h | Interrupt |
| 1…0: Transfer Type | …11 | Interrupt | ||
| 7…2: Reserved | 000000… | |||
| 4 | wMaxPacketSize | 2 | 0020h | 32 bytes |
| 6 | bInterval | 1 | 08h | 8 ms |
手柄完整的数据协议:https://blog.csdn.net/liudijiang/article/details/86693435#Logitech_Wireless_Gamepad_F710_2
程序
顺便放一个我的程序,裸机读取usb手柄数据并发给串口,基于stm32h743,使用意法半导体官方IDEstm32cubeide生成并修改了部分驱动内容。
蓝奏云:https://www.lanzoui.com/i8wf6de
PS: 后续有时间更新一下生成和修改的过程,并移植到freertos中(官方ide直接生成的freertos + usb-host代码有bug,会直接内存泄露)。
DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。
更多推荐
所有评论(0)