[英]How to move the mouse cursor from user code?
My data comes from an arduino (which gets it from a sensor).我的数据来自 arduino(从传感器获取)。
I'd like to have the data processed by an user program (after reading it from /dev/ttyUSB0 ).我想让用户程序处理数据(从 /dev/ttyUSB0 读取后)。
After that I need to control the mouse cursor using the output of the program.之后,我需要使用程序的输出来控制鼠标光标。
(I'd really like to avoid writing a kernel driver at this moment.) (此时我真的很想避免编写内核驱动程序。)
What is the recommended way to do this(on a Linux environment)?执行此操作的推荐方法是什么(在 Linux 环境中)?
Perhaps a library on top of X...or some tool/script I can directly pipe the data into?也许是一个基于 X 的库……或者一些我可以直接将数据通过管道传输的工具/脚本?
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
void mouseMove(int x, int y)
{
Display *displayMain = XOpenDisplay(NULL);
if(displayMain == NULL)
{
fprintf(stderr, "Errore nell'apertura del Display !!!\n");
exit(EXIT_FAILURE);
}
XWarpPointer(displayMain, None, None, 0, 0, 0, 0, x, y);
XCloseDisplay(displayMain);
}
There are a few options I know of:我知道有几个选项:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.