【问题标题】:Remove input driver bound to the HID interface删除绑定到 HID 接口的输入驱动程序
【发布时间】:2015-05-29 01:18:55
【问题描述】:

我正在使用一些特殊键盘的驱动程序代码。而且这个键盘确实有特殊模式。根据规范,这些模式只能通过发送和获取功能报告来启用。

我正在使用“hid.c”文件和用户模式发送HID 报告。但是“hid_read”和“hid_get_feature_report”都失败了,错误号为-1。

我已经尝试使用 libusb 从内核驱动程序中分离键盘,但是当我这样做时,'hid_open' 失败。我猜这是由于“输入”或内核的某些驱动程序已经使用了 HID 接口。所以我可能不需要解绑内核 hidraw 驱动程序,而是应该尝试解绑“hidraw”驱动程序顶部的键盘(“输入”)驱动程序。我说的对吗?

知道我该怎么做吗?以及如何找到使用哪些驱动程序以及哪些低级驱动程序绑定到哪个驱动程序的驱动程序?

【问题讨论】:

    标签: linux hid libusb


    【解决方案1】:

    我自己找到了答案。 答案是挖掘这个项目并找到它在 libusb 上的隐藏实现。 或者您可以直接收到报告。

    int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length)
    {
        int res = -1;
        int skipped_report_id = 0;
        int report_number = data[0];
    
        if (report_number == 0x0) {
            /* Offset the return buffer by 1, so that the report ID
               will remain in byte 0. */
            data++;
            length--;
            skipped_report_id = 1;
        }
        res = libusb_control_transfer(dev->device_handle,
            LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE|LIBUSB_ENDPOINT_IN,
            0x01/*HID get_report*/,
            (3/*HID feature*/ << 8) | report_number,
            dev->interface,
            (unsigned char *)data, length,
            1000/*timeout millis*/);
    
        if (res < 0)
            return -1;
    
        if (skipped_report_id)
            res++;
    
        return res;
    }
    

    很抱歉,由于某些法律原因,我无法发布我的实际代码。但是上面的代码来自 hidapi 实现。

    因此,即使您使用旧内核,您仍然有机会让您的驱动程序正常工作。 这也回答了这个问题:https://stackoverflow.com/questions/30565999/kernel-version-2-6-32-does-not-support-hidiocgfeature

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-29
      • 1970-01-01
      • 1970-01-01
      • 2010-12-07
      • 2010-12-15
      • 2010-10-26
      • 1970-01-01
      相关资源
      最近更新 更多