#include "keyb.h"
#include "scancode.h"
#include "inttypes.h"
+#include "dosutil.h"
#define KB_INTR 0x9
#define KB_PORT 0x60
#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();
{
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--;
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 */
/* and update keystate table */
keystate[key] = press;
+eoi:
outp(PIC1_CMD_PORT, OCW2_EOI); /* send end-of-interrupt */
}