Linux low-level mouse reading… here is a solution to the problem.
Linux low-level mouse reading
I want to read mouse position and button state in Linux using C++, but no X or some (advanced) libraries etc. The only two possibilities I’ve found are reading from the device /dev/input/mice (using fopen ,…) or using libgpm. Are there any other low-level methods?
Thanks in advance.
Solution
In Linux, all mouse events are via /dev/input/mouseX
. /dev/input/mice
is an accumulator in single-mouse devices. Both gpm and X take the mouse event from /dev/input/mouseX or /dev/input
/mice
and forward it.
So reading from /dev/input/
mouseX
or /dev/input/mice
is the lowest level you can get — unless you use libusb/libhid to access the USB mouse device directly. However, accessing the mouse in this way separates it from the kernel, causing a lot of trouble.