AOA 2.0 HID 设备在发送 HID 事件时不支持控制请求

AOA 2.0 HID Device Unsupported Control Request On Sending HID Event

我正在尝试使用 AOA 2.0 协议和 libusb 将按键发送到 Android 设备。我能够将设备置于附件模式并且能够注册 HID 设备。但是,每当我发送事件时,我都会收到错误消息:

libusb: debug [handle_control_completion] unsupported control request

我想我的问题可能出在我发送的隐藏描述符上,但是我在网上找到了一个应该有效的描述符。

这是我的相关代码和描述符:

char DESC[] = {

            0x05, 0x01, /* Usage Page (Generic Desktop)      */
            0x09, 0x06, /* Usage (Keyboard)                  */
            0xA1, 0x01, /* Collection (Application)          */
            0x05, 0x07, /* Usage Page (Keyboard)             */
            0x19, 224,  /* Usage Minimum (224)               */
            0x29, 231,  /* Usage Maximum (231)               */
            0x15, 0x00, /* Logical Minimum (0)               */
            0x25, 0x01, /* Logical Maximum (1)               */
            0x75, 0x01, /* Report Size (1)                   */
            0x95, 0x08, /* Report Count (8)                  */
            0x81, 0x02, /* Input (Data, Variable, Absolute)  */
            0x81, 0x01, /* Input (Constant)                  */
            0x19, 0x00, /* Usage Minimum (0)                 */
            0x29, 101,  /* Usage Maximum (101)               */
            0x15, 0x00, /* Logical Minimum (0)               */
            0x25, 101,  /* Logical Maximum (101)             */
            0x75, 0x08, /* Report Size (8)                   */
            0x95, 0x06, /* Report Count (6)                  */
            0x81, 0x00, /* Input (Data, Array)               */
            0x05, 0x08, /* Usage Page (LED)                  */
            0x19, 0x01, /* Usage Minimum (1)                 */
            0x29, 0x05, /* Usage Maximum (5)                 */
            0x15, 0x00, /* Logical Minimum (0)               */
            0x25, 0x01, /* Logical Maximum (1)               */
            0x75, 0x01, /* Report Size (1)                   */
            0x95, 0x05, /* Report Count (5)                  */
            0x91, 0x02, /* Output (Data, Variable, Absolute) */
            0x95, 0x03, /* Report Count (3)                  */
            0x91, 0x01, /* Output (Constant)                 */
            0xC0    /* End Collection                    */
};
int response;
//Register the HID device
response = libusb_control_transfer(handle, 0x40, 54, 1, sizeof(DESC), NULL, 0, 0);
if (response < 0) {error(response); return -1;}
// Send the device descriptor
response = libusb_control_transfer(handle, 0x40, 56, 1, 0, DESC, sizeof(DESC), 0);
if (response < 0) {error(response); return -1;}
usleep(1000);
// OK so here is the problem, this request should just send the next song ket 
// However I am getting unsupported control request.
char report[] = {0x07,0x00,0xEC,0x00,0x00,0x00,0x00,0x00};
response = libusb_control_transfer(handle, 0x40, 57, 1, 0, report, sizeof(report), 0);
if (response < 0) {error(response); return -1;} 
return 0;

编辑:好的,所以我在 android adk 代码中做了更多的挖掘,我发现了一个带有一些示例代码的通用键盘描述符。现在它似乎不会像每 10 次尝试中的一次那样失败,这很奇怪吗?我也更新了代码。

我的问题是发送设备描述符后我没有睡足够长的时间。

usleep(100000);

已修复