使用Linux虚拟鼠标驱动程序 [英] Using Linux virtual mouse driver
问题描述
我正在尝试根据 Essential Linux设备驱动程序一书来实现虚拟鼠标驱动程序.有一个用户空间应用程序,它可以生成坐标以及内核模块.
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.)我编译了用户空间应用程序和驱动程序的代码.
1.) I compile the code of the user space application and driver.
2.)接下来,我检查了dmesg
输出并具有
2.) Next i checked dmesg
output and have,
输入:未指定的设备为/class/input/input32
虚拟鼠标驱动程序已初始化
input: Unspecified device as /class/input/input32
Virtual Mouse Driver Initialized
3.) sysfs 节点是在初始化期间正确创建的(可在/sys/devices/platform/vms/coordinates
中找到)
3.) The sysfs node was created properly during initialization (found in /sys/devices/platform/vms/coordinates
)
4.)我知道通过检查以下内容,虚拟鼠标驱动程序( input32 )已链接到 event5 :
4.) I know that the virtual mouse driver (input32 ) is linked to event5 by checking the following:
$ cat/proc/bus/input/devices
I:总线= 0000供应商= 0000产品= 0000版本= 0000
N:姓名="
P:物理=
S:Sysfs =/设备/虚拟/输入/输入32
U:Uniq =
H:处理程序= event5
B:EV = 5
B:REL = 3
$ 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.)接下来,我将 GPM 服务器附加到事件接口:gpm -m /dev/input/event5 -t evdev
5.) Next i attach a GPM server to the event interface: gpm -m /dev/input/event5 -t evdev
6.)运行用户空间应用程序为虚拟鼠标生成随机坐标,并使用od -x /dev/input/event5
观察生成的坐标.
6.) Run the user space application to generate random coordinates for virtual mouse and observe generated coordinates using od -x /dev/input/event5
.
什么也没发生.为什么?
另外,此处作者提到应使用/etc/停止gdm
init.d/gdm停止,但是在停止gdm
时得到没有这样的服务" .
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
.
这是我用于构建和运行虚拟鼠标的完整脚本:
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
制作文件:
obj-m+=app.o
内核版本: 2.6.35.6
正如我之前所说,我可以通过od接收结果,但是我是通过您的程序收到的 echo 9 19>/sys/devices/platform/virmouse/vmevent
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
给予:
时间1368284298.207654类型2代码0值9
时间1368284298.207657类型2代码1值19
时间1368284298.207662类型0代码0值0
也许这会有所帮助:在Xorg.0.log中,我看到以下内容:
Maybe this will help: in Xorg.0.log i see the following:
[21.022](II)未指定输入驱动程序/标识符(忽略)
[ 21.022] (II) No input driver/identifier specified (ignoring)
[272.987](II)config/udev:添加输入设备(/dev/input/event5)
[ 272.987] (II) config/udev: Adding input device (/dev/input/event5)
[272.987](II)未指定输入驱动程序/标识符(忽略)
[ 272.987] (II) No input driver/identifier specified (ignoring)
[666.521](II)config/udev:添加输入设备(/dev/input/event5)
[ 666.521] (II) config/udev: Adding input device (/dev/input/event5)
[666.521](II)未指定输入驱动程序/标识符(忽略)
[ 666.521] (II) No input driver/identifier specified (ignoring)
推荐答案
我花费了大量时间来解决此问题,并且我想帮助其他遇到此问题的人.我认为某些 X11 外部功能干扰了我的模块工作. 禁用GDM 后,它现在可以正常运行(运行级别3).您可以在这里找到工作代码 http://fred-zone .blogspot.ru/2010/01/mouse-linux-kernel-driver.html 工作发行版ubuntu 11.04(已禁用gdm)
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)
这篇关于使用Linux虚拟鼠标驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!