我正在构建一个适配器,通过USB将各种视频游戏控制器连接到PC . 它的核心是Teensy 3.1微控制器,它使用Cortex-M4处理器 .
M4能够处理原始USB数据包,从而模拟任何类型的USB设备 . 我已成功编程它以呈现复合USB设备:
-
接口1, endpoints 1:USB串口(用于调试) - 状态接口
-
接口1, endpoints 2:USB串行TX / RX接口
-
接口2, endpoints 3:HID操纵杆
现在的问题是,我希望能够同时连接几种不同类型的游戏控制器(例如Nintendo和Super Nintendo) . 在我的所有适配器中都有超过15个端口,这意味着我不能只为每个端口分配一个 endpoints ,因为USB总共只允许16个 endpoints .
阅读HID报告描述符规范,我得到的印象是's possible to define multiple independent devices on the same interface. However despite my best efforts, I can' t似乎把它拉了下来 . 应用程序(例如 jstest-gtk
)只能看到一个巨大的操纵杆 .
现在我正在使用这个报告描述符:
static uint8_t joystick_report_desc[] = {
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x04, // Usage (Joystick)
0xA1, 0x01, // Collection (Application)
0x85, 0x01, // Report ID (1)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x75, 0x01, // Report Size (1)
0x95, 0x08, // Report Count (8)
0x05, 0x09, // Usage Page (Button)
0x19, 0x01, // Usage Minimum (Button #1)
0x29, 0x08, // Usage Maximum (Button #8)
0x81, 0x02, // Input (variable,absolute)
0xC0, // End Collection
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x04, // Usage (Joystick)
0xA1, 0x01, // Collection (Application)
0x85, 0x02, // Report ID (2)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x75, 0x01, // Report Size (1)
0x95, 0x10, // Report Count (16)
0x05, 0x09, // Usage Page (Button)
0x19, 0x01, // Usage Minimum (Button #1)
0x29, 0x10, // Usage Maximum (Button #16)
0x81, 0x02, // Input (variable,absolute)
0xC0, // End Collection
};
我原本希望有一个带有8个按钮的操纵杆和一个带有16个按钮的操纵杆,但应用程序会看到一个带有24个按钮的操纵杆 .
实际上是否可以通过这种方式定义多个独立操纵杆?
1 回答
我最近使用mbed实现了一个类似的项目,并且可以确认只能使用您所描述的报告描述符来定义多个操纵杆 .
在Windows中,它应该工作 . 使用Linux,需要使用
HID_QUIRK_MULTI_INPUT
quirk加载usbhid驱动程序 .VID
是您的供应商ID,PID
是您的产品ID . 然后它应该在/dev/input
中显示为多个操纵杆设备 .