As far as i know the two ways to get mouse position are using
libgpm or reading
/dev/input/mice file. But the latter just returns a <strong>relative position</strong> from the last position. So my question is how can i get the <strong>absolute mouse position</strong> though reading
/dev/input/mice or other way.
And i want to implement this function by
C++. Any information will be appreciate.
First, a mouse device is probably sending only relative movements, so there is no way to get the absolute position (just try to raise the mouse with your hand and put it elsewhere), except by integrating the movement.
And almost all Linux GUI environments are above <a href="http://en.wikipedia.org/wiki/X11" rel="nofollow">X11</a>, so it is the X11 server (usually the
Xorg process) which deals with the mouse (it is the only process actually reading
You'll then need to make an X11 client application. See <a href="https://stackoverflow.com/q/9357382/841108" rel="nofollow">this</a> & <a href="https://stackoverflow.com/q/10311270/841108" rel="nofollow">that</a> question. But you'll be much better in using some existing toolkit library, like Qt or GTK; see e.g. <a href="http://doc.qt.digia.com/qt/qmoveevent.html" rel="nofollow">QMouseEvent</a> & <a href="http://doc.qt.digia.com/qt/qwidget.html#mouseMoveEvent" rel="nofollow">QWidget::mouseMoveEvent</a> in Qt, and <a href="http://developer.gnome.org/gtk3/stable/GtkWidget.html#GtkWidget-motion-notify-event" rel="nofollow">GtkWidget "motion-notify-event" signal</a> in Gtk (and many other functions).
See also <a href="https://stackoverflow.com/q/14553435/841108" rel="nofollow">this question</a>