ibmpc_usb: Remove clear_keyboard() from INIT state

to avoid unnecessary empty keyboard report at startup.
This commit is contained in:
tmk 2021-06-24 20:46:40 +09:00
parent 3c1700ee4e
commit 0b19a95ff4

View file

@ -131,6 +131,7 @@ uint8_t matrix_scan(void)
READ_ID, READ_ID,
SETUP, SETUP,
LOOP, LOOP,
ERROR,
} state = INIT; } state = INIT;
static uint16_t init_time; static uint16_t init_time;
@ -152,7 +153,7 @@ uint8_t matrix_scan(void)
// keyboard init again // keyboard init again
if (state == LOOP) { if (state == LOOP) {
xprintf("[RST] "); xprintf("[RST] ");
state = INIT; state = ERROR;
} }
} }
@ -172,7 +173,7 @@ uint8_t matrix_scan(void)
((current_protocol&IBMPC_PROTOCOL_AT) && (ibmpc_protocol&IBMPC_PROTOCOL_XT))) { ((current_protocol&IBMPC_PROTOCOL_AT) && (ibmpc_protocol&IBMPC_PROTOCOL_XT))) {
if (state == LOOP) { if (state == LOOP) {
xprintf("[CHG] "); xprintf("[CHG] ");
state = INIT; state = ERROR;
} }
} }
@ -188,7 +189,6 @@ uint8_t matrix_scan(void)
current_protocol = 0; current_protocol = 0;
matrix_clear(); matrix_clear();
clear_keyboard();
init_time = timer_read(); init_time = timer_read();
state = WAIT_SETTLE; state = WAIT_SETTLE;
@ -473,13 +473,13 @@ MOUSE_DONE:
switch (keyboard_kind) { switch (keyboard_kind) {
case PC_XT: case PC_XT:
if (process_cs1(code) == -1) state = INIT; if (process_cs1(code) == -1) state = ERROR;
break; break;
case PC_AT: case PC_AT:
if (process_cs2(code) == -1) state = INIT; if (process_cs2(code) == -1) state = ERROR;
break; break;
case PC_TERMINAL: case PC_TERMINAL:
if (process_cs3(code) == -1) state = INIT; if (process_cs3(code) == -1) state = ERROR;
break; break;
#ifdef IBMPC_MOUSE_ENABLE #ifdef IBMPC_MOUSE_ENABLE
case PC_MOUSE: { case PC_MOUSE: {
@ -593,6 +593,11 @@ MOUSE_DONE:
} }
} }
break; break;
case ERROR:
// something goes wrong
clear_keyboard();
state = INIT;
break;
default: default:
break; break;
} }