]> Joshua Wise's Git repositories - netwatch.git/blobdiff - cs410/keyb.c
First pass of 410watch UI code.
[netwatch.git] / cs410 / keyb.c
diff --git a/cs410/keyb.c b/cs410/keyb.c
new file mode 100644 (file)
index 0000000..8fd4c98
--- /dev/null
@@ -0,0 +1,39 @@
+#include <io.h>
+#include "keyhelp.h"
+#include "../net/net.h"
+#include <output.h>
+
+/* Takes over the i8042... oh well.  If we ever fully emulate the i8042,
+ * then we'll patch into that.
+ */
+
+#define KEYBOARD_PORT 0x60
+#define KEYB_STATUS_PORT 0x64
+#define KEYB_OBF 0x1
+
+int getchar()
+{
+       kh_type key;
+       unsigned char scancode;
+       
+       /* Ignore accesses -- XXX hack */
+       outl(0x840, 0x0);
+       outl(0x848, 0x0);
+       
+       do
+       {
+               while (!(inb(KEYB_STATUS_PORT) & KEYB_OBF))
+                       eth_poll();
+               
+               scancode = inb(KEYBOARD_PORT);
+               outputf("scancode: %02x", scancode);
+               key = process_scancode(scancode);
+       } while (!KH_HASDATA(key) || !KH_ISMAKE(key));
+       
+       /* XXX */
+       outl(0x840, 0x0);
+       outl(0x844, 0x1000);
+       outl(0x848, 0x1000);
+       
+       return KH_GETCHAR(key);
+}
This page took 0.02363 seconds and 4 git commands to generate.