Added Ctrl-key combination support on Unix
authorRobert Pengelly <robertapengelly@hotmail.com>
Tue, 20 Oct 2026 20:50:00 +0000 (21:50 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Tue, 20 Oct 2026 20:50:00 +0000 (21:50 +0100)
interrupts.c

index 755cde7d195251d04647aa2594f33ffea10cf660..44bf77aeed804bee78ecf2278b1b86a81206c89f 100644 (file)
@@ -1319,12 +1319,53 @@ static int host_function_scan (int scan, unsigned modifier) {
             return scan + 6;
         }
     
+    } else if (modifier == 5) {
+    
+        if (scan >= 0x3B && scan <= 0x44) {
+            return scan + 0x23;
+        }
+        
+        if (scan == 0x85 || scan == 0x86) {
+            return scan + 4;
+        }
+        
+        switch (scan) {
+        
+            case 0x47: return 0x77;     /* Ctrl+Home */
+            case 0x48: return 0x8D;     /* Ctrl+Up */
+            case 0x49: return 0x84;     /* Ctrl+Page Up */
+            case 0x4B: return 0x73;     /* Ctrl+Left */
+            case 0x4D: return 0x74;     /* Ctrl+Right */
+            case 0x4F: return 0x75;     /* Ctrl+End */
+            case 0x50: return 0x91;     /* Ctrl+Down */
+            case 0x51: return 0x76;     /* Ctrl+Page Down */
+            case 0x52: return 0x92;     /* Ctrl+Insert */
+            case 0x53: return 0x93;     /* Ctrl+Delete */
+        
+        }
+    
     }
     
     return scan;
 
 }
 
+static int host_control_scan (int key) {
+
+    if (key >= 1 && key <= 26) {
+    
+        if (key == 8) return 0x0E;      /* Backspace and Ctrl+H are indistinguishable. */
+        if (key == 9) return 0x0F;      /* Tab and Ctrl+I are indistinguishable. */
+        if (key == 13) return 0x1C;     /* Enter and Ctrl+M are indistinguishable. */
+        
+        return host_alt_scan ((unsigned char) ('a' + key - 1));
+    
+    }
+    
+    return 0;
+
+}
+
 static int host_read_key_from (FILE *source) {
 
     struct termios oldt, newt;
@@ -1951,10 +1992,8 @@ static int bios_read_key (CPU8086 *cpu, int wait) {
     
     if (extended) {
         ch = scan << 8;
-    }
-    
-    if (ch == '\n') {
-        ch = '\r';
+    } else if (changed && ch > 0 && ch <= 26) {
+        ch |= host_control_scan (ch) << 8;
     }
     
 bios_read_done:
@@ -5503,10 +5542,6 @@ static void int_21 (CPU8086 *cpu) {
                         c = '\r';
                     }
                     
-                    if (c == '\n') {
-                        c = '\r';
-                    }
-                    
                     set_reg8 (cpu, REG_AX, (uint8_t) c); /* AL */
                     cpu->flags &= ~FLAG_CF;