]> git.friedersdorff.com Git - max/tmk_keyboard.git/blobdiff - converter/ibmpc_usb/ibmpc_usb.c
ibmpc_usb: Fix led_set
[max/tmk_keyboard.git] / converter / ibmpc_usb / ibmpc_usb.c
index 4267c21128bfb6e63d66c66e47e3292dd96a662c..52fffc3d245acb1714db9633a6466e1c5aa3a2e7 100644 (file)
@@ -105,6 +105,7 @@ void matrix_init(void)
  *      d. ID is BF BF: Terminal keyboard CodeSet3
  *      e. error on recv: maybe broken PS/2
  */
+uint8_t current_protocol = 0;
 uint16_t keyboard_id = 0x0000;
 keyboard_kind_t keyboard_kind = NONE;
 uint8_t matrix_scan(void)
@@ -141,6 +142,18 @@ uint8_t matrix_scan(void)
         ibmpc_error = IBMPC_ERR_NONE;
     }
 
+    // check ISR state debug
+    if (ibmpc_isr_debug) {
+        xprintf("\nISR:%04X\n", ibmpc_isr_debug);
+        ibmpc_isr_debug = 0;
+    }
+
+    // check protocol AT/XT
+    if (ibmpc_protocol != current_protocol) {
+        xprintf("\nPROTO:%02X\n", ibmpc_protocol);
+        current_protocol = ibmpc_protocol;
+    }
+
     switch (state) {
         case INIT:
             xprintf("I%u ", timer_read());
@@ -241,9 +254,11 @@ uint8_t matrix_scan(void)
                 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
+            } else if (0xAB86 == keyboard_id ||
+                       0xAB85 == keyboard_id) {     // For G80-2551 and other 122-key terminal
                 // https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#ab86
+                // https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#ab85
+
                 if ((0xFA == ibmpc_host_send(0xF0)) &&
                     (0xFA == ibmpc_host_send(0x03))) {
                     // switch to code set 3
@@ -252,6 +267,11 @@ uint8_t matrix_scan(void)
                     keyboard_kind = PC_AT;
                 }
 #endif
+            } else if (0xBFB0 == keyboard_id) {     // IBM RT Keyboard
+                // https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#bfb0
+                // TODO: LED indicator fix
+                //keyboard_kind = PC_TERMINAL_IBM_RT;
+                keyboard_kind = PC_TERMINAL;
             } else if (0xAB00 == (keyboard_id & 0xFF00)) {  // CodeSet2 PS/2
                 keyboard_kind = PC_AT;
             } else if (0xBF00 == (keyboard_id & 0xFF00)) {  // CodeSet3 Terminal
@@ -347,6 +367,7 @@ void matrix_clear(void)
 
 void led_set(uint8_t usb_led)
 {
+    if (keyboard_kind == NONE) return;
     //if (keyboard_kind != PC_AT) return;
 
     uint8_t ibmpc_led = 0;
@@ -625,12 +646,12 @@ static uint8_t cs2_e0code(uint8_t code) {
         case 0x75: return 0x4F; // cursor up
         case 0x7A: return 0x56; // page down
         case 0x7D: return 0x5E; // page up
-        case 0x7C: return 0x6F; // Print Screen
+        case 0x7C: return 0x7F; // Print Screen
         case 0x7E: return 0x00; // Control'd Pause
 
         case 0x21: return 0x65; // volume down
         case 0x32: return 0x6E; // volume up
-        case 0x23: return 0x7F; // mute
+        case 0x23: return 0x6F; // mute
         case 0x10: return 0x08; // (WWW search)     -> F13
         case 0x18: return 0x10; // (WWW favourites) -> F14
         case 0x20: return 0x18; // (WWW refresh)    -> F15
@@ -711,7 +732,7 @@ static int8_t process_cs2(void)
                     state = INIT;
                     break;
                 case 0x84:  // Alt'd PrintScreen
-                    matrix_make(0x6F);
+                    matrix_make(0x7F);
                     state = INIT;
                     break;
                 case 0xAA:  // Self-test passed
@@ -758,7 +779,7 @@ static int8_t process_cs2(void)
                     state = INIT;
                     break;
                 case 0x84:  // Alt'd PrintScreen
-                    matrix_break(0x6F);
+                    matrix_break(0x7F);
                     state = INIT;
                     break;
                 default:
@@ -850,9 +871,8 @@ static int8_t process_cs2(void)
 /*
  * Terminal: Scan Code Set 3
  *
- * See [3], [7]
- *
- * Scan code 0x83 and 0x84 are handled exceptioanally to fit into 1-byte range index.
+ * See [3], [7] and
+ * https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#scan-code-set-3
  */
 static int8_t process_cs3(void)
 {