[net.micro.amiga] mouse vs. joystick

lbg@gitpyr.UUCP (Lee B Grey) (03/20/86)

I am curious about the difference between a joystick and a mouse.  (No 
smart-ass comments!  I KNOW what the difference is!)  I mean, are they 
interchangable when plugged into the side of the Amiga?  Can anyone,
Commodore-Amiga affiliated or otherwise, shed some light on this?

The inspiration for this question is the rotating amiga3d demo which
was posted a short while ago.  It had some joystick functions in the
source, but my mouse had no effect on it.  Is it supposed to respond 
to user controls?  Is it only affected by a joystick, and not a mouse?

Thanks for your help (whoever you turn out to be).

Lee

bruceb@amiga.UUCP (Bruce Barrett) (03/25/86)

In article <1574@gitpyr.UUCP> lbg@gitpyr.UUCP (Lee B Grey) writes:
>I am curious about the difference between a joystick and a mouse.[...]
>The inspiration for this question is the rotating amiga3d demo [...]


OK, lets look at this.

Game port			Track ball
pin #		Joystick	or Mouse

  1		Forward		V-Pulse
  2		Backward	H-Pulse
  3		Left		VQ-Pulse
  4		Right		HD-Pulse
  6		button 1	button 1	CIAB, bit 6 or 7
  9		button 2	button 2

At the connection of the mouse to the main Amiga box the signals look like
this:

Joystick:
Imagine 4 simple switches (X) arranged in the following pattern:

	       		X Forward

	       Left X   o   X Right

		        X    
		        Backward

As the joystick handle is moved closer to a switch contact is made with that
switch.  (Imagine that they are buttons.)  There are 9 unique positions 
that the joystick can produce:

		Forward	Left	Right	Backward
		-------	----	-----	--------
"At rest"	Up	Up	Up	Up
"North"		Down	Up	Up	Up
"South"		Up	Up	Up	Down
"West"		Up	Down	Up	Up	
"East"		Up	Up	Down	Up	
"NW"		Down	Down	Up	Up	
"SW"		Up	Down	Up	Down
"NE"		Down	Up	Down	Up
"SE"		Up	Up	Down	Down

The normal state of each switch is open (state is logic 1).  When closed 
input is grounded and the state becomes a logic 0.

For a forward movement of the joystick the signals would look like this:
		Start    End
		|	 |
		V	 V
	________         ________
Forward		\_______/
	_________________________
Back	
	_________________________
Left
	_________________________
Right


A mouse generates 2 out of phase signals foe each axis.  The way that these
are out of phase determines the direction.  The number of transitions
determines th "distance", or "speed".  For example:

	____     ____     ____     ____
V pulse	    |___|    |___|    |___|
	  ____     ____     ____     ____
V quad	      |___|    |___|    |___|

might indicate "forward" and:

	    ____     ____     ____     ____
V pulse	        |___|    |___|    |___|
	  ____     ____     ____     ____
V quad	      |___|    |___|    |___|

might indicate backward.

Look at the up transitions of V-pulse with respect to the signal value
of V-quad.  In the first case they occur when V-quad is low, in the 
second they occur when V-quad is high.  This is an example only,
I don't have the exact phase information in front of me.

Conclusion:
===========

	If you plug a mouse into a port that is expecting a joystick
you will get lots of up/down transitions which look like button presses.
Moving vertically should cause forward and left "button presses", moving
horizontally should cause back and right "button presses".  It should
be possible (but quite difficult) to position a mouse such that all 4
of the pulse signals are high and the "joystick port" thinks that it
is at rest.

Hope this helps.
--Bruce Barrett