[comp.sys.mac.programmer] GetMouse et al.

mnkonar@pavo.SRC.Honeywell.COM (Murat N. Konar) (10/26/88)

A question:
How do the mouse routines like WaitMouseUp, Button, StillDown, GetMouse,
and others(I can't remember if there are any others at the moment) get
their information?  Do they directly read the mouse or do they use the 
event queue?  Any insights welcome either on the net or by mail.
__________________________
Have a day. :^|
Murat N. Konar mnkonar@ely.UUCP
Honeywell Systems & Research Center, Camden, MN

lsr@Apple.COM (Larry Rosenstein) (10/28/88)

In article <10849@srcsip.UUCP> mnkonar@srcsip.UUCP () writes:
>
>A question:
>How do the mouse routines like WaitMouseUp, Button, StillDown, GetMouse,
>and others(I can't remember if there are any others at the moment) get
>their information?  Do they directly read the mouse or do they use the 

A quick perusal in Macsbug reveals that Button and GetMouse look at the low
mnemory globals, and that the others (such as WaitMouseUp) call the lower
level routines.  In addition, the OS Event Manager routines OSEventAvail
and GetOSEvent seem to access the low memory globals as well.

-- 
		 Larry Rosenstein,  Object Specialist
 Apple Computer, Inc.  20525 Mariani Ave, MS 46-B  Cupertino, CA 95014
	    AppleLink:Rosenstein1    domain:lsr@Apple.COM
		UUCP:{sun,voder,nsc,decwrl}!apple!lsr

mnkonar@pavo.SRC.Honeywell.COM (Murat N. Konar) (10/28/88)

I asked how GetMouse and other mouse routines work and lsr@Apple.COM (Larry
Rosenstein) replied (thanks, by the way):
>A quick perusal in Macsbug reveals that Button and GetMouse look at the low
>mnemory globals, and that the others (such as WaitMouseUp) call the lower
>level routines.  In addition, the OS Event Manager routines OSEventAvail
>and GetOSEvent seem to access the low memory globals as well.

This is what I was afraid of.  What I'm trying to figure out is how I can
"fake" mouse activity a la QuicKeys and others.  I had hoped that manipulating
the event queue would allow me to do this but no dice. What is the best or
easiest (take your pick) way to do this?
______________________________________________________________________
Have a day. :^|
Murat N. Konar mnkonar@ely.UUCP
Honeywell Systems & Research Center, Camden, MN

lippin@skippy.berkeley.edu (The Apathist) (10/31/88)

Recently mnkonar@ely.UUCP (Murat N. Konar) wrote:

>This is what I was afraid of.  What I'm trying to figure out is how I can
>"fake" mouse activity a la QuicKeys and others.  I had hoped that manipulating
>the event queue would allow me to do this but no dice. What is the best or
>easiest (take your pick) way to do this?

For most purposes, you can still fake mouse activity by using the
event queue, because most programs are interested in the recent past,
instead of the present.  For example, to fake a click, you can post a
mousedown/mouseup pair, and a well-written program will figure the
button went down while it wasn't looking.  Dragging may be more
difficult, as programs might ignore the location of the mouseup event
in favor of their own calls to GetMouse.  And since presumably you
would post both events together, the program's call to StillDown would
fail, and so it wouldn't call GetMouse, and the drag wouldn't go
anywhere.

In a case like this, you can still work with the program interactively
by patching GetMouse and Button.

					--Tom Lippincott
					..ucbvax!math!lippin

	"`The problem's all inside your head,' she said to me.
	 `The program's easy if it's done recursively.
	  I'd like to help you in your struggle for a B;
	  There must be fifty ways to write your program.

	  Fifty ways to write your program.'"

jkjl@munnari.oz (John Lim) (11/01/88)

In article <16230@agate.BERKELEY.EDU> lippin@math.berkeley.edu writes:
>Recently mnkonar@ely.UUCP (Murat N. Konar) wrote:
>
>>This is what I was afraid of.  What I'm trying to figure out is how I can
>>"fake" mouse activity a la QuicKeys and others.  I had hoped that manipulating
>>the event queue would allow me to do this but no dice. What is the best or
>>easiest (take your pick) way to do this?
>

I thought you could always use the journaling driver described in the Event
manager chapter in IM 1. I do remember somewhere a comment that it might
not be supported in future versions of the Mac, but give it a go anyway
and let us know the answer.

Furthermore the person who wrote Easy Access is on the net. Perhaps
you could ask him.

	john lim

tecot@Apple.COM (Ed Tecot) (11/06/88)

In article <2553@munnari.oz> jkjl@munnari.UUCP (John Lim) writes:
>In article <16230@agate.BERKELEY.EDU> lippin@math.berkeley.edu writes:
>>Recently mnkonar@ely.UUCP (Murat N. Konar) wrote:
>>
>>>This is what I was afraid of.  What I'm trying to figure out is how I can
>>>"fake" mouse activity a la QuicKeys and others.  I had hoped that manipulating
>>>the event queue would allow me to do this but no dice. What is the best or
>>>easiest (take your pick) way to do this?
>
>I thought you could always use the journaling driver described in the Event
>manager chapter in IM 1. I do remember somewhere a comment that it might
>not be supported in future versions of the Mac, but give it a go anyway
>and let us know the answer.
>
>Furthermore the person who wrote Easy Access is on the net. Perhaps
>you could ask him.

Hello?  Did somebody call?
The method used by Easy Access won't work for you.  In a nutshell, Easy Access
emulates the native mouse driver.  It takes advantage of the fact that the
human in the loop won't press the mouse until the cursor is in the right place.
Since your routine doesn't want to wait for the cursor VBL to update (and I
don't even know if it can), you can't use this method.

I'd also recommend using journalling.  I'm pretty sure it has all the hooks
you need.

						_emt