I am using this code to read mouse events from the dev/input/event* in linux .
#include #include #include
A mouse only sends relative movement, not absolute position. You have to keep track of it yourself, and when you receive a mouse-button event you have to check your own coordinates for the position.