Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!dimacs.rutgers.edu!rutgers!cbmvax!peter From: peter@cbmvax.commodore.com (Peter Cherna) Newsgroups: comp.sys.amiga.programmer Subject: Re: How to do a "MovePointer()"? Message-ID: <22627@cbmvax.commodore.com> Date: 21 Jun 91 15:58:36 GMT References: <19997@csli.Stanford.EDU> Reply-To: peter@cbmvax.commodore.com (Peter Cherna) Organization: Commodore-Amiga, Inc. West Chester, PA. Lines: 53 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 -- Peter Cherna, Operating Systems Development Group, Commodore-Amiga, Inc. {uunet|rutgers}!cbmvax!peter peter@cbmvax.commodore.com My opinions do not necessarily represent the opinions of my employer. "Gosh, didn't he have anything positive to say at all?"