From: John Tsiombikas Date: Fri, 6 Mar 2020 14:07:21 +0000 (+0200) Subject: fixed keyboard handler to translate extended scancodes X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=eradicate;a=commitdiff_plain;h=d3401f8f5fbe0b0a7939ce3a8ef680cf5356f9ba fixed keyboard handler to translate extended scancodes --- diff --git a/src/dos/keyb.c b/src/dos/keyb.c index 55b9013..ac200b3 100644 --- a/src/dos/keyb.c +++ b/src/dos/keyb.c @@ -214,12 +214,18 @@ static void INTERRUPT kbintr() { unsigned char code; int key, c, press; + static int ext; code = inp(KB_PORT); - if(code >= 128) { + if(code == 0xe0) { + ext = 1; + goto eoi; + } + + if(code & 0x80) { press = 0; - code -= 128; + code &= 0x7f; if(num_pressed > 0) { num_pressed--; @@ -230,8 +236,14 @@ static void INTERRUPT kbintr() num_pressed++; } - key = scantbl[code]; - c = (keystate[KB_LSHIFT] | keystate[KB_RSHIFT]) ? scantbl_shift[code] : key; + if(ext) { + key = scantbl_ext[code]; + c = key; + ext = 0; + } else { + key = scantbl[code]; + c = (keystate[KB_LSHIFT] | keystate[KB_RSHIFT]) ? scantbl_shift[code] : key; + } if(press) { /* append to buffer */ @@ -251,5 +263,6 @@ static void INTERRUPT kbintr() /* and update keystate table */ keystate[key] = press; +eoi: outp(PIC1_CMD_PORT, OCW2_EOI); /* send end-of-interrupt */ } diff --git a/src/dos/scancode.h b/src/dos/scancode.h index 48f8a0b..b0e398c 100644 --- a/src/dos/scancode.h +++ b/src/dos/scancode.h @@ -45,3 +45,17 @@ static int scantbl_shift[] = { 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 */ }; + + +/* extended scancodes, after the 0xe0 prefix */ +static int scantbl_ext[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0 - f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\r', KB_RCTRL, 0, 0, /* 10 - 1f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 20 - 2f */ + 0, 0, 0, 0, 0, KB_NUM_MINUS, 0, KB_SYSRQ, KB_RALT, 0, 0, 0, 0, 0, 0, 0, /* 30 - 3f */ + 0, 0, 0, 0, 0, 0, 0, KB_HOME, KB_UP, KB_PGUP, 0, KB_LEFT, 0, KB_RIGHT, 0, KB_END, /* 40 - 4f */ + KB_DOWN, KB_PGDN, KB_INSERT, KB_DEL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 50 - 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 */ +}; + diff --git a/src/game.h b/src/game.h index a080fab..77a5fce 100644 --- a/src/game.h +++ b/src/game.h @@ -23,7 +23,7 @@ enum { KB_NUM_5, KB_NUM_6, KB_NUM_7, KB_NUM_8, KB_NUM_9, KB_NUM_DOT, KB_NUM_DIV, KB_NUM_MUL, KB_NUM_MINUS, KB_NUM_PLUS, KB_NUM_ENTER, KB_NUM_EQUALS, KB_UP, KB_DOWN, KB_RIGHT, KB_LEFT, - KB_INSERT, KB_HOME, KB_END, KB_PGUP, KB_PGDN, + KB_INSERT, KB_DEL, KB_HOME, KB_END, KB_PGUP, KB_PGDN, KB_F1, KB_F2, KB_F3, KB_F4, KB_F5, KB_F6, KB_F7, KB_F8, KB_F9, KB_F10, KB_F11, KB_F12, KB_F13, KB_F14, KB_F15,