Find the answer to your Linux question:
Results 1 to 3 of 3
Hi, I've made a virtual mouse driver as part of my input driver study (essential linux drivers book). Besides the driver, there is also a user application (coord.c) that generates ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2009
    Posts
    2

    virtual mouse driver


    Hi,


    I've made a virtual mouse driver as part of my input driver study (essential linux drivers book). Besides the driver, there is also a user application (coord.c) that generates random coordinates and forwards these coordinates to the driver via sysfs.

    I installed the driver and did run the coord user application. This resulted in the following logs :

    user app. :
    -3 6 0
    -17 -15 0
    -13 -15 0
    6 12 0
    -9 -1 0
    2 -7 0
    10 -19 0
    -3 6 0
    0 6 0
    12 16 0
    -11 8 0
    -7 -9 0
    2 10 0
    2 -3 0
    ...

    driver :
    input: Unspecified device as /devices/virtual/input/input8
    Virtual Mouse Driver Initialized.
    -3 6
    -17 -15
    -13 -15
    6 12
    -9 -1
    2 -7
    10 -19
    -3 6
    0 6
    12 16
    -11 8
    -7 -9
    2 10
    2 -3
    ...

    In other words, the coordinates that are being produced by the user app. are coming through properly in the write method of my driver.

    I would however expect that the mouse pointer would be jumping around also, but this is not the case... (I'm running gpm as follows : gpm -m /dev/input/event7 -t evdev )

    I know that the virtual mouse driver ( input8 ) is linked to event7 by checking the following :

    cat /proc/bus/input/devices
    I: Bus=0019 Vendor=0000 Product=0002 Version=0000
    N: Name="Power Button (FF)"
    P: Phys=LNXPWRBN/button/input0
    S: Sysfs=/devices/LNXSYSTM:00/LNXPWRBN:00/input/input0
    U: Uniq=
    H: Handlers=kbd event0
    B: EV=3
    B: KEY=100000 0 0 0

    I: Bus=0019 Vendor=0000 Product=0001 Version=0000
    N: Name="Power Button (CM)"
    P: Phys=PNP0C0C/button/input0
    S: Sysfs=/devices/LNXSYSTM:00/device:00/PNP0C0C:00/input/input1
    U: Uniq=
    H: Handlers=kbd event1
    B: EV=3
    B: KEY=100000 0 0 0

    I: Bus=0017 Vendor=0001 Product=0001 Version=0100
    N: Name="Macintosh mouse button emulation"
    P: Phys=
    S: Sysfs=/devices/virtual/input/input2
    U: Uniq=
    H: Handlers=mouse0 event2
    B: EV=7
    B: KEY=70000 0 0 0 0 0 0 0 0
    B: REL=3

    I: Bus=0011 Vendor=0001 Product=0001 Version=ab41
    N: Name="AT Translated Set 2 keyboard"
    P: Phys=isa0060/serio0/input0
    S: Sysfs=/devices/platform/i8042/serio0/input/input3
    U: Uniq=
    H: Handlers=kbd event3
    B: EV=120013
    B: KEY=4 2000000 3803078 f800d001 feffffdf ffefffff ffffffff fffffffe
    B: MSC=10
    B: LED=7

    I: Bus=0003 Vendor=046d Product=c525 Version=0111
    N: Name="Logitech USB Receiver"
    P: Phys=usb-0000:00:1d.0-1/input0
    S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1:1.0/input/input4
    U: Uniq=
    H: Handlers=mouse1 event4
    B: EV=17
    B: KEY=ffff0000 0 0 0 0 0 0 0 0
    B: REL=143
    B: MSC=10

    I: Bus=0003 Vendor=046d Product=c525 Version=0111
    N: Name="Logitech USB Receiver"
    P: Phys=usb-0000:00:1d.0-1/input1
    S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1:1.1/input/input5
    U: Uniq=
    H: Handlers=kbd event5
    B: EV=1f
    B: KEY=837fff 2c3027 bf004444 0 0 1 f84 8a27c000 667bfa d9415fed 8e0000 0 0 0
    B: REL=40
    B: ABS=1 0
    B: MSC=10

    I: Bus=0010 Vendor=001f Product=0001 Version=0100
    N: Name="PC Speaker"
    P: Phys=isa0061/input0
    S: Sysfs=/devices/platform/pcspkr/input/input6
    U: Uniq=
    H: Handlers=kbd event6
    B: EV=40001
    B: SND=6

    I: Bus=0000 Vendor=0000 Product=0000 Version=0000
    N: Name=""
    P: Phys=
    S: Sysfs=/devices/virtual/input/input8
    U: Uniq=
    H: Handlers=event7
    B: EV=5
    B: REL=3

    I also did check that the according input events are generated properly by inserting the evbug module. After doing this I got following log :
    14 -19
    evbug.c: Event. Dev: input8, Type: 2, Code: 0, Value: 14
    evbug.c: Event. Dev: input8, Type: 2, Code: 1, Value: -19
    evbug.c: Event. Dev: input8, Type: 0, Code: 0, Value: 0
    14 6
    evbug.c: Event. Dev: input8, Type: 2, Code: 0, Value: 14
    evbug.c: Event. Dev: input8, Type: 2, Code: 1, Value: 6
    evbug.c: Event. Dev: input8, Type: 0, Code: 0, Value: 0
    8 -13
    evbug.c: Event. Dev: input8, Type: 2, Code: 0, Value: 8
    evbug.c: Event. Dev: input8, Type: 2, Code: 1, Value: -13
    evbug.c: Event. Dev: input8, Type: 0, Code: 0, Value: 0
    2 -3
    evbug.c: Event. Dev: input8, Type: 2, Code: 0, Value: 2
    evbug.c: Event. Dev: input8, Type: 2, Code: 1, Value: -3
    evbug.c: Event. Dev: input8, Type: 0, Code: 0, Value: 0
    6 2
    evbug.c: Event. Dev: input8, Type: 2, Code: 0, Value: 6
    evbug.c: Event. Dev: input8, Type: 2, Code: 1, Value: 2
    evbug.c: Event. Dev: input8, Type: 0, Code: 0, Value: 0
    12 14
    evbug.c: Event. Dev: input8, Type: 2, Code: 0, Value: 12
    evbug.c: Event. Dev: input8, Type: 2, Code: 1, Value: 14
    evbug.c: Event. Dev: input8, Type: 0, Code: 0, Value: 0
    -7 10
    evbug.c: Event. Dev: input8, Type: 2, Code: 0, Value: -7
    evbug.c: Event. Dev: input8, Type: 2, Code: 1, Value: 10
    evbug.c: Event. Dev: input8, Type: 0, Code: 0, Value: 0
    14 -9
    evbug.c: Event. Dev: input8, Type: 2, Code: 0, Value: 14
    evbug.c: Event. Dev: input8, Type: 2, Code: 1, Value: -9
    evbug.c: Event. Dev: input8, Type: 0, Code: 0, Value: 0

    So the according event is generated properly also.

    I'm not familiar with gpm, but looking at the man pages, it seems that nothing more needs to be done to run gpm (besides indicating that it should react on on event7).

    Does anybody have an idea why I don't see the result of the randomly generated mouse movement events???

  2. #2
    tqh
    tqh is offline
    Just Joined!
    Join Date
    Jul 2010
    Posts
    1

    Red face The same question

    I have the same question.Is there anyone can know why?

  3. #3
    Just Joined!
    Join Date
    Mar 2011
    Posts
    1
    Are you sure that you use the right node to gpm? For me it is /dev/event5 (i.e. not input). Try with e.g. "hd /dev/event5" (or your node) to see if you have any output.

    /Kjell J

  4. $spacer_open
    $spacer_close

Posting Permissions

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