LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (http://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   How to capture clicks from mouse to a file (http://www.linuxquestions.org/questions/linux-hardware-18/how-to-capture-clicks-from-mouse-to-a-file-338963/)

floydigus 07-01-2005 02:06 AM

How to capture clicks from mouse to a file
 
Hi,

I'm planning a project to hack a mouse to monitor the CO2 being generated by my homebrew beer, and I could use some suggestions about how to capture the input from the mouse.

What I'm planning is something like the weather flaps you see on the vertical exhaust pipes on tractors. This will be placed over the airlock on a fermenter and close a circuit when the flap goes up. That circuit would be one of the mouse button circuits.

All I need is to log a date and time to a file when that 'button' is 'clicked'. Is there a way I can do that from a bash script - perhaps using /dev/psaux?

I'm using Suse, a ps2 mouse and the serial and paralell ports are occupied with other (beer related) devices.

Cheers!

RandomLinuxNewb 07-01-2005 03:09 AM

I would imagine you could watch /dev/psaux for changes. Go grab an old ball mouse take the ball out and use
Code:

tail -f /dev/psaux
Then start clicking away and see if the screen is updated, also make sure that it doesn't get updated if the mouse is just sitting still. If it is being updated only with clicks then you would need to use
Code:

stat --format=%Y /dev/psaux
in a script that runs as a cron job every few seconds or what ever is needed.

floydigus 07-02-2005 01:40 AM

Can read /dev/psaux, just can't make sense of it
 
Thanks for the pointer, RLN, you inspired me to plug the mouse in and have play.

Tail doesn't work on /dev/psaux at all - it just sits there until I ctrl-c.

Cat /dev/psaux does, however, show some stuff.
Moving the ball shows this kind of thing:
((((((
Clicking the buttons also has an effect but these seem to be getting interpreted as control characters as they just move the cursor around the terminal window. Left click moves the cursor one space right on button down and then one space back again on button up. Right click moves the cursor to a new line on button down and then to the right of the previous line on button up. Perhaps this is binary data - do I just need to read it differently?


All times are GMT -5. The time now is 09:01 AM.