ibmpc_usb: Fix keyboard reset sequence

Wait 3 sec for keyboard to be settled or until keyboard sends anything

Fix for BTC-5161 AT/XT auto-select: The keyboard requires reset to
start AT mode even if it already sends AA.
https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#btc-5161
This commit is contained in:
tmk 2021-02-03 12:46:05 +09:00
parent 64a3159391
commit 7d9e554a8d

View file

@ -169,8 +169,6 @@ uint8_t matrix_scan(void)
switch (state) {
case INIT:
ibmpc_host_disable();
xprintf("I%u ", timer_read());
keyboard_kind = NONE;
keyboard_id = 0x0000;
@ -183,17 +181,20 @@ uint8_t matrix_scan(void)
state = WAIT_SETTLE;
break;
case WAIT_SETTLE:
// Reset when keyboad sends something
if (ibmpc_host_recv() != -1) {
state = AT_RESET;
}
// wait for keyboard to settle after plugin
if (timer_elapsed(init_time) > 1000) {
if (timer_elapsed(init_time) > 3000) {
state = AT_RESET;
}
break;
case AT_RESET:
ibmpc_host_isr_clear();
ibmpc_host_enable();
wait_ms(1); // keyboard can't respond to command without this
xprintf("A%u ", timer_read());
// SKIDATA-2-DE(and some other keyboards?) stores 'Code Set' setting in nonvlatile memory
// SKIDATA-2-DE(and some other keyboards?) stores 'Code Set' setting in nonvolatile memory
// and keeps it until receiving reset. Sending reset here may be useful to clear it, perhaps.
// https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#select-alternate-scan-codesf0
@ -203,7 +204,6 @@ uint8_t matrix_scan(void)
} else {
state = XT_RESET;
}
xprintf("A%u ", timer_read());
break;
case XT_RESET:
// Reset XT-initialize keyboard