Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!munnari.oz.au!yoyo.aarnet.edu.au!sirius.ucs.adelaide.edu.au!jpotter From: jpotter@ucs.adelaide.edu.au (Jonathan Potter) Newsgroups: comp.sys.amiga.programmer Subject: Re: How to do a "MovePointer()"? Message-ID: <3758@sirius.ucs.adelaide.edu.au> Date: 22 Jun 91 05:08:48 GMT References: <19997@csli.Stanford.EDU> <22627@cbmvax.commodore.com> Organization: Information Technology Division, The University of Adelaide, AUSTRALIA Lines: 65 In article <22627@cbmvax.commodore.com> peter@cbmvax.commodore.com (Peter Cherna) writes: >In article caw@miroc.Chi.IL.US (Christopher A. Wichura) writes: >>In article <19997@csli.Stanford.EDU> bratt@csli.Stanford.EDU (Harry Bratt) writes: >>>I need to change the position of Intuition's mouse pointer. I >> >>>Currently I'm doing: >>> >>>IntuitionBase->MouseX = x; >>>IntuitionBase->MouseY = y; >>>SetPointer(...); >>> >>>This appears to work.... but... > >That is illegal. >> >>The above looks kinda illegal to me. What you might consider is doing >>something like this: >> >> lock = LockIBase(0); >> CurX = IntuitionBase->MouseX; >> CurY = IntuitionBase->MouseY; >> >> >> UnlockIBase(lock); > >I don't think I'd do a DoIO() to input.device while inside LockIBase(). >In any case, you can't guarantee that there aren't other input events >(from the hardware) moving the mouse. All you want to do is get >an atomic reading of MouseX and MouseY. That is to say, if the >mouse-coords change from (100,50) to (120,40) at one time, you >want to avoid reading (100,40) or (120,50). Since MouseX and >MouseY are both words, you can grab them in one shot: > >sturct MouseCoords >{ > WORD MouseY; > WORD MouseX; >} mouse; > > (* (ULONG *)(&mouse)) = (* (ULONG *)(&IntuitionBase->MouseY) ) > /* set-up event and perform DoIO() */ > >That horrible expression basically reads: pretend there is a ULONG >value starting at IntuitionBase->MouseY, and copy it into the ULONG >we're pretending is located at 'mouse'. > >>Christopher A. Wichura Multitasking. Just DO it. > > Peter Going through the input device is the proper way to do it, but you don't need to LockIBase() - your DoIO() to the input device goes in before intuition sees it, so Intuition acts as if nothing unusual has happened. Another way to do it is to use the Intuition() function, passing it an input event. This saves having to setup an IORequest, but can cause some problems. The RKM discourages you from using this. Jon -- | Jon Potter | | I'd really like to | | P.O. Box 289 | jpotter@itd.adelaide.edu.au | change the world... | | Goodwood, SA | FidoNet : 3:680/829 | But they won't give me | | Australia 5034 | | the source code. |