How to detect mouse movement

I would like to detect mouse movement using c++ in while{} statement. can someone tell me how to do this? thanks

C++ doen't know about the mouse.
Do you use some kind of framework ?
no, just g++
OP is on linux, and he wants to know about detecting/mouse events (movement). That's what matters.

Let me says I don't know much about mouse movement on linux, but this topic sort of piqued my interest.

Unlike Windows, Linux doesn't have a unified desktop environment (windowing system). You need to tell us what you're using. X, KDE, GNOME, etc.? If I had to guess, then you're most likely using the X11 window system.

If so, you need to look into Xlib. Try searching on the web for xlib and mouse/pointer events.

12.1 Pointer Grabbing
Xlib provides functions that you can use to control input from the pointer, which usually is a mouse. Usually, as soon as keyboard and mouse events occur, the X server delivers them to the appropriate client, which is determined by the window and input focus. The X server provides sufficient control over event delivery to allow window managers to support mouse ahead and various other styles of user interface. Many of these user interfaces depend upon synchronous delivery of events. The delivery of pointer and keyboard events can be controlled independently.

10.5.2 Keyboard and Pointer Events

XQueryPointer - get pointer coordinates

Those links are probably helpful, but more research definitely needs to happen for a complete answer to your question.
Last edited on
Topic archived. No new replies allowed.