在Linux中从内核模块控制鼠标指针
好的,问题来了:我必须编写一个 Linux 内核模块来控制鼠标光标。例如,将屏幕上的光标移动到给定的 x/y 坐标、发送随机鼠标点击等。
我必须这样写的原因是我正在编写一个使用手机作为触摸板的应用程序。因为这是我大学的一个项目,所以计算机端控制器必须是linux内核模块。那么,问题是,如何从内核模块控制鼠标行为?我已经用谷歌搜索了一段时间,但遗憾的是,我在网络深处没有找到任何结论性的东西:(
Ok, so here's the problem: I have to write a linux kernel module that will control the mouse cursor. For example, to move the cursor around the screen to given x/y coords, send random mouse clicks, etc.
The reason why I have to write that is that I'm writing an application that uses mobile phone as a touchpad. Because it's a project for my uni, the computer-side controller has to be a linux kernel module. So, the question is, how can I control mouse behaviour from kernel module? I've googled for some time, but I didn't find anything conclusive in the depths of the 'net, sadly :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
内核是错误的地方——内核完全不知道任何像“鼠标光标”这样具体的东西的存在。输入层大约是尽可能接近的,并且仅传输相对鼠标运动事件(例如,“有人将鼠标向左移动了一英寸”)。
查看 XTEST X11 扩展。它有许多与您想要做的事情直接相关的功能。
http://www.xfree86.org/current/xtestlib.pdf
The kernel is the wrong place for this -- the kernel is completely unaware of the existence of anything so concrete as a "mouse cursor". The input layer is about as close as it gets, and that only transfers relative mouse motion events (e.g, "someone moved the mouse an inch to the left").
Check out the XTEST X11 extension. It has a number of functions which relate directly to what you're trying to do.
http://www.xfree86.org/current/xtestlib.pdf
在设备子系统中查看 /dev/input/mouse0 的内容。
内核输入文档是否有很大帮助?
请注意,典型应用程序和鼠标之间存在大量库。但是,由于您明确提到了内核驱动程序,因此似乎可以安全地排除 X11 堆栈和构建在其之上的其他项目。
Poke around in the devices subsystem to see what is presenting /dev/input/mouse0.
Has any of the kernel input documentation been of much help?
Note that there are tons of libraries between the typical application and the mouse. However, since you explicitly mentioned kernel drivers, it seems safe to rule out inclusion of the X11 stack and other items built on top of it.
破解 Linux 输入子系统。您可以使用 input_handler 创建一个输入模块,然后输入文件将在 /sys 中创建。然后编写一个用户程序来读取/写入/sys中的该文件
hack in the Linux input subsystem. You can create a input module with a input_handler, and then the input file will be craeted in /sys. Then write a user program to read/write from that file in /sys