[comp.sys.amiga.tech] Finding current mouse status.

cattelan@cs.umn.edu (Russell Cattelan) (09/19/90)

I am tring to port the programs the was orginally written for and IBM 
The program is not interupt driven, so when it wants to find out what the 
mouse status is it just looks at it and updateds a global structure.

I have been trying to do the same thing on the the amiga but all
I seem to come up with is events. Both by intuition and by opening 
the gameport I have to deal with events. 

The one thing I did come up with was locking intuition and the looking
at the x an y val of the mouse, that works but the condition of the buttons
is not stored in the intuition structer?(or I missed it).

any suggestions most welcome.

<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
<> :-{             :-\<>  Russell Cattelan       University of Minnesota    <>
<>    :-}       :-`)  <>  cattelan@umn-cs.cs.umn.edu                        <>
<>       :-) :-(      <>  {...!rutgers!umn-cs!cattelan}                     <>
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>

walterl@cwi.nl (walter van der laan) (09/19/90)

Make a global structure reflecting the mouse status and update it
every time you get a mouse event, set the FOLLOWMOUSE flag if you
want a lot of (x,y) reports (the flagname might be slightly
different). This way you can look at your own structure if you
want to know the mouse status.

	Walter van der Laan

cmcmanis@stpeter.Eng.Sun.COM (Chuck McManis) (09/30/90)

In article <1990Sep18.192348.3594@cs.umn.edu> (Russell Cattelan) writes:
>I am tring to port the programs the was orginally written for and IBM 
>The program is not interupt driven, so when it wants to find out what the 
>mouse status is it just looks at it and updateds a global structure.

A friendly way to do this is to create an input handler which simple
tracks the mouse by looking at all of the mousemove events. It should
open a public message port with some well known name like "MousePosition"
and keep with the port two shorts which contain the mouse position. Since
your code will only be reading the position you don't have to worry about
multiple writers. So your code  will look something like :

main()
	...
	struct custom_port {
		struct MsgPort	port;
		USHORT		MouseX;
		USHORT		MouseY;
	} *mp;

	mp = FindPort("MousePosition");
	if (mp == NULL) 
		/* error can't find handler's port */

	...
	MouseX = mp->MouseX;
	MouseY = mp->MouseY;
	/* etc */
}

You can kick off the input handler from your code or you can have
a separate program to do that. In 2.0 you would build a commodity
to do this fairly easily. 

--
--Chuck McManis						    Sun Microsystems
uucp: {anywhere}!sun!cmcmanis   BIX: <none>   Internet: cmcmanis@Eng.Sun.COM
These opinions are my own and no one elses, but you knew that didn't you.
"I tell you this parrot is bleeding deceased!"

xanthian@zorch.SF-Bay.ORG (Kent Paul Dolan) (10/01/90)

cmcmanis@stpeter.Eng.Sun.COM (Chuck McManis) writes:
>In article <1990Sep18.192348.3594@cs.umn.edu> (Russell Cattelan) writes:
[asks for a simple way to just look at a structure for mouse position]

>A friendly way to do this is to create an input handler which simply
>tracks the mouse by looking at all of the mousemove events. It should
>open a public message port with some well known name like "MousePosition"
>and keep with the port two shorts which contain the mouse position. Since
>your code will only be reading the position you don't have to worry about
>multiple writers. So your code  will look something like :
>
>main()
>	...
>	struct custom_port {
>		struct MsgPort	port;
>		USHORT		MouseX;
>		USHORT		MouseY;
>	} *mp;
>
>	mp = FindPort("MousePosition");
>	if (mp == NULL) 
>		/* error can't find handler's port */
>
>	...
>	MouseX = mp->MouseX;
>	MouseY = mp->MouseY;
>	/* etc */
>}
>
>You can kick off the input handler from your code or you can have
>a separate program to do that. In 2.0 you would build a commodity
>to do this fairly easily. 

Probably you want to forbid(); permit(): (or whatever's appropriate)
around the two assignments to prevent picking up a new MouseX and an
old MouseY from a parallel multitasking routine (if a handler can be
interrupted in turn by a time slice preempt).

A nit, but of such is great code made.

Kent, the man from xanth.
<xanthian@Zorch.SF-Bay.ORG> <xanthian@well.sf.ca.us>