c++ - 360 游戏 Controller Linux 设备驱动程序问题调用我的探测功能

标签 c++ c linux driver device

我正在尝试学习 USB Linux 设备驱动程序。我选择了 MS XBOX 360 Controller 。我注意到有一个适用于 Linux 的通用驱动程序 (xpad.ko)。不用说,我的代码是基于 xpad.c 的。无论如何,我构建了我的驱动程序 (360.ko)。当前驱动程序(xpad、led_class、甚至 usbhid)上的 modprobe -r。还将 xpad 驱动程序列入黑名单。对我的驱动程序 (360.ko) 进行了 insmod。 USBcore registers my driver (usbcore: registered new interface driver Microsoft Xbox 360 Controller)。但是,它不会调用我的 usb_360_probe() 。有什么线索吗?????

static struct usb_driver uDriver = {
     .name =         "Microsoft Xbox 360 Controller",
     .probe =        usb_360_probe,
     .disconnect =   usb_360_disconnect,
     .id_table =     skel_table,

};

#define USB_360_VENDOR_ID 0x045E
#define USB_360_PRODUCT_ID 0x0202//0x0289//0x028E //I tried all these product IDs!

static struct usb_device_id skel_table[] = {
 { USB_DEVICE(USB_360_VENDOR_ID, USB_360_PRODUCT_ID) },
 {},
 };

static int usb_360_probe(struct usb_interface *intf, const struct usb_device_id*id)
{
printk(KERN_INFO, "(360)usb_360_probe.\n");

}

static int __init usb_360_init(void)
{
int result;

printk(KERN_INFO, "(360)usb_360_init.\n");

/* register this driver with the USB subsystem */
 result = usb_register(&uDriver);
 if (result)
 {
    printk(KERN_INFO, "(360)usb_register failed.\n");
 }

  printk(KERN_INFO, "(360)usb_register succeeded.\n");

 return result;
 }

static void __exit usb_360_exit(void)
{


/* deregister this driver with the USB subsystem */
usb_deregister(&uDriver);
printk(KERN_INFO, "(360)usb_unregister succeeded.\n");
}

module_init(usb_360_init);
module_exit(usb_360_exit);

//我正在使用 printk(KERN_INFO) 来获取 dmesg 消息。它适用于我的其他字符驱动程序。

内核:2.6.32-21-通用

最佳答案

当找到使用给定供应商 ID 产品 ID 插入的设备时,将调用您的探测函数。你有上述设备吗?插入了吗。

关于c++ - 360 游戏 Controller Linux 设备驱动程序问题调用我的探测功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9879941/

相关文章:

c++ - typeid() 在 g++ 中返回额外的字符

c - 您的程序中出现了访问冲突(段错误)

c - 多线程程序中计数意外增加

javascript - NodeJs 套接字连接问题

linux - sftp 文件年龄 : reading files transferred from sftp that aren't complete yet

Linux:尝试通过 ioctl 获取操纵杆供应商和产品 ID,改为获取 EINVAL

c++ - 我如何指示 Emscripten 在编译期间应将源文件放置在何处?

c++ - C++中打印 double 的最大宽度

c++ - 什么是数组指针,int (*ptr)[10],它是如何工作的?

c# - 确保表单例份验证在浏览器关闭时注销