My data comes from an arduino (which gets it from a sensor).
I'd like to have the data processed by an user program (after reading it from /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)?
Perhaps a library on top of X...or some tool/script I can directly pipe the data into?
Taken from dzone:
#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:
- xte is a command line tool: http://linux.die.net/man/1/xte
- if you can use python, xaut might be more to your liking: http://xautomation.sourceforge.net/index.html
Or with node-x11:
var x = 100;
var y = 200;
require('x11').createClient(function(err, display) {
display.client.WarpPointer(0, display.screen[0].root, 0, 0, 0, 0, x, y);
});
来源:https://stackoverflow.com/questions/20581343/how-to-move-the-mouse-cursor-from-user-code