tags:

views:

41

answers:

1

Is there a convenient way to get mouse deltas (e.g. mickeys) under X/linux?

I know that I could read from /dev/input/mice but that requires root access and seems a bit to low level for me.

Any idea?

+2  A: 

If this is for a game, i.e. an application with an actual X window, the typical approach used to be:

  1. Grab the mouse, so all mouse input goes to your window
  2. Warp the mouse pointer to the center of your window, to give maximum amount of space to move
  3. On each mouse movement event, subtract the center of the window from the reported position; this gives you a "delta event"
  4. Goto 2

I write "used to be" because there might be better ways to solve this now, haven't looked into it for a while.

This of course won't give you a resolution that is higher than what X is reporting to applications, i.e. pixels. If you're after sub-pixel reporting, I think you need to go lower, perhaps read the device directly as you suggest.

unwind