Page 1 of 1

Detect PS/2 Mice click events

Posted: Thu Mar 15, 2007 3:35 am
by XCHG
Suppose the PS/2 mouse is in the Stream Mode and the IRQ12 handler procedure is catching 3 bytes of Movement Data Packets. Now I want to know when a button on the mouse is clicked. I don’t know if this is correct or not but should I just see if Byte #1 contains information and both Byte #2 and Byte #3 of the Movement Data Packet are zero? Or in other words, when a mouse button is clicked, should Byte #2 and #3 of the Movement Data Packet necessarily be zero? I’d appreciate it if somebody could answer this question.

Posted: Thu Mar 15, 2007 4:18 am
by pcmattman
The code I sent you (PS/2 Mice Initialization order) shows how to split the status byte. Just get the click states (leftbut, midbut, rightbut) and see if they are 1, if so the mouse is down.

If the button code is 1, movement data may still be there - how else could you drag?

Posted: Thu Mar 15, 2007 2:56 pm
by mystran
Just take the information from the mouse apart, and then rebuild what you want from what you know.

You have a button-down event when button status goes from "not-pressed" to "pressed" and button-up when it's the other way. So you keep the "previous known state" to compare with. There is little point to handle such things in a mouse driver though.

I'd say, take the data (button statuses, movement, whatever) and dump it in some nice format to your GUI, then figure out in your GUI (in some non-PS2 specific code) what to do with the raw data. Probably build events by combining new data with previous data, with some GUI specific logic. :)

Posted: Sat Mar 17, 2007 2:16 am
by XCHG
pcmattman, You are right. I hadn't thought about dragging events.

I am creating a LUT in which different procedures can register themselves as mouse notification handlers. So procedure1 for example can say "Okay I handle the right button's down event" and procedure2 can say "I handle the middle button's up event". The good thing about this would be that procedures can be invoked like a chain so you can have multiple procedures handling the up event of a specifc mouse button. I have not yet came with the complete implementation of this method but once I do, I will post the code in here so others can use it too.

Thank you guys.