From: John Tsiombikas Date: Sat, 21 Dec 2019 12:04:58 +0000 (+0200) Subject: shift translation for DOS too X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=commitdiff_plain;h=6819a099c49a569221321a46a52811aead65d20e shift translation for DOS too --- diff --git a/src/dos/keyb.c b/src/dos/keyb.c index 98a1f3d..36a6021 100644 --- a/src/dos/keyb.c +++ b/src/dos/keyb.c @@ -20,6 +20,7 @@ along with the program. If not, see #include #include #include +#include #include #include @@ -138,6 +139,10 @@ int kb_isdown(int key) case KB_CTRL: return keystate[KB_LCTRL] + keystate[KB_RCTRL]; } + + if(isalpha(key)) { + key = tolower(key); + } return keystate[key]; } @@ -206,7 +211,7 @@ void kb_putback(int key) static void INTERRUPT kbintr() { unsigned char code; - int key, press; + int key, c, press; code = inp(KB_PORT); @@ -224,12 +229,13 @@ static void INTERRUPT kbintr() } key = scantbl[code]; + c = (keystate[KB_LSHIFT] | keystate[KB_RSHIFT]) ? scantbl_shift[code] : key; if(press) { /* append to buffer */ - last_key = key; + last_key = c; 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 diff --git a/src/dos/scancode.h b/src/dos/scancode.h index bac82d6..48f8a0b 100644 --- a/src/dos/scancode.h +++ b/src/dos/scancode.h @@ -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 */ }; + +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 */ +};