grml...
[seabios.git] / src / kbd.c
index 6f3ae15d5b5556fb92a8989458603c45f3b17f88..1977c5d018c72ff87da3a8e90882090d97a3b356 100644 (file)
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -9,7 +9,8 @@
 #include "util.h" // debug_enter
 #include "config.h" // CONFIG_*
 #include "bregs.h" // struct bregs
-#include "ps2port.h" // kbd_command
+#include "ps2port.h" // ps2_kbd_command
+#include "usb-hid.h" // usb_kbd_command
 
 // Bit definitions for BDA kbd_flag[012]
 #define KF0_RSHIFT       (1<<0)
@@ -73,6 +74,7 @@ enqueue_key(u8 scan_code, u8 ascii_code)
 static void
 dequeue_key(struct bregs *regs, int incr, int extended)
 {
+    yield();
     u16 buffer_head;
     u16 buffer_tail;
     for (;;) {
@@ -108,6 +110,14 @@ dequeue_key(struct bregs *regs, int incr, int extended)
     SET_BDA(kbd_buf_head, buffer_head);
 }
 
+static inline int
+kbd_command(int command, u8 *param)
+{
+    if (usb_kbd_active())
+        return usb_kbd_command(command, param);
+    return ps2_kbd_command(command, param);
+}
+
 // read keyboard input
 static void
 handle_1600(struct bregs *regs)
@@ -126,6 +136,7 @@ handle_1601(struct bregs *regs)
 static void
 handle_1602(struct bregs *regs)
 {
+    yield();
     regs->al = GET_BDA(kbd_flag0);
 }
 
@@ -184,6 +195,7 @@ handle_1611(struct bregs *regs)
 static void
 handle_1612(struct bregs *regs)
 {
+    yield();
     regs->al = GET_BDA(kbd_flag0);
     regs->ah = ((GET_BDA(kbd_flag1) & ~(KF2_RCTRL|KF2_RALT))
                 | (GET_BDA(kbd_flag2) & (KF2_RCTRL|KF2_RALT)));