shift translation for DOS too
authorJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 21 Dec 2019 12:04:58 +0000 (14:04 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 21 Dec 2019 12:04:58 +0000 (14:04 +0200)
src/dos/keyb.c
src/dos/scancode.h

index 98a1f3d..36a6021 100644 (file)
@@ -20,6 +20,7 @@ along with the program. If not, see <http://www.gnu.org/licenses/>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
 #include <conio.h>
 #include <dos.h>
 
 #include <conio.h>
 #include <dos.h>
 
@@ -138,6 +139,10 @@ int kb_isdown(int key)
        case KB_CTRL:
                return keystate[KB_LCTRL] + keystate[KB_RCTRL];
        }
        case KB_CTRL:
                return keystate[KB_LCTRL] + keystate[KB_RCTRL];
        }
+
+       if(isalpha(key)) {
+               key = tolower(key);
+       }
        return keystate[key];
 }
 
        return keystate[key];
 }
 
@@ -206,7 +211,7 @@ void kb_putback(int key)
 static void INTERRUPT kbintr()
 {
        unsigned char code;
 static void INTERRUPT kbintr()
 {
        unsigned char code;
-       int key, press;
+       int key, c, press;
 
        code = inp(KB_PORT);
 
 
        code = inp(KB_PORT);
 
@@ -224,12 +229,13 @@ static void INTERRUPT kbintr()
        }
 
        key = scantbl[code];
        }
 
        key = scantbl[code];
+       c = (keystate[KB_LSHIFT] | keystate[KB_RSHIFT]) ? scantbl_shift[code] : key;
 
        if(press) {
                /* append to buffer */
 
        if(press) {
                /* append to buffer */
-               last_key = key;
+               last_key = c;
                if(buffer_size > 0) {
                if(buffer_size > 0) {
-                       buffer[buf_widx] = key;
+                       buffer[buf_widx] = c;
                        ADVANCE(buf_widx);
                        /* if the write end overtook the read end, advance the read end
                         * too, to discard the oldest keypress from the buffer
                        ADVANCE(buf_widx);
                        /* if the write end overtook the read end, advance the read end
                         * too, to discard the oldest keypress from the buffer
index bac82d6..48f8a0b 100644 (file)
@@ -32,3 +32,16 @@ static int scantbl[] = {
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                                                                 /* 60 - 6f */
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0                                                                  /* 70 - 7f */
 };
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                                                                 /* 60 - 6f */
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0                                                                  /* 70 - 7f */
 };
+
+static int scantbl_shift[] = {
+       0, KB_ESC, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '\b',            /* 0 - e */
+       '\t', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n',                 /* f - 1c */
+       KB_LCTRL, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~',                           /* 1d - 29 */
+       KB_LSHIFT, '|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', KB_RSHIFT,                    /* 2a - 36 */
+       KB_NUM_MUL, KB_LALT, ' ', KB_CAPSLK, KB_F1, KB_F2, KB_F3, KB_F4, KB_F5, KB_F6, KB_F7, KB_F8, KB_F9, KB_F10,                     /* 37 - 44 */
+       KB_NUMLK, KB_SCRLK, KB_NUM_7, KB_NUM_8, KB_NUM_9, KB_NUM_MINUS, KB_NUM_4, KB_NUM_5, KB_NUM_6, KB_NUM_PLUS,      /* 45 - 4e */
+       KB_NUM_1, KB_NUM_2, KB_NUM_3, KB_NUM_0, KB_NUM_DOT, KB_SYSRQ, 0, 0, KB_F11, KB_F12,                                             /* 4d - 58 */
+       0, 0, 0, 0, 0, 0, 0,                                                                                                                    /* 59 - 5f */
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                                                                 /* 60 - 6f */
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0                                                                  /* 70 - 7f */
+};