X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Fdos%2Fkeyb.c;h=55b90134de8715c902aa3c04f581ae73197967cc;hp=98a1f3da20ee0a7cb3c16f63f90fa63a6c256e92;hb=7cffbf057545fb303ad8f53e432ef42f7708e16d;hpb=0165ec15f868a16a70b56ada2d42db0cb69ea193 diff --git a/src/dos/keyb.c b/src/dos/keyb.c index 98a1f3d..55b9013 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 @@ -27,7 +28,6 @@ along with the program. If not, see #include #endif #ifdef __DJGPP__ -#include #include #include #include @@ -35,6 +35,7 @@ along with the program. If not, see #include "keyb.h" #include "scancode.h" +#include "inttypes.h" #define KB_INTR 0x9 #define KB_PORT 0x60 @@ -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]; } @@ -156,10 +161,12 @@ void kb_wait(void) { int key; while((key = kb_getkey()) == -1) { +#ifdef USE_HLT /* put the processor to sleep while waiting for keypresses, but first * make sure interrupts are enabled, or we'll sleep forever */ halt(); +#endif } kb_putback(key); } @@ -206,7 +213,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 +231,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