Detect PS/2 Mice click events

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Detect PS/2 Mice click events

Post 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.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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?
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post 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. :)
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post 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.
Post Reply