Using Linux Virtual Mouse Driver

Using Linux virtual mouse driver

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)

How does linux pick connect the mouse on my display to a driver in /dev/input/mouse*?

The Linux kernel doesn't process /dev/input/mouse*

The kernel is what provides /dev/input/mouse*

Userspace programs like X.org can then read this device and show a cursor moving accordingly.

Control mouse by writing to /dev/input/mice

this is not trough the file you mentioned, but its way quicker to use this tool instead of decypering the dump of that file. And it does everything you want in bash.

xdotool does the trick in my terminal.

this is the package site for ubuntu.
you probably can install it trough

# apt-get install xdotool

I could just emerge it on gentoo without adding any repositories.

the tool works fairly simple:

#! /bin/bash
# move the mouse x y
xdotool mousemove 1800 500
# left click
xdotool click 1
# right click
xdotool click 3

found it here

How can i create new virtual mouse device on my android device?

From what i see you should create your own virtual device with your own driver , Fortunately there is an easy way to do so using uinput

There is an easy guide for getting started here , and this question can be a good guide to write your own virtual driver.

I thought this can only be done if you have access to kernel , and create your own ( i dont think modifying user rom is a good solution ) , but after reading this , it is clear that Uinput can run in user mode.

Note :

I agree with recommendition to use touch events ; as this solution is more common and makes sense , check second suggestion is this answer

Virtual mouse and eventX

Typically standard udev rules are used to generate symlinks based on the name; for example, in Debian-based systems, as /dev/input/by-id/*-event-* to the corresponding input event device. Because these are based on the device properties, they are stable: you can just use the symlink in there to access your virtual device.

If you cannot find the symlink, you can search for the input event device.

Each Linux input event device is described by a pseudodirectory /sys/class/input/event*, i.e. /sys/class/input/event0, corresponding to /dev/input/event0 or /dev/input/event/0 (whichever exists).

The pseudofile /sys/class/input/event*/device/name contains the device name. The product, vendor, version, and bus type are available as four-character hexadecimal strings in pseudofiles /sys/class/input/event*/device/id/product, /sys/class/input/event*/device/id/vendor, /sys/class/input/event*/device/id/version, and /sys/class/input/event*/device/id/bustype, respectively. You can read these files as normal, except that if you stat() or fstat() them, their size is zero. Instead, read the contents of these files to a small buffer (length 128, or up to 126 characters + "\n\0", should suffice for the name; 8 (4 + "\n\0") should suffice for the files under id/), and compare it to the desired device name, or parse the hexadecimal numbers.

uinput virtual device and /dev/input/mice

/dev/input/mice provides data in the PS/2 mouse protocol.

/dev/input/event* use the Linux input event interface (struct input_event structures as described in /usr/include/linux/input.h).

How to insert my driver automatically on the insertion of USB mouse in Linux System?

Thanks all for your help.

I follow the udev approach to load module automatically on the USB insertion

Below is the procedure to load your Driver automatically on the Insertion of Hot plug-gable device (I experiment with the USB mouse and below procedure is working fine for it)

  1. Run Following command

    cmd > udevadm info -a -p $(udevadm info -q path -n /dev/input/mouse)

    In place of ?? in the above command user need to add the device ID based on its entry in /dev (e.g.for USB flash drive: sdb1 or sda1 etc. based on the device identity)

  2. Get the Value of the below parameters from the output of above command
    KERNEL, ATTRS{idVendor}, ATTRS{idProduct}, ATTRS{serial}

  3. Go to /etc/dev/rule.d directory and Add your rule

    cmd > sudo vim 40-usbmouse.rules
    ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd?1", ATTRS{idVendor}=="058f", ATTRS{idProduct}=="6387", ATTRS{serial} =="4EPLXAXE", SYMLINK+="usbpd", RUN+="/usr/local/bin/InsertModule.sh"

    Save this file.
    Above rule is defined for the USB Mouse.
    Parameter SYMLINK creates a link of your device in the /dev directory and In RUN+ you can give your script location which is going to execute on your device insertion.

    For more info on How to write a rule refer below link

    http://hackaday.com/2009/09/18/how-to-write-udev-rules/

  4. Now after you define your rule user need to restart the udev to take your rule in notice by kernel.
    cmd > sudo stop udev

    cmd > sudo start udev

  5. Insert your USB and validate that your script which you define in your rule shows its effact.
    For Mouse user can use below command

    cmd > udevadm info -a -p $(udevadm info -q path -n /dev/input/mouse)

P.S.: cmd stands for the command shell (Terminal).The above procedure is working with any USB device.



Related Topics



Leave a reply



Submit