mac: Add workaround to prevent dropping keyboard input when speed=1
When running at the normal slow CPU speed and there is a lot of
keyboard input in a short amount of time, the keyboard data into the
6522 doesn't seem to be written in or read out properly which causes
the OS to figure the keyboard is no longer responding to its Inquiry
commands, so it sends out a Model request which the PCE keyboard
driver handles by flushing out its buffer of keys queued up.
Work around this by tracking the last time data was sent to the 6522
and waiting a very short while before shifting another byte (either
keyboard data or an inquiry response) into it. This ensures that
every keyboard response can be properly read by the OS so it resets
its inquiry timeout watchdog.
A proper way to do this is probably to know when the data was
properly read out of the 6522 and make it available again, rather
than just relying on a timer.
From http://www.mac.linux-m68k.org/devel/plushw.php:
The first command the Macintosh sends out is the Model Number
command. The keyboard's response to this command is to reset
itself and send back its model number to the Macintosh. If no
response is received for 1/2 second, the Macintosh tries the
Model Number command again. Once the Macintosh has successfully
received a model number from the keyboard, normal operation can
begin. The Macintosh sends the Inquiry command; the keyboard
sends back a Key Transition response if a key has been pressed
or released. If no key transition has occurred after 1/4
second, the keyboard sends back a Null response to let the
Macintosh know it's still there. The Macintosh then sends the
Inquiry command again. In normal operation, the Macintosh sends
out an Inquiry command every 1/4 second. If it receives no
response within 1/2 second, it assumes the keyboard is missing
or needs resetting, so it begins again with the Model Number
command.