5

I am trying to implement a virtual mouse driver according to the Essential Linux device Drivers book. There is a user space application, which generates coordinates as well as a kernel module.

See: Virtual mouse driver and userspace application code and also a step by step on how to use this driver.

1.) I compile the code of the user space application and driver.

2.) Next i checked dmesg output and have,

input: Unspecified device as /class/input/input32
Virtual Mouse Driver Initialized

3.) The sysfs node was created properly during initialization (found in /sys/devices/platform/vms/coordinates)

4.) I know that the virtual mouse driver (input32 ) is linked to event5 by checking the following:

$ cat /proc/bus/input/devices
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name=""
P: Phys=
S: Sysfs=/devices/virtual/input/input32
U: Uniq=
H: Handlers=event5
B: EV=5
B: REL=3

5.) Next i attach a GPM server to the event interface: gpm -m /dev/input/event5 -t evdev

6.) Run the user space application to generate random coordinates for virtual mouse and observe generated coordinates using od -x /dev/input/event5.

And nothing happens. Why? Also here author mentioned that gdm should be stopped, using /etc/init.d/gdm stop, but i get "no such service" when stopping gdm.

Here is my complete script for building and runing virtual mouse:

make -C /usr/src/kernel/2.6.35.6-45.fc14.i686/ SUBDIRS=$PWD modules
gcc -o app_userspace app_userspace.c
insmod app.ko
gpm -m /dev/input-event5 -t evdev
./app_userspace

Makefile:

obj-m+=app.o

Kernel version: 2.6.35.6


As i said before i can recieve the result through od, but i received it through your program echo 9 19> /sys/devices/platform/virmouse/vmevent

gives:

time 1368284298.207654 type 2 code 0 value 9

time 1368284298.207657 type 2 code 1 value 19

time 1368284298.207662 type 0 code 0 value 0

So now the question is: what is wrong with X11? I would like to stress, that i tried this code under two different distributions Ubuntu 11.04 and Fedora 14.


Maybe this will help: in Xorg.0.log i see the following:

[ 21.022] (II) No input driver/identifier specified (ignoring)

[ 272.987] (II) config/udev: Adding input device (/dev/input/event5)

[ 272.987] (II) No input driver/identifier specified (ignoring)

[ 666.521] (II) config/udev: Adding input device (/dev/input/event5)

[ 666.521] (II) No input driver/identifier specified (ignoring)

asked May 10, 2013 at 12:27
3
  • I use ubuntu distro not a custom kernel, is it ok for this example? Commented May 10, 2013 at 21:01
  • So now the question is: what is wrong with X11? This question is not for Stackoverflow then. Commented May 11, 2013 at 15:59
  • maybe the cause lies in virtual machine? (i use virtualbox) Commented May 12, 2013 at 11:08

2 Answers 2

4

I spent a huge amount of time, resolving this issue, and i would like to help other people, who run in this problem. I think some outer X11 features interfered my module work. After disabling GDM it now works fine (runlevel 3). Working code you can find here http://fred-zone.blogspot.ru/2010/01/mouse-linux-kernel-driver.html working distro ubuntu 11.04 (gdm disabled)

answered May 16, 2013 at 18:05
Sign up to request clarification or add additional context in comments.

1 Comment

I disabled lightdm in Xubuntu 12.04 (it replaced gdm) and am still having the same issue. Really don't know what to make of this.
4

Try replacing the below lines of code in the input device driver

set_bit(EV_REL, vms_input_dev->evbit);
set_bit(REL_X, vms_input_dev->relbit);
set_bit(REL_Y, vms_input_dev->relbit);

with

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);

It worked for me on ubuntu 12.04

answered Jun 25, 2013 at 13:29

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.