Find the answer to your Linux question:
Results 1 to 1 of 1
Hello. I try to use example driver from Essential Linux device Drivers book. The idea is that you transfer coordinates to GPM through sysfs file and event interface. Driver code ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2013
    Posts
    3

    Virtual mouse driver problems


    Hello. I try to use example driver from Essential Linux device Drivers book. The idea is that you transfer coordinates to GPM through sysfs file and event interface. Driver code is attached.

    After driver initialization i have in dmesg:
    [ 3884.645588] input: Unspecified device as /devices/virtual/input/input7
    [ 3884.645728] Virtual Mouse Driver Initialized.


    cat /proc/bus/input/devices shows:
    I: Bus=0000 Vendor=0000 Product=0000 Version=0000
    N: Name=""
    P: Phys=
    S: Sysfs=/devices/virtual/input/input7
    U: Uniq=
    H: Handlers=mouse2 event5
    B: PROP=0
    B: EV=7
    B: KEY=70000 0 0 0 0 0 0 0 0
    B: REL=103


    next i do the following: gpm -m /dev/input/event5 -t evdev i attach event interface to gpm.
    Next i write coordinates into sysfs node using:
    echo "100 100 0" > /sys/devices/platform/virmouse/vmevent

    using dmesg | tail i can check that packet was recieved.
    So i have write function.
    Code:
    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%d", &x, &y, &key);
    
            /* 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 %d\n", x, y, key);
    
            /* Report key event */
            if (key>0) {
                    if (key==1)
                            input_report_key(virmouse_input_dev, BTN_LEFT, 1);
                    else if (key==2)
                            input_report_key(virmouse_input_dev, BTN_MIDDLE, 1);
                    else
                            input_report_key(virmouse_input_dev, BTN_RIGHT, 1);
            }
    
            input_sync(virmouse_input_dev);
    
            return count;
    
    }
    this function connected with sysfs node. After packet was received, i display it. Dmesg output:
    [ 5365.684407] virmouse_event: X:100 Y:100 0

    but mouse cursor doesen't move. Why?
    I tried different variations of this code from different sites on two distros ubuntu 11.04 and fedora 14, (2.6.35, 2.6.38 kernels). And i really confused, why it isn't working? So i guess that the code is ok but i have some unknown outer features in system which are interfere my module work. Thanks.
    Attached Files Attached Files

Posting Permissions

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