tmk 2020-04-28 11:59:20 +09:00
parent 87bd991afa
commit c6786290bc

View file

@ -224,11 +224,7 @@ uint8_t matrix_scan(void)
ibmpc_error = IBMPC_ERR_NONE; ibmpc_error = IBMPC_ERR_NONE;
} }
if (0xAB00 == (keyboard_id & 0xFF00)) { // CodeSet2 PS/2 if (0x0000 == keyboard_id) { // CodeSet2 AT(IBM PC AT 84-key)
keyboard_kind = PC_AT;
} else if (0xBF00 == (keyboard_id & 0xFF00)) { // CodeSet3 Terminal
keyboard_kind = PC_TERMINAL;
} else if (0x0000 == keyboard_id) { // CodeSet2 AT
keyboard_kind = PC_AT; keyboard_kind = PC_AT;
} else if (0xFFFF == keyboard_id) { // CodeSet1 XT } else if (0xFFFF == keyboard_id) { // CodeSet1 XT
keyboard_kind = PC_XT; keyboard_kind = PC_XT;
@ -237,6 +233,22 @@ uint8_t matrix_scan(void)
} else if (0x00FF == keyboard_id) { // Mouse is not supported } else if (0x00FF == keyboard_id) { // Mouse is not supported
xprintf("Mouse: not supported\n"); xprintf("Mouse: not supported\n");
keyboard_kind = NONE; keyboard_kind = NONE;
#ifdef G80_2551_SUPPORT
} else if (0xAB86 == keyboard_id) { // CodeSet2 PS/2 Terminal
// For G80-2551 and other 122-key terminal keyboards
// https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#ab86
if ((0xFA == ibmpc_host_send(0xF0)) &&
(0xFA == ibmpc_host_send(0x03))) {
// switch to code set 3
keyboard_kind = PC_TERMINAL;
} else {
keyboard_kind = PC_AT;
}
#endif
} else if (0xAB00 == (keyboard_id & 0xFF00)) { // CodeSet2 PS/2
keyboard_kind = PC_AT;
} else if (0xBF00 == (keyboard_id & 0xFF00)) { // CodeSet3 Terminal
keyboard_kind = PC_TERMINAL;
} else { } else {
keyboard_kind = PC_AT; keyboard_kind = PC_AT;
} }
@ -327,7 +339,7 @@ void matrix_clear(void)
void led_set(uint8_t usb_led) void led_set(uint8_t usb_led)
{ {
if (keyboard_kind != PC_AT) return; //if (keyboard_kind != PC_AT) return;
uint8_t ibmpc_led = 0; uint8_t ibmpc_led = 0;
if (usb_led & (1<<USB_LED_SCROLL_LOCK)) if (usb_led & (1<<USB_LED_SCROLL_LOCK))
@ -977,6 +989,11 @@ static int8_t process_cs3(void)
static enum { static enum {
READY, READY,
F0, F0,
#ifdef G80_2551_SUPPORT
// G80-2551 four extra keys around cursor keys
G80,
G80_F0,
#endif
} state = READY; } state = READY;
uint16_t code = ibmpc_host_recv(); uint16_t code = ibmpc_host_recv();
@ -1023,6 +1040,11 @@ static int8_t process_cs3(void)
case 0x8D: // Application case 0x8D: // Application
matrix_make(0x0A); matrix_make(0x0A);
break; break;
#ifdef G80_2551_SUPPORT
case 0x80: // G80-2551 four extra keys around cursor keys
state = G80;
break;
#endif
default: // normal key make default: // normal key make
if (code < 0x80) { if (code < 0x80) {
matrix_make(code); matrix_make(code);
@ -1087,6 +1109,58 @@ static int8_t process_cs3(void)
} }
} }
break; break;
#ifdef G80_2551_SUPPORT
/*
* G80-2551 terminal keyboard support
* https://deskthority.net/wiki/Cherry_G80-2551
* https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#g80-2551-in-code-set-3
*/
case G80: // G80-2551 four extra keys around cursor keys
switch (code) {
case (0x26): // TD= -> JYEN
matrix_make(0x5D);
break;
case (0x25): // page with edge -> NUHS
matrix_make(0x53);
break;
case (0x16): // two pages -> RO
matrix_make(0x51);
break;
case (0x1E): // calc -> KANA
matrix_make(0x00);
break;
case (0xF0):
state = G80_F0;
return 0;
default:
// Not supported
matrix_clear();
break;
}
state = READY;
break;
case G80_F0:
switch (code) {
case (0x26): // TD= -> JYEN
matrix_break(0x5D);
break;
case (0x25): // page with edge -> NUHS
matrix_break(0x53);
break;
case (0x16): // two pages -> RO
matrix_break(0x51);
break;
case (0x1E): // calc -> KANA
matrix_break(0x00);
break;
default:
// Not supported
matrix_clear();
break;
}
state = READY;
break;
#endif
} }
return 0; return 0;
} }