From: tmk Date: Tue, 28 Apr 2020 02:59:20 +0000 (+0900) Subject: ibmpc_usb: Add G80-2551 support in Code Set 3 X-Git-Url: https://git.friedersdorff.com/?a=commitdiff_plain;h=c6786290bcfebfbd39a17860f5d820523ec7ce09;p=max%2Ftmk_keyboard.git ibmpc_usb: Add G80-2551 support in Code Set 3 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 https://geekhack.org/index.php?topic=103648.msg2894921#msg2894921 --- diff --git a/converter/ibmpc_usb/ibmpc_usb.c b/converter/ibmpc_usb/ibmpc_usb.c index 17bdba83..c85e7646 100644 --- a/converter/ibmpc_usb/ibmpc_usb.c +++ b/converter/ibmpc_usb/ibmpc_usb.c @@ -224,19 +224,31 @@ uint8_t matrix_scan(void) 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; - } else if (0xFFFF == keyboard_id) { // CodeSet1 XT + } else if (0xFFFF == keyboard_id) { // CodeSet1 XT keyboard_kind = PC_XT; - } else if (0xFFFE == keyboard_id) { // CodeSet2 PS/2 fails to response? + } else if (0xFFFE == keyboard_id) { // CodeSet2 PS/2 fails to response? keyboard_kind = PC_AT; - } else if (0x00FF == keyboard_id) { // Mouse is not supported + } else if (0x00FF == keyboard_id) { // Mouse is not supported xprintf("Mouse: not supported\n"); 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 { keyboard_kind = PC_AT; } @@ -327,7 +339,7 @@ void matrix_clear(void) void led_set(uint8_t usb_led) { - if (keyboard_kind != PC_AT) return; + //if (keyboard_kind != PC_AT) return; uint8_t ibmpc_led = 0; if (usb_led & (1< 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; }