Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!ccu.umanitoba.ca!herald.usask.ca!alberta!brazeau.ucs.ualberta.ca!unixg.ubc.ca!ubc-cs!van-bc!zaphod.mps.ohio-state.edu!think.com!linus!agate!ucbvax!cis.ohio-state.edu!sample.eng.ohio-state.edu!purdue!mentor.cc.purdue.edu!noose.ecn.purdue.edu!samsung!mips!dimacs.rutgers.edu!rutgers!cbmvax!mks From: mks@cbmvax.commodore.com (Michael Sinz) Newsgroups: comp.sys.amiga.programmer Subject: Re: How to do a "MovePointer()"? Message-ID: <22533@cbmvax.commodore.com> Date: 18 Jun 91 12:49:02 GMT References: <19997@csli.Stanford.EDU> Reply-To: mks@cbmvax.commodore.com (Michael Sinz) Organization: Commodore, West Chester, PA Lines: 105 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 >don't need lots of low-level control (like recording mouse movements >and playing them back), I just need a single re-positioning once >in a while. >Currently I'm doing: > >IntuitionBase->MouseX = x; >IntuitionBase->MouseY = y; >SetPointer(...); > >This appears to work.... but... >Is it legal to be writing to those IntuitionBase variables? And >is there a better way to be doing this? You are lucky that it almost worked... To move the mouse, you need to send a mouse event down the input food chain. There is full documentation of this in the RKM (1.3) The example code given here moves the mouse pointer in a circle... /* * InputDevice example * * This example adds a few mouse movements to the input chain... */ #include #include #include #include #include VOID main(VOID) { struct IOStdReq *inputReqBlk; struct MsgPort *inputPort; struct InputEvent *FakeEvent; short loop; short num; short numloop; if (inputPort=CreatePort(NULL,NULL)) { if (FakeEvent=AllocMem(sizeof(struct InputEvent),MEMF_PUBLIC)) { if (inputReqBlk=(struct IOStdReq *)CreateExtIO(inputPort, sizeof(struct IOStdReq))) { if (!OpenDevice("input.device",NULL, (struct IORequest *)inputReqBlk,NULL)) { for (numloop=0;numloop<4;numloop++) for (loop=0;loop<8;loop++) for (num=0;num<20;num++) { /* * Note that events are trashed after they finish * from the input food chain. All fields must * be set up before submitting the event again */ FakeEvent->ie_NextEvent=NULL; FakeEvent->ie_Class=IECLASS_RAWMOUSE; FakeEvent->ie_Code=IECODE_NOBUTTON; FakeEvent->ie_Qualifier=IEQUALIFIER_RELATIVEMOUSE; FakeEvent->ie_X=0; FakeEvent->ie_Y=0; switch (loop) { case 0: FakeEvent->ie_X=1; case 1: FakeEvent->ie_Y=1; break; case 2: FakeEvent->ie_Y=1; case 3: FakeEvent->ie_X=-1; break; case 4: FakeEvent->ie_X=-1; case 5: FakeEvent->ie_Y=-1; break; case 6: FakeEvent->ie_Y=-1; case 7: FakeEvent->ie_X=1; break; } inputReqBlk->io_Data=(APTR)FakeEvent; inputReqBlk->io_Command=IND_WRITEEVENT; inputReqBlk->io_Flags=0; inputReqBlk->io_Length=sizeof(struct InputEvent); DoIO((struct IORequest *)inputReqBlk); } CloseDevice((struct IORequest *)inputReqBlk); } DeleteExtIO((struct IORequest *)inputReqBlk); } FreeMem(FakeEvent,sizeof(struct InputEvent)); } DeletePort(inputPort); } } /----------------------------------------------------------------------\ | /// Michael Sinz - Amiga Software Engineer | | /// Operating System Development Group | | /// BIX: msinz UUNET: rutgers!cbmvax!mks | |\\\/// | | \XX/ Quantum Physics: The Dreams that Stuff is made of. | \----------------------------------------------------------------------/