ibmpc_usb: AT/XT Auto-Switching keyboard support
Prefer selecting AT protocool to XT Send resend command 'FE' to keyboard that starts with 'AA' including parity error https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-Keyboard-Converter#atxt-auto-switching
This commit is contained in:
parent
eea8b36f0d
commit
16ff313820
2 changed files with 27 additions and 10 deletions
|
|
@ -171,11 +171,15 @@ uint8_t IBMPCConverter::process_interface(void)
|
|||
|
||||
// when recv error, neither send error nor buffer full
|
||||
if (!(ibmpc.error & (IBMPC_ERR_SEND | IBMPC_ERR_FULL))) {
|
||||
// keyboard init again
|
||||
if (state == LOOP) {
|
||||
xprintf("[RST] ");
|
||||
// Reset
|
||||
state = ERROR;
|
||||
}
|
||||
if (ibmpc.error == IBMPC_ERR_PARITY_AA) {
|
||||
// AT/XT Auto-Switching support
|
||||
// https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-Keyboard-Converter#atxt-auto-switching
|
||||
state = ERROR_PARITY_AA;
|
||||
}
|
||||
}
|
||||
|
||||
// clear or process error
|
||||
|
|
@ -205,15 +209,9 @@ uint8_t IBMPCConverter::process_interface(void)
|
|||
switch (state) {
|
||||
case INIT:
|
||||
xprintf("I%u ", timer_read());
|
||||
keyboard_kind = NONE;
|
||||
keyboard_id = 0x0000;
|
||||
current_protocol = 0;
|
||||
|
||||
matrix_clear();
|
||||
|
||||
init_time = timer_read();
|
||||
state = WAIT_SETTLE;
|
||||
ibmpc.host_enable();
|
||||
state = WAIT_SETTLE;
|
||||
break;
|
||||
case WAIT_SETTLE:
|
||||
while (ibmpc.host_recv() != -1) ; // read data
|
||||
|
|
@ -606,8 +604,22 @@ MOUSE_DONE:
|
|||
}
|
||||
}
|
||||
break;
|
||||
case ERROR_PARITY_AA:
|
||||
{
|
||||
xprintf("P%u ", timer_read());
|
||||
// AT/XT Auto-Switching support: Send Resend command to select AT
|
||||
uint16_t code = ibmpc.host_send(0xFE);
|
||||
if (0xAA == code) {
|
||||
state = READ_ID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// FALL THROUGH
|
||||
case ERROR:
|
||||
// something goes wrong
|
||||
xprintf("E%u ", timer_read());
|
||||
// reinit state
|
||||
init();
|
||||
matrix_clear();
|
||||
clear_keyboard();
|
||||
state = INIT;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ class IBMPCConverter {
|
|||
}
|
||||
|
||||
void init(void) {
|
||||
keyboard_id = 0x0000;
|
||||
keyboard_kind = NONE;
|
||||
current_protocol = 0;
|
||||
matrix_clear();
|
||||
ibmpc.host_init();
|
||||
}
|
||||
|
||||
|
|
@ -64,6 +68,7 @@ class IBMPCConverter {
|
|||
SETUP,
|
||||
LOOP,
|
||||
ERROR,
|
||||
ERROR_PARITY_AA,
|
||||
} state = INIT;
|
||||
|
||||
enum CS1_state {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue