我正在尝试运行《Essential Linux Device Drivers》一书中的虚拟鼠标驱动程序,但是当我使用 /var/log/Xorg.0.log 中的 insmod 将此模块加载到内核中时,我看到:
[ 757.212] (II) config/udev: Adding input device (/dev/input/event10)
[ 757.212] (II) No identifier specified, ignoring this device.
我怎样才能强制 Xorg 不忽略这个设备?或者我必须在内核模块代码中添加什么?
答案1
尝试替换输入设备驱动程序中的以下代码行
set_bit(EV_REL, vms_input_dev->evbit);
set_bit(REL_X, vms_input_dev->relbit);
set_bit(REL_Y, vms_input_dev->relbit);
和
vms_input_dev->name = "Virtual Mouse";
vms_input_dev->phys = "vmd/input0"; // "vmd" is the driver's name
vms_input_dev->id.bustype = BUS_VIRTUAL;
vms_input_dev->id.vendor = 0x0000;
vms_input_dev->id.product = 0x0000;
vms_input_dev->id.version = 0x0000;
vms_input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
vms_input_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE);
vms_input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
vms_input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_SIDE) | BIT_MASK(BTN_EXTRA);
vms_input_dev->relbit[0] |= BIT_MASK(REL_WHEEL);
它在 ubuntu 12.04 上对我有用