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

时间:2015-05-24 16:47:58

标签: android c hid libusb

我正在尝试使用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次尝试中的一次尝试那样非常奇怪?我也更新了代码。

1 个答案:

答案 0 :(得分:0)

我的问题是我在发送设备描述符后睡得不够长。

usleep(100000);

修正了它