diff --git a/keyboards/converter/ibmpc_usb/atmega32u2_atmel_dfu/ibmpc.h b/keyboards/converter/ibmpc_usb/atmega32u2_atmel_dfu/ibmpc.h index e3de5018803..82fe5eb3a30 100644 --- a/keyboards/converter/ibmpc_usb/atmega32u2_atmel_dfu/ibmpc.h +++ b/keyboards/converter/ibmpc_usb/atmega32u2_atmel_dfu/ibmpc.h @@ -108,7 +108,6 @@ int16_t ibmpc_host_send(uint8_t data); int16_t ibmpc_host_recv_response(void); int16_t ibmpc_host_recv(void); void ibmpc_host_isr_clear(void); -void ibmpc_host_set_led(uint8_t usb_led); /*-------------------------------------------------------------------- diff --git a/keyboards/converter/ibmpc_usb/atmega32u2_usbasploader/ibmpc.h b/keyboards/converter/ibmpc_usb/atmega32u2_usbasploader/ibmpc.h index e3de5018803..82fe5eb3a30 100644 --- a/keyboards/converter/ibmpc_usb/atmega32u2_usbasploader/ibmpc.h +++ b/keyboards/converter/ibmpc_usb/atmega32u2_usbasploader/ibmpc.h @@ -108,7 +108,6 @@ int16_t ibmpc_host_send(uint8_t data); int16_t ibmpc_host_recv_response(void); int16_t ibmpc_host_recv(void); void ibmpc_host_isr_clear(void); -void ibmpc_host_set_led(uint8_t usb_led); /*-------------------------------------------------------------------- diff --git a/keyboards/converter/ibmpc_usb/atmega32u4_atmel_dfu/ibmpc.h b/keyboards/converter/ibmpc_usb/atmega32u4_atmel_dfu/ibmpc.h index e3de5018803..82fe5eb3a30 100644 --- a/keyboards/converter/ibmpc_usb/atmega32u4_atmel_dfu/ibmpc.h +++ b/keyboards/converter/ibmpc_usb/atmega32u4_atmel_dfu/ibmpc.h @@ -108,7 +108,6 @@ int16_t ibmpc_host_send(uint8_t data); int16_t ibmpc_host_recv_response(void); int16_t ibmpc_host_recv(void); void ibmpc_host_isr_clear(void); -void ibmpc_host_set_led(uint8_t usb_led); /*-------------------------------------------------------------------- diff --git a/keyboards/converter/ibmpc_usb/atmega32u4_bootloadhid/ibmpc.h b/keyboards/converter/ibmpc_usb/atmega32u4_bootloadhid/ibmpc.h index e3de5018803..82fe5eb3a30 100644 --- a/keyboards/converter/ibmpc_usb/atmega32u4_bootloadhid/ibmpc.h +++ b/keyboards/converter/ibmpc_usb/atmega32u4_bootloadhid/ibmpc.h @@ -108,7 +108,6 @@ int16_t ibmpc_host_send(uint8_t data); int16_t ibmpc_host_recv_response(void); int16_t ibmpc_host_recv(void); void ibmpc_host_isr_clear(void); -void ibmpc_host_set_led(uint8_t usb_led); /*-------------------------------------------------------------------- diff --git a/keyboards/converter/ibmpc_usb/atmega32u4_caterina/ibmpc.h b/keyboards/converter/ibmpc_usb/atmega32u4_caterina/ibmpc.h index e3de5018803..82fe5eb3a30 100644 --- a/keyboards/converter/ibmpc_usb/atmega32u4_caterina/ibmpc.h +++ b/keyboards/converter/ibmpc_usb/atmega32u4_caterina/ibmpc.h @@ -108,7 +108,6 @@ int16_t ibmpc_host_send(uint8_t data); int16_t ibmpc_host_recv_response(void); int16_t ibmpc_host_recv(void); void ibmpc_host_isr_clear(void); -void ibmpc_host_set_led(uint8_t usb_led); /*-------------------------------------------------------------------- diff --git a/keyboards/converter/ibmpc_usb/atmega32u4_halfkay/ibmpc.h b/keyboards/converter/ibmpc_usb/atmega32u4_halfkay/ibmpc.h index e3de5018803..82fe5eb3a30 100644 --- a/keyboards/converter/ibmpc_usb/atmega32u4_halfkay/ibmpc.h +++ b/keyboards/converter/ibmpc_usb/atmega32u4_halfkay/ibmpc.h @@ -108,7 +108,6 @@ int16_t ibmpc_host_send(uint8_t data); int16_t ibmpc_host_recv_response(void); int16_t ibmpc_host_recv(void); void ibmpc_host_isr_clear(void); -void ibmpc_host_set_led(uint8_t usb_led); /*-------------------------------------------------------------------- diff --git a/keyboards/converter/ibmpc_usb/atmega32u4_qmk_dfu/ibmpc.h b/keyboards/converter/ibmpc_usb/atmega32u4_qmk_dfu/ibmpc.h index e3de5018803..82fe5eb3a30 100644 --- a/keyboards/converter/ibmpc_usb/atmega32u4_qmk_dfu/ibmpc.h +++ b/keyboards/converter/ibmpc_usb/atmega32u4_qmk_dfu/ibmpc.h @@ -108,7 +108,6 @@ int16_t ibmpc_host_send(uint8_t data); int16_t ibmpc_host_recv_response(void); int16_t ibmpc_host_recv(void); void ibmpc_host_isr_clear(void); -void ibmpc_host_set_led(uint8_t usb_led); /*-------------------------------------------------------------------- diff --git a/keyboards/converter/ibmpc_usb/atmega32u4_qmk_hid/ibmpc.h b/keyboards/converter/ibmpc_usb/atmega32u4_qmk_hid/ibmpc.h index e3de5018803..82fe5eb3a30 100644 --- a/keyboards/converter/ibmpc_usb/atmega32u4_qmk_hid/ibmpc.h +++ b/keyboards/converter/ibmpc_usb/atmega32u4_qmk_hid/ibmpc.h @@ -108,7 +108,6 @@ int16_t ibmpc_host_send(uint8_t data); int16_t ibmpc_host_recv_response(void); int16_t ibmpc_host_recv(void); void ibmpc_host_isr_clear(void); -void ibmpc_host_set_led(uint8_t usb_led); /*-------------------------------------------------------------------- diff --git a/keyboards/converter/ibmpc_usb/atmega32u4_usbasploader/ibmpc.h b/keyboards/converter/ibmpc_usb/atmega32u4_usbasploader/ibmpc.h index e3de5018803..82fe5eb3a30 100644 --- a/keyboards/converter/ibmpc_usb/atmega32u4_usbasploader/ibmpc.h +++ b/keyboards/converter/ibmpc_usb/atmega32u4_usbasploader/ibmpc.h @@ -108,7 +108,6 @@ int16_t ibmpc_host_send(uint8_t data); int16_t ibmpc_host_recv_response(void); int16_t ibmpc_host_recv(void); void ibmpc_host_isr_clear(void); -void ibmpc_host_set_led(uint8_t usb_led); /*-------------------------------------------------------------------- diff --git a/keyboards/converter/ibmpc_usb/config.h b/keyboards/converter/ibmpc_usb/config.h index a783b190c95..d126a988c23 100644 --- a/keyboards/converter/ibmpc_usb/config.h +++ b/keyboards/converter/ibmpc_usb/config.h @@ -22,8 +22,7 @@ along with this program. If not, see . #define PRODUCT_ID 0x6536 #define DEVICE_VER 0x0101 #define MANUFACTURER QMK -#define PRODUCT Legacy Keyboard Convert -#define DESCRIPTION convert IBM PC keyboard to USB +#define PRODUCT IBM keyboard protocol converter /* matrix size */ #define MATRIX_ROWS 8 diff --git a/keyboards/converter/ibmpc_usb/ibmpc.c b/keyboards/converter/ibmpc_usb/ibmpc.c index 85af51f6adc..37c5415901f 100644 --- a/keyboards/converter/ibmpc_usb/ibmpc.c +++ b/keyboards/converter/ibmpc_usb/ibmpc.c @@ -1,5 +1,6 @@ /* -Copyright 2010,2011,2012,2013,2019 Jun WAKO +Copyright 2010,2011,2012,2013,2019 Jun WAKO , +2023 an_achronism <87213873+an-achronism@users.noreply.github.com> This software is licensed with a Modified BSD License. All of this is supposed to be Free Software, Open Source, DFSG-free, @@ -418,11 +419,3 @@ ISR(IBMPC_INT_VECT) { ibmpc_interrupt_service_routine(); } void ibmpc_interrupt_service_routine(void); void palCallback(void *arg) { ibmpc_interrupt_service_routine(); } #endif - -/* send LED state to keyboard */ -void ibmpc_host_set_led(uint8_t led) -{ - if (0xFA == ibmpc_host_send(0xED)) { - ibmpc_host_send(led); - } -} diff --git a/keyboards/converter/ibmpc_usb/info.json b/keyboards/converter/ibmpc_usb/info.json index 4eb107c8c10..8656daa3fac 100644 --- a/keyboards/converter/ibmpc_usb/info.json +++ b/keyboards/converter/ibmpc_usb/info.json @@ -1,10 +1,144 @@ { - "keyboard_name": "converter/ibmpc_usb", - "url": "", - "maintainer": "qmk", + "keyboard_name": "IBM keyboard protocol converter", + "url": "https://github.com/purdeaandrei/vial-qmk-with-ibmpc-usb-converter", + "maintainer": "purdeaandrei", "layouts": { "LAYOUT": { - "layout": [{"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6, "y":0}, {"x":7, "y":0}, {"x":8, "y":0}, {"x":9, "y":0}, {"x":10, "y":0}, {"x":11, "y":0}, {"x":12, "y":0}, {"x":13, "y":0}, {"x":0, "y":1}, {"x":2, "y":1}, {"x":3, "y":1}, {"x":4, "y":1}, {"x":5, "y":1}, {"x":6, "y":1}, {"x":7, "y":1}, {"x":8, "y":1}, {"x":9, "y":1}, {"x":10, "y":1}, {"x":11, "y":1}, {"x":12, "y":1}, {"x":13, "y":1}, {"x":15.25, "y":1}, {"x":16.25, "y":1}, {"x":17.25, "y":1}, {"x":19.5, "y":1}, {"x":20.5, "y":1}, {"x":21.5, "y":1}, {"x":0, "y":2.5}, {"x":1, "y":2.5}, {"x":2, "y":2.5}, {"x":3, "y":2.5}, {"x":4, "y":2.5}, {"x":5, "y":2.5}, {"x":6, "y":2.5}, {"x":7, "y":2.5}, {"x":8, "y":2.5}, {"x":9, "y":2.5}, {"x":10, "y":2.5}, {"x":11, "y":2.5}, {"x":12, "y":2.5}, {"x":13, "y":2.5}, {"x":14, "y":2.5}, {"x":15.25, "y":2.5}, {"x":16.25, "y":2.5}, {"x":17.25, "y":2.5}, {"x":18.5, "y":2.5}, {"x":19.5, "y":2.5}, {"x":20.5, "y":2.5}, {"x":21.5, "y":2.5}, {"x":0, "y":3.5, "w":1.5}, {"x":1.5, "y":3.5}, {"x":2.5, "y":3.5}, {"x":3.5, "y":3.5}, {"x":4.5, "y":3.5}, {"x":5.5, "y":3.5}, {"x":6.5, "y":3.5}, {"x":7.5, "y":3.5}, {"x":8.5, "y":3.5}, {"x":9.5, "y":3.5}, {"x":10.5, "y":3.5}, {"x":11.5, "y":3.5}, {"x":12.5, "y":3.5}, {"x":13.5, "y":3.5, "w":1.5}, {"x":15.25, "y":3.5}, {"x":16.25, "y":3.5}, {"x":17.25, "y":3.5}, {"x":18.5, "y":3.5}, {"x":19.5, "y":3.5}, {"x":20.5, "y":3.5}, {"x":21.5, "y":3.5}, {"x":0, "y":4.5, "w":1.75}, {"x":1.75, "y":4.5}, {"x":2.75, "y":4.5}, {"x":3.75, "y":4.5}, {"x":4.75, "y":4.5}, {"x":5.75, "y":4.5}, {"x":6.75, "y":4.5}, {"x":7.75, "y":4.5}, {"x":8.75, "y":4.5}, {"x":9.75, "y":4.5}, {"x":10.75, "y":4.5}, {"x":11.75, "y":4.5}, {"x":12.75, "y":4.5}, {"x":13.75, "y":4.5, "w":1.25}, {"x":18.5, "y":4.5}, {"x":19.5, "y":4.5}, {"x":20.5, "y":4.5}, {"x":21.5, "y":4.5}, {"x":0, "y":5.5, "w":1.25}, {"x":1.25, "y":5.5}, {"x":2.25, "y":5.5}, {"x":3.25, "y":5.5}, {"x":4.25, "y":5.5}, {"x":5.25, "y":5.5}, {"x":6.25, "y":5.5}, {"x":7.25, "y":5.5}, {"x":8.25, "y":5.5}, {"x":9.25, "y":5.5}, {"x":10.25, "y":5.5}, {"x":11.25, "y":5.5}, {"x":12.25, "y":5.5}, {"x":13.25, "y":5.5, "w":1.75}, {"x":16.25, "y":5.5}, {"x":18.5, "y":5.5}, {"x":19.5, "y":5.5}, {"x":20.5, "y":5.5}, {"x":21.5, "y":5.5}, {"x":0, "y":6.5, "w":1.25}, {"x":1.25, "y":6.5, "w":1.25}, {"x":2.5, "y":6.5, "w":1.25}, {"x":3.75, "y":6.5, "w":1.25}, {"x":5, "y":6.5, "w":2.5}, {"x":7.5, "y":6.5, "w":1.25}, {"x":8.75, "y":6.5, "w":1.25}, {"x":10, "y":6.5, "w":1.25}, {"x":11.25, "y":6.5, "w":1.25}, {"x":12.5, "y":6.5, "w":1.25}, {"x":13.75, "y":6.5, "w":1.25}, {"x":15.25, "y":6.5}, {"x":16.25, "y":6.5}, {"x":17.25, "y":6.5}, {"x":18.5, "y":6.5, "w":2}, {"x":20.5, "y":6.5}, {"x":21.5, "y":6.5}] + "layout": [ + {"x":2, "y":0, "label":"F13"}, + {"x":3, "y":0, "label":"F14"}, + {"x":4, "y":0, "label":"F15"}, + {"x":5, "y":0, "label":"F16"}, + {"x":6, "y":0, "label":"F17"}, + {"x":7, "y":0, "label":"F18"}, + {"x":8, "y":0, "label":"F19"}, + {"x":9, "y":0, "label":"F20"}, + {"x":10, "y":0, "label":"F21"}, + {"x":11, "y":0, "label":"F22"}, + {"x":12, "y":0, "label":"F23"}, + {"x":13, "y":0, "label":"F24"}, + {"x":0, "y":1, "label":"Escape"}, + {"x":2, "y":1, "label":"F1"}, + {"x":3, "y":1, "label":"F2"}, + {"x":4, "y":1, "label":"F3"}, + {"x":5, "y":1, "label":"F4"}, + {"x":6, "y":1, "label":"F5"}, + {"x":7, "y":1, "label":"F6"}, + {"x":8, "y":1, "label":"F7"}, + {"x":9, "y":1, "label":"F8"}, + {"x":10, "y":1, "label":"F9"}, + {"x":11, "y":1, "label":"F10"}, + {"x":12, "y":1, "label":"F11"}, + {"x":13, "y":1, "label":"F12"}, + {"x":15.25, "y":1, "label":"Print Screen"}, + {"x":16.25, "y":1, "label":"Scroll Lock"}, + {"x":17.25, "y":1, "label":"Pause/Break"}, + {"x":19.5, "y":1, "label":"Media Volume Down"}, + {"x":20.5, "y":1, "label":"Media Volume Up"}, + {"x":21.5, "y":1, "label":"Media Mute"}, + {"x":0, "y":2.5, "label":"Grave Accent"}, + {"x":1, "y":2.5, "label":"1"}, + {"x":2, "y":2.5, "label":"2"}, + {"x":3, "y":2.5, "label":"3"}, + {"x":4, "y":2.5, "label":"4"}, + {"x":5, "y":2.5, "label":"5"}, + {"x":6, "y":2.5, "label":"6"}, + {"x":7, "y":2.5, "label":"7"}, + {"x":8, "y":2.5, "label":"8"}, + {"x":9, "y":2.5, "label":"9"}, + {"x":10, "y":2.5, "label":"0"}, + {"x":11, "y":2.5, "label":"-"}, + {"x":12, "y":2.5, "label":"="}, + {"x":13, "y":2.5, "label":"International 3 (¥)"}, + {"x":14, "y":2.5, "label":"Backspace"}, + {"x":15.25, "y":2.5, "label":"Insert"}, + {"x":16.25, "y":2.5, "label":"Home"}, + {"x":17.25, "y":2.5, "label":"Page Up"}, + {"x":18.5, "y":2.5, "label":"Num Lock"}, + {"x":19.5, "y":2.5, "label":"Keypad /"}, + {"x":20.5, "y":2.5, "label":"Keypad *"}, + {"x":21.5, "y":2.5, "label":"Keypad -"}, + {"x":0, "y":3.5, "w":1.5, "label":"Tabulator"}, + {"x":1.5, "y":3.5, "label":"Q"}, + {"x":2.5, "y":3.5, "label":"W"}, + {"x":3.5, "y":3.5, "label":"E"}, + {"x":4.5, "y":3.5, "label":"R"}, + {"x":5.5, "y":3.5, "label":"T"}, + {"x":6.5, "y":3.5, "label":"Y"}, + {"x":7.5, "y":3.5, "label":"U"}, + {"x":8.5, "y":3.5, "label":"I"}, + {"x":9.5, "y":3.5, "label":"O"}, + {"x":10.5, "y":3.5, "label":"P"}, + {"x":11.5, "y":3.5, "label":"["}, + {"x":12.5, "y":3.5, "label":"]"}, + {"x":13.5, "y":3.5, "w":1.5, "label":"ANSI \\"}, + {"x":15.25, "y":3.5, "label":"Delete"}, + {"x":16.25, "y":3.5, "label":"End"}, + {"x":17.25, "y":3.5, "label":"Page Down"}, + {"x":18.5, "y":3.5, "label":"Keypad 7"}, + {"x":19.5, "y":3.5, "label":"Keypad 8"}, + {"x":20.5, "y":3.5, "label":"Keypad 9"}, + {"x":21.5, "y":3.5, "label":"Keypad +"}, + {"x":0, "y":4.5, "w":1.75, "label":"Caps Lock"}, + {"x":1.75, "y":4.5, "label":"A"}, + {"x":2.75, "y":4.5, "label":"S"}, + {"x":3.75, "y":4.5, "label":"D"}, + {"x":4.75, "y":4.5, "label":"F"}, + {"x":5.75, "y":4.5, "label":"G"}, + {"x":6.75, "y":4.5, "label":"H"}, + {"x":7.75, "y":4.5, "label":"J"}, + {"x":8.75, "y":4.5, "label":"K"}, + {"x":9.75, "y":4.5, "label":"L"}, + {"x":10.75, "y":4.5, "label":";"}, + {"x":11.75, "y":4.5, "label":"'"}, + {"x":12.75, "y":4.5, "label":"Right ISO"}, + {"x":13.75, "y":4.5, "w":1.25, "label":"Return"}, + {"x":18.5, "y":4.5, "label":"Keypad 4"}, + {"x":19.5, "y":4.5, "label":"Keypad 5"}, + {"x":20.5, "y":4.5, "label":"Keypad 6"}, + {"x":21.5, "y":4.5, "label":"Keypad ,"}, + {"x":0, "y":5.5, "w":1.25, "label":"Left Shift"}, + {"x":1.25, "y":5.5, "label":"Left ISO"}, + {"x":2.25, "y":5.5, "label":"Z"}, + {"x":3.25, "y":5.5, "label":"X"}, + {"x":4.25, "y":5.5, "label":"C"}, + {"x":5.25, "y":5.5, "label":"V"}, + {"x":6.25, "y":5.5, "label":"B"}, + {"x":7.25, "y":5.5, "label":"N"}, + {"x":8.25, "y":5.5, "label":"M"}, + {"x":9.25, "y":5.5, "label":","}, + {"x":10.25, "y":5.5, "label":"."}, + {"x":11.25, "y":5.5, "label":"/"}, + {"x":12.25, "y":5.5, "label":"International 1 (ろ)"}, + {"x":13.25, "y":5.5, "w":1.75, "label":"Right Shift"}, + {"x":16.25, "y":5.5, "label":"Up"}, + {"x":18.5, "y":5.5, "label":"Keypad 1"}, + {"x":19.5, "y":5.5, "label":"Keypad 2"}, + {"x":20.5, "y":5.5, "label":"Keypad 3"}, + {"x":21.5, "y":5.5, "label":"Keypad Enter"}, + {"x":0, "y":6.5, "w":1.25, "label":"Left Control"}, + {"x":1.25, "y":6.5, "w":1.25, "label":"Left GUI"}, + {"x":2.5, "y":6.5, "w":1.25, "label":"Left Alternate"}, + {"x":3.75, "y":6.5, "w":1.25, "label":"International 5 (Muhenkan)"}, + {"x":5, "y":6.5, "w":2.5, "label":"Space"}, + {"x":7.5, "y":6.5, "w":1.25, "label":"International 4 (Henkan)"}, + {"x":8.75, "y":6.5, "w":1.25, "label":"International 2 (Kana)"}, + {"x":10, "y":6.5, "w":1.25, "label":"Right Alternate"}, + {"x":11.25, "y":6.5, "w":1.25, "label":"Right GUI"}, + {"x":12.5, "y":6.5, "w":1.25, "label":"Application / Function Layer"}, + {"x":13.75, "y":6.5, "w":1.25, "label":"Right Control"}, + {"x":15.25, "y":6.5, "label":"Left"}, + {"x":16.25, "y":6.5, "label":"Down"}, + {"x":17.25, "y":6.5, "label":"Right"}, + {"x":18.5, "y":6.5, "w":2, "label":"Keypad 0"}, + {"x":20.5, "y":6.5, "label":"Keypad ."}, + {"x":21.5, "y":6.5, "label":"Keypad Enter"} + ] } + }, + "indicators": { + "caps_lock": "F5", + "num_lock": "F6", + "scroll_lock": "F7" } } diff --git a/keyboards/converter/ibmpc_usb/matrix.c b/keyboards/converter/ibmpc_usb/matrix.c index 354e253558d..951439d114d 100644 --- a/keyboards/converter/ibmpc_usb/matrix.c +++ b/keyboards/converter/ibmpc_usb/matrix.c @@ -1,6 +1,7 @@ /* Copyright 2011 Jun Wako , -2021 Markus Fritsche +2021 Markus Fritsche , +2023 an_achronism <87213873+an-achronism@users.noreply.github.com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,6 +25,7 @@ along with this program. If not, see . #include "ibmpc_usb.h" #include "ibmpc.h" #include "matrix.h" +#include "led.h" #define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) #define print_matrix_header() print("\nr/c 01234567\n") @@ -364,15 +366,12 @@ uint8_t matrix_scan(void) case SETUP: xprintf("S%u ", timer_read()); switch (keyboard_kind) { - case PC_XT: - break; + case PC_XT: // "XT" protocol boards now protected by led_set() case PC_AT: led_set(host_keyboard_leds()); break; case PC_TERMINAL: - // Set all keys to make/break type - ibmpc_host_send(0xF8); - // This should not be harmful + ibmpc_host_send(0xF8); // Set all keys to make/break type led_set(host_keyboard_leds()); break; default: @@ -521,51 +520,60 @@ bool matrix_has_ghost_in_row(uint8_t row) void led_set(uint8_t usb_led) { - uint8_t ibmpc_led = 0; -// if (usb_led & (1<> USB_LED_NUM_LOCK) & 1); +#endif +#ifdef LED_CAPS_LOCK_PIN + writePin(LED_CAPS_LOCK_PIN, (usb_led >> USB_LED_CAPS_LOCK) & 1); +#endif +#ifdef LED_SCROLL_LOCK_PIN + writePin(LED_SCROLL_LOCK_PIN, (usb_led >> USB_LED_SCROLL_LOCK) & 1); +#endif + /* Pointing devices and original IBM PC ("XT") protocol keyboards do not + * support receiving data signals, only sending them, so it's probably not a + * good idea to send any to them: + * https://github.com/tmk/tmk_keyboard/issues/635#issuecomment-626993437 + * + * IBM terminal boards don't have LEDs, but are capable of receiving and + * responding to incoming data. This is useful, because it means we can send + * the enquiry byte to terminal keyboards, which will facilitate updating + * the lock state LEDs on terminal keyboards that do have them, like the + * Cherry G80-2551: + * https://geekhack.org/index.php?topic=103648.msg2894921#msg2894921 + * + * The USB HID and IBM PC/AT protocols both set keyboards' lock state LEDs + * by sending a single byte in which each lock state is represented by one + * bit, but the bit order differs between protocols (see led.h and ibmpc.h). + */ + // Send lock states out to connected input device(s), if appropriate + switch (keyboard_kind) { + /* If the connected device is unidentified (temporarily or otherwise), a + * pointing device, or an "XT" protocol keyboard, do nothing */ + case NONE: + case PC_XT: + case PC_MOUSE: + break; + default: + /* If keyboard returns "ACK" acknowledgement byte (0xFA) when LED update + * enquiry byte (0xED) is sent, reorganise USB HID LED byte into IBM bit + * order and send to keyboard to update all 3 of its lock state LEDs */ + if (ibmpc_host_send(IBMPC_SET_LED) == IBMPC_ACK) { + uint8_t ibm_led = 0; + if (usb_led & (1 << USB_LED_NUM_LOCK)) { + ibm_led |= (1 << IBMPC_LED_NUM_LOCK); + } + if (usb_led & (1 << USB_LED_CAPS_LOCK)) { + ibm_led |= (1 << IBMPC_LED_CAPS_LOCK); + } + if (usb_led & (1 << USB_LED_SCROLL_LOCK)) { + ibm_led |= (1 << IBMPC_LED_SCROLL_LOCK); + } + ibmpc_host_send(ibm_led); + } + break; } - ibmpc_host_set_led(ibmpc_led); + // TODO: PC_TERMINAL_IBM_RT support } @@ -801,14 +809,23 @@ static int8_t process_cs1(uint8_t code) static uint8_t cs2_e0code(uint8_t code) { switch(code) { // E0 prefixed codes translation See [a]. - case 0x11: return 0x0F; // right alt - case 0x14: return 0x17; // right control - case 0x1F: return 0x19; // left GUI + case 0x11: if (0xAB90 == keyboard_id || 0xAB91 == keyboard_id) + return 0x13; // Hiragana(5576) -> KANA + else + return 0x0F; // right alt + + case 0x41: if (0xAB90 == keyboard_id || 0xAB91 == keyboard_id) + return 0x7C; // Keypad ,(5576) -> Keypad * + else + return (code & 0x7F); + + case 0x14: return 0x19; // right control + case 0x1F: return 0x17; // left GUI case 0x27: return 0x1F; // right GUI - case 0x2F: return 0x5C; // apps + case 0x2F: return 0x27; // apps case 0x4A: return 0x60; // keypad / case 0x5A: return 0x62; // keypad enter - case 0x69: return 0x27; // end + case 0x69: return 0x5C; // end case 0x6B: return 0x53; // cursor left case 0x6C: return 0x2F; // home case 0x70: return 0x39; // insert @@ -816,6 +833,7 @@ static uint8_t cs2_e0code(uint8_t code) { case 0x72: return 0x3F; // cursor down case 0x74: return 0x47; // cursor right case 0x75: return 0x4F; // cursor up + case 0x77: return 0x00; // Unicomp New Model M Pause/Break key fix case 0x7A: return 0x56; // page down case 0x7D: return 0x5E; // page up case 0x7C: return 0x7F; // Print Screen diff --git a/keyboards/converter/ibmpc_usb/promicro/ibmpc.h b/keyboards/converter/ibmpc_usb/promicro/ibmpc.h index e3de5018803..82fe5eb3a30 100644 --- a/keyboards/converter/ibmpc_usb/promicro/ibmpc.h +++ b/keyboards/converter/ibmpc_usb/promicro/ibmpc.h @@ -108,7 +108,6 @@ int16_t ibmpc_host_send(uint8_t data); int16_t ibmpc_host_recv_response(void); int16_t ibmpc_host_recv(void); void ibmpc_host_isr_clear(void); -void ibmpc_host_set_led(uint8_t usb_led); /*-------------------------------------------------------------------- diff --git a/keyboards/converter/ibmpc_usb/readme.md b/keyboards/converter/ibmpc_usb/readme.md index d6e71410015..e304b375322 100644 --- a/keyboards/converter/ibmpc_usb/readme.md +++ b/keyboards/converter/ibmpc_usb/readme.md @@ -1,42 +1,97 @@ -# Keyboard converter for IBM terminal keyboard +# IBM keyboard protocol converter -This is a port of TMK's converter/terminal_usb to QMK. -The ibmpc.c and ibmpc.h code has been moved from -tmk_core/protocol in TMK to the keyboard directory in -this version. +This is a QMK and Vial port of hasu's TMK IBM PC Keyboard Converter, with some +added features. You can read more about the original TMK version here: +https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-Keyboard-Converter -It supports PS/2 Scan Code Set 2 (as of now) and runs on USB AVR chips. -I tested the converter on ATMega32U4 with 1391403(102keys). +I hesitate to call this an "IBM PC" converter, though, given that the scope of +that part of TMK has grown a lot since it start, and it now incorporates +terminal keyboards as well. -To support other codesets, ibmpc_usb.h has to be extended. +The ibmpc.c and ibmpc.h code has been moved from TMK's tmk_core/protocol +directory into the appropriate "keyboard" directory in this version. -Original TMK Link/ Article: http://geekhack.org/index.php?topic=27272.0 +It runs on AVR chips; I have personally only tested the code on the ATmega32U4, +which this amount of code only just fits onto. -## Connection +## Build + +If you want to compile the Vial version without also compiling the QMK one at +the same time, move into the root director then do: +``` +make converter/ibmpc_usb:vial +``` + +## Wiring + +### Required Keyboard | ATMega32U4 :------- | :--------- -Data | PD0 / 3 -Clock | PD1 / 2 +Data | PD0 +Clock | PD1 +VCC | VCC +GND | GND -And VCC and GND, of course. See Resource section for keyboard connector pin assign. +Depending on your keyboard, your cables, and the clarity of your power source, +it may be wise to connect pull-up resistors on all of the signal lines (between +the signal line and VCC). The TMK project recommends using resistors between 1 +and 4.7 kOhms. Obviously, only do this on the signal lines; don't bridge VCC to +GND! +### Required by some "XT" protocol keyboards -## Build +Keyboard | ATMega32U4 +:------- | :--------- +Reset | PB6 or PB7 -``` -git clone https://github.com/marfrit/qmk_firmware.git -cd qmk_firmware -make converter/ibmpc_usb/promicro:default -``` +Some older IBM PC compatible keyboards will refuse to initialise unless you +wire up their Reset pin, and doing so won't harm keyboards that don't need it. -## Resource +### Optional + +Function | ATMega32U4 +:-------------- | :--------- +Secondary Data | PD2 +Secondary Clock | PD3 +Caps Lock LED | PF5 +Num Lock LED | PF6 +Scroll Lock LED | PF7 + +The secondary data/clock pair are for the PS/2 interface; for example, you could +hook up a mouse or trackball. I haven't tested this with this specific code yet +but I can tell you that if support for it is present here, it is not structured +the same way as it is in TMK (the LED functions were different in a way that +made that apparent). + +Indicator LEDs are entirely optional and support for them is only included here +for convenience when using an older IBM PC keyboard or terminal keyboard that +has no LEDs of its own. If your keyboard already has indicator LEDs on it, those +will still work fine even if you don't wire up any LEDs to the converter and/or +comment out the pin definitions for the indicators in led_pins.h. + + +## Development Path + +The initial QMK port of hasu's work with TMK, with the addition of support for +DEC VT220 layout Televideo terminal keyboards was done by Markus Fritsche: +https://github.com/marfrit/qmk_firmware/tree/ibmpc_usb_port + +This was then ported to Vial and further improved by Purdea Andrei: +https://github.com/purdeaandrei/vial-qmk-with-ibmpc-usb-converter + +My contribution so far is mostly smaller tweaks here and there, notably support +for converters with lock status indicator LEDs following the same pinout as the +original converters put together by Soarer. My own fork is currently here: +https://github.com/an-achronism/vial-qmk/tree/ibmpc_usb + + +## Additional Resources - Soarer's Converter: http://geekhack.org/index.php?topic=17458.0 -- 102keys(1392595): http://geekhack.org/index.php?topic=10737.0 -- 122keys(1390876): http://www.seasip.info/VintagePC/ibm_1390876.html -- KbdBabel: http://www.kbdbabel.org/ -- RJ45 Connector: http://www.kbdbabel.org/conn/kbd_connector_ibmterm.png -- DIN Connector: http://www.kbdbabel.org/conn/kbd_connector_ibm3179_318x_319x.png +- 102keys (1392595): http://geekhack.org/index.php?topic=10737.0 +- 122keys (1390876): http://www.seasip.info/VintagePC/ibm_1390876.html +- kbdbabel: http://www.kbdbabel.org/ +- RJ45 connector: http://www.kbdbabel.org/conn/kbd_connector_ibmterm.png +- DIN connector: http://www.kbdbabel.org/conn/kbd_connector_ibm3179_318x_319x.png - WinAVR: http://winavr.sourceforge.net/ -