X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fdos%2Fkeyb.c;h=e35cb7b35b58432ce965db51f7257a178b6d9115;hb=HEAD;hp=36a6021a8e288cfcf115f6916d14bad0fd37dfb3;hpb=6819a099c49a569221321a46a52811aead65d20e;p=dosdemo
diff --git a/src/dos/keyb.c b/src/dos/keyb.c
index 36a6021..e35cb7b 100644
--- a/src/dos/keyb.c
+++ b/src/dos/keyb.c
@@ -28,7 +28,6 @@ along with the program. If not, see
#include
#endif
#ifdef __DJGPP__
-#include
#include
#include
#include
@@ -36,6 +35,8 @@ along with the program. If not, see
#include "keyb.h"
#include "scancode.h"
+#include "inttypes.h"
+#include "dosutil.h"
#define KB_INTR 0x9
#define KB_PORT 0x60
@@ -55,9 +56,6 @@ static void (INTERRUPT *prev_handler)();
#define DONE_INIT prev_intr.pm_offset
static _go32_dpmi_seginfo intr, prev_intr;
-
-#define outp(p, v) outportb(p, v)
-#define inp(p) inportb(p)
#endif
static void INTERRUPT kbintr();
@@ -161,10 +159,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);
}
@@ -212,12 +212,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--;
@@ -228,8 +234,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 */
@@ -249,5 +261,6 @@ static void INTERRUPT kbintr()
/* and update keystate table */
keystate[key] = press;
+eoi:
outp(PIC1_CMD_PORT, OCW2_EOI); /* send end-of-interrupt */
}