Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Virtual mouse driver, possible problems with X11

    Hello. I created virtual mouse driver according to Essential Linux Device Drivers book. After i wrote coordinates echo x y > /sys/ ... /coordinates into sysfs node, my program generates event packets through event interface /dev/input/event5 (i checked this). This event interface is attached to the GPM gpm -m /dev/input/event5 -t evdev. So the code is OK. But mouse don't move. After checking Xorg.0.log i catched this:

    [ 666.521] (II) config/udev: Adding input device (/dev/input/event5)
    [ 666.521] (II) No input driver/identifier specified (ignoring)

    Maybe this is the error which affects my module work? But i don't know how to fix it ... Thanks.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Review some existing mouse driver code to figure this out. Most drivers have some sort of identification that the kernel can use to map devices to applications that need to use them (such as xorg in your case). Sorry, but this generality is as far as I can advise you...

    P.S. I last wrote a mouse driver for Linux X-windows to control an analog joystick about 10-15 years ago. My remembery is fuzzy...
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Thanks for reply. This is the code:

     * A Virtual Mouse Driver to send fake events from userspace.
     * Written by Fred Chien <>
    #include <linux/fs.h>
    #include <asm/uaccess.h>
    #include <linux/pci.h>
    #include <linux/input.h>
    #include <linux/platform_device.h>
    struct input_dev *virmouse_input_dev;
    static struct platform_device *virmouse_dev; /* Device structure */
    /* Sysfs method to input simulated coordinates */
    static ssize_t write_virmouse(struct device *dev,
                                  struct device_attribute *attr,
                                  const char *buffer, size_t count)
            int x, y, key;
            /* parsing input data */
            sscanf(buffer, "%d %d", &x, &y);
            /* Report relative coordinates */
            input_report_rel(virmouse_input_dev, REL_X, x);
            input_report_rel(virmouse_input_dev, REL_Y, y);
            printk ("virmouse_event: X:%d Y:%d\n", x, y);
            return count;
    /* Attach the sysfs write method */
    DEVICE_ATTR(vmevent, 0644, NULL, write_virmouse);
    /* Attribute Descriptor */
    static struct attribute *virmouse_attrs[] = {
    /* Attribute group */
    static struct attribute_group virmouse_attr_group = {
            .attrs = virmouse_attrs,
    /* Driver Initializing */
    int __init virmouse_init(void)
            /* Register a platform device */
            virmouse_dev = platform_device_register_simple("virmouse", -1, NULL, 0);
            if (IS_ERR(virmouse_dev)){
                    printk ("virmouse_init: error\n");
                    return PTR_ERR(virmouse_dev);
            /* Create a sysfs node to read simulated coordinates */
            sysfs_create_group(&virmouse_dev->dev.kobj, &virmouse_attr_group);
            /* Allocate an input device data structure */
            virmouse_input_dev = input_allocate_device();
            if (!virmouse_input_dev) {
                    printk("Bad input_allocate_device()\n");
                    return -ENOMEM;
            /* Announce that the virtual mouse will generate relative coordinates */
            set_bit(EV_REL, virmouse_input_dev->evbit);
            set_bit(REL_X, virmouse_input_dev->relbit);
            set_bit(REL_Y, virmouse_input_dev->relbit);
            /* Register with the input subsystem */
            /* print messages in the dmesg */
            printk("Virtual Mouse Driver Initialized.\n");
            return 0;
    /* Driver Uninitializing */
    void virmouse_uninit(void)
            /* Unregister from the input subsystem */
            /* Remove sysfs node */
            sysfs_remove_group(&virmouse_dev->dev.kobj, &virmouse_attr_group);
            /* Unregister driver */
    MODULE_AUTHOR("Fred Chien <>");
    MODULE_DESCRIPTION("Virtual Mouse Driver");

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts