Emerson: Mouse Demo 2 - Ben Ryves 2005-2006
-------------------------------------------

This second demo provides a TI-83 binary.
I have reworked a lot of the internal AT routines to make them more
efficient, as well as working on the TI-83.
I have also added a number of "safer" AT protocol calls, that check
acknowledgement bytes and "resend" bytes and handle that properly.
The result is a much more reliable set of routines.

I have only tested these routines on a Microsoft Intellimouse. I lack
the tools (currently) to make a proper adapter, so have to unscrew and
wrap wires to the circuit board of each device I wish to test with,
and have a limited number of rodents and stereo jack plugs to be able
to test thoroughly.

The TI-83 version is completely untested, but should work.

Usage:

Send the program to your calculator. Run it, it shouldn't matter if
your mouse was plugged in before or if you plug it in afterwards. It
continuously checks for a connected mouse.

Once it has detected a valid mouse, it will display a success message
followed by the mouse type (standard PS/2 or Intellimouse). If your
mouse has a scroll wheel, it should be picked up as an Intellimouse.

Press any key to enter the main program. At this (or any point),
Clear quits.

Moving the mouse should move the mouse icon around, pressing a mouse
button should highlight the button on the icon. Scrolling the scroll
wheel should adjust the LCD's contrast.

Pressing Y=, Window, Zoom or Trace adjusts the mouse resolution between
1 count/mm and 8 counts/mm.

Possible problems:

If your mouse loses power, and you reset it, it will enter Stream mode.
This program relies on Remote mode (not the default), so you will need
to restart the program to reinitialise your mouse.

The timeout I've used between resetting the mouse and getting the POST
code back should be long enough; it might not be, however. If it fails
to pick up your mouse, try a different one. Please tell me if this is
a problem for you, and I will extend the delay.

Plugging a keyboard in when the program is waiting for a mouse will
cause the keyboard LEDs to flash. This is due to the detection
process:

1. Reset device. (if fails, go to 1).
2. Wait for POST success code ($AA) (if fails, go to 1).
3. Check for device ID of $00 (if fails, go to 1).
4. Check for Intellisense.
5. Intiliase mouse. (if fails, go to 1).

The keyboard fails at step 3 (ID $00 is a mouse) and so resets, causing
the LEDs to flash.

Unsupported features:

A mouse with five buttons will be treated as a standard Intellimouse,
thanks to a bug (since fixed) that caused the initialisation to fail.
I have fixed the bug that caused the problems, but have not yet re-
added the 5 button handling.

I do not have a 5-buttoned mouse to test with; nor a mouse with two
scroll wheels.