[comp.sys.mac.programmer] Mouse Positioning

yarri@ee.eng.ohio-state.edu (Douglas Yarrington) (01/31/91)

Moshi-moshi, Koniti wa.

I'm trying to find a quick and dirty way to over-ride the position of
the on mouse. What I'd like to do is to input data from the serial
port, and then use this data as the location of the mouse.

I don't really want to right a new mouse driver, I'm hoping I can just
write to a certain memory location to over-ride the mouse position.

Anyone know how I can do that? Do I have to fake-out the mouse driver
by changing the contents of the VIA? Isn't there just a low memory
global containing the mouse coordinates?

Thanks for your help, arigato goziamashita.

zaa mata.

--Douglas

-- 

 Douglas Yarrington                            yarri@icarus.eng.ohio-state.edu
 MSEE The Ohio State University:    "The best 4, no 5, no 6 years of my life!"
_______________________________________________________________________________

jwinterm@jarthur.Claremont.EDU (Jim Wintermyre) (02/28/91)

In article <1991Jan30.194250.6792@ee.eng.ohio-state.edu> yarri@ee.eng.ohio-state.edu (Douglas Yarrington) writes:
>Moshi-moshi, Koniti wa.
>
>I'm trying to find a quick and dirty way to over-ride the position of
>the on mouse. What I'd like to do is to input data from the serial
>port, and then use this data as the location of the mouse.
>
>I don't really want to right a new mouse driver, I'm hoping I can just
>write to a certain memory location to over-ride the mouse position.
>
>Anyone know how I can do that? Do I have to fake-out the mouse driver
>by changing the contents of the VIA? Isn't there just a low memory
>global containing the mouse coordinates?
>
>Thanks for your help, arigato goziamashita.
>
>zaa mata.
>
>--Douglas
>
>-- 
>
> Douglas Yarrington                            yarri@icarus.eng.ohio-state.edu
> MSEE The Ohio State University:    "The best 4, no 5, no 6 years of my life!"
>_______________________________________________________________________________


Yes, Douglas, there ARE some low-memory globals that contain the 
position of the mouse.  I was wondering the same thing for quite a 
while, then I read about it the other night in a little program in
"On Macintosh Programming: Advanced Techniques" by Dan Allen (which
I recommend).  I then went through some of my old DTS sample code 
and found an assembly program called "TbltDrvr" which had some code
showing how to change mouse positioning.  I then figured out how to
call it form a high-level language.  The globals you need to worry 
about are "MTemp" ($0828), "RawMouse" ($082C), and "Mouse" ($0830) 
(By the way, all of these low-mem globals are listed in SysEqu.a in
MPW).  Why do you have to worry about 3 variables just to position 
the mouse?  Well, in order to determine how fast the cursor tracks 
mouse movement, you need to keep track of an "old" mouse position 
and a "new" mouse position - this is apparently the purpose of  
MTemp and RawMouse.  It seems as though Mouse is used for actually 
drawing the cursor on the screen.  So to move the cursor on the 
screen, you put the coordinates you want to go to into all 3 
variables.  If you don't fill out Mouse, the cursor won't move on 
the screen; if you don't fill out either mTemp or RawMouse the 
mouse will jump as soon as you move it from the new location (this 
is a result of the scaling feature).  By the way, the horizontal 
coordinate is stored in the low word of the variable, and the vert 
is stored in the hi word.  In code, this looks like:

 var
  mTemp, rawMouse, mouse: ^longint;

 mTemp := Pointer($828);  {get low mem globals}
 rawMouse := Pointer($82C);
 mouse := Pointer($830);

 mouse^ := vertCoord;  {stuff vertical coordinate}
 mouse^ := BSL(mouse^, vertCoord);  {move them to hi word}
 mouse^ := BOR(mouse^, horizCoord); {add horiz coord to low word}

 mTemp^ := mouse^;     {update related globals}
 rawMouse^ := mouse^;

I don't know exactly how technically accurate my description has 
been, but I do know that it works.  Hope this helps.

         - Jim Wintermyre