|There's more than one way to do things
read raw mouse data in Linuxby Lotus1 (Vicar)
|on Apr 30, 2014 at 20:58 UTC
I'm working on a stepper motor project with the Raspberry Pi and I needed to detect when an an optical mouse stops seeing motion. I'm using the mouse in place of an optical encoder to tell me when the stepper is stalled.
This code works on Raspbian with or without X. Since POSIX::read() waits for mouse events at first I thought I would have to use a second thread to poll somehow. Then I found the alarm function in "Programming Perl".
I found solutions for reading raw mouse data in Python but of course I wanted to do it in Perl. And I'm sharing it here so others can find it. (The oo Mouse module makes websearches for Perl related mouse projects difficult to find.)