fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

+9 -1
+8 -1
src/arch/macplus/keyboard.c
··· 26 26 #include <stdlib.h> 27 27 28 28 #include <lib/log.h> 29 + #include <lib/sysdep.h> 29 30 30 31 #include <drivers/video/keys.h> 31 32 ··· 386 387 void mac_kbd_set_data_out (mac_kbd_t *kbd, unsigned char val) 387 388 { 388 389 if (kbd->set_data != NULL) { 390 + pce_get_interval_us (&kbd->last_data_set); 389 391 kbd->set_data (kbd->set_data_ext, val); 390 392 } 391 393 } ··· 468 470 void mac_kbd_set_uint8 (mac_kbd_t *kbd, unsigned char val) 469 471 { 470 472 switch (val) { 471 - case 0x10: /* inquiry */ 473 + case 0x10: /* inquiry, must be acked within 0.5 seconds */ 472 474 kbd->timeout = MAC_CPU_CLOCK / 4; 473 475 kbd->send_byte = 1; 474 476 break; ··· 503 505 void mac_kbd_clock (mac_kbd_t *kbd, unsigned cnt) 504 506 { 505 507 unsigned char val; 508 + unsigned long now_us; 506 509 507 510 if (kbd->data == 0) { 508 511 return; ··· 511 514 if (kbd->send_byte == 0) { 512 515 return; 513 516 } 517 + 518 + pce_get_interval_us (&now_us); 519 + if (now_us - kbd->last_data_set < 1000) 520 + return; 514 521 515 522 if (kbd->buf_n > 0) { 516 523 val = kbd->buf[kbd->buf_i];
+1
src/arch/macplus/keyboard.h
··· 48 48 49 49 unsigned char data; 50 50 unsigned long timeout; 51 + unsigned long last_data_set; 51 52 52 53 int send_byte; 53 54