<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -21,13 +21,11 @@
 #include &lt;drivers/kb.h&gt;
 #include &lt;isr.h&gt;
 #include &lt;lib/kprintf.h&gt;
-#include &lt;drivers/video/textvideo.h&gt;
 #include &lt;irq.h&gt;
 #include &lt;procio.h&gt;
 #include &lt;driver.h&gt;
 #include &lt;kmalloc.h&gt;
-
-extern video_t video_funcs;
+#include &lt;lib/linked_list.h&gt;
 
 /* A look-up table for all of our keypress values */
 static unsigned char keyboard_map[128] = {
@@ -45,6 +43,7 @@ static unsigned char keyboard_map[128] = {
 };
 
 keyboard_status_t *kb_status;
+ll_t *callbacks;
 
 static void kb_loop(){
 	while(read_byte(0x64)&amp;0x02);
@@ -114,17 +113,29 @@ void keyboard_handler(stack_rep_t *rep){
 				do_leds();
 				break;
 			default:{
-				video_funcs.write_char(key);
-				video_funcs.refresh();
+				ll_node_t *x = callbacks-&gt;head;
+				while(x){
+					((keyboard_callback_p)x-&gt;data)(key);
+					x = x-&gt;next;
+				}
 			}
 		}
 	}
 }
 
+int keyboard_add_callback(keyboard_callback_p x){
+	return ll_add(callbacks, x);
+}
+
+int keyboard_remove_callback(keyboard_callback_p x){
+	return ll_remove(callbacks, x);
+}
+
 driver_t *keyboard_install(){
 	/* Install the keyboard to IRQ #1 */
 	irq_create_handler(1, keyboard_handler);
 	kb_status = kmalloc(sizeof(kb_status));
+	callbacks = ll_create();
 	return driver_started(&quot;keyboard&quot;, 1, DRIVER_INIT_SUCCESSFUL);
 }
 </diff>
      <filename>src/drivers/kb.c</filename>
    </modified>
    <modified>
      <diff>@@ -23,6 +23,7 @@
 #include &lt;lib/string.h&gt;
 #include &lt;drivers/video/textvideo.h&gt;
 #include &lt;driver.h&gt;
+#include &lt;drivers/kb.h&gt;
 
 #define TAB_SIZE 8*8 /* XXX: This could possibly be made dynamic */
 
@@ -69,7 +70,8 @@ video_t video_funcs = {
 	vbe_get_foreground_color,
 	vbe_get_background_color,
 	vbe_refresh,
-	vbe_update_cursor
+	vbe_update_cursor,
+	vbe_keyboard_callback
 };
 
 extern unsigned char font[256*8];
@@ -300,3 +302,8 @@ void vbe_update_cursor(int dy, int dx){
 	vbe_refresh();
 }
 
+void vbe_keyboard_callback(int key){
+	vbe_write_char(key);
+	vbe_refresh();
+}
+</diff>
      <filename>src/drivers/video/tvbe.c</filename>
    </modified>
    <modified>
      <diff>@@ -92,7 +92,11 @@ typedef struct keyboard_status {
 	int status;
 } keyboard_status_t;
 
+typedef void (*keyboard_callback_p)(int);
+
 void keyboard_handler(stack_rep_t *);
 driver_t *keyboard_install();
+int keyboard_add_callback(keyboard_callback_p);
+int keyboard_remove_callback(keyboard_callback_p);
 
 #endif</diff>
      <filename>src/include/drivers/kb.h</filename>
    </modified>
    <modified>
      <diff>@@ -51,6 +51,7 @@ typedef struct {
 	uint8_t (*get_bg_color)(void);
 	void (*refresh)(void);
 	void (*update_cursor)(int, int);
+	void (*keyboard_callback)(int);
 } video_t;
 
 #endif</diff>
      <filename>src/include/drivers/video/textvideo.h</filename>
    </modified>
    <modified>
      <diff>@@ -53,4 +53,6 @@ void vbe_refresh(void);
 
 void vbe_update_cursor(int, int);
 
+void vbe_keyboard_callback(int);
+
 #endif</diff>
      <filename>src/include/drivers/video/tvbe.h</filename>
    </modified>
    <modified>
      <diff>@@ -102,6 +102,8 @@ void init(unsigned long magic, unsigned long addr) {
 	kprintf(&quot;\tExtended Model: %i\n&quot;, cpu_info-&gt;ext_model);
 	kprintf(&quot;\tExtended Family: %i\n&quot;, cpu_info-&gt;ext_family);
 
+	keyboard_add_callback(video_funcs.keyboard_callback);
+
 	__asm__ __volatile__(&quot;sti&quot;);
 
 	while (1) {</diff>
      <filename>src/init/main.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e7c61ff67be2d9a32c8499f0246dafdd0699ac9c</id>
    </parent>
  </parents>
  <author>
    <name>Andrew Etches</name>
    <email>seadog@mehmoo.com</email>
  </author>
  <url>http://github.com/seadog/kaiser/commit/79c4814dfdb12170005317adb150dbc5126adeb1</url>
  <id>79c4814dfdb12170005317adb150dbc5126adeb1</id>
  <committed-date>2009-05-15T14:32:40-07:00</committed-date>
  <authored-date>2009-05-15T14:32:40-07:00</authored-date>
  <message>Added keyboard callbacks so more than one device can grab the keyboard input, also decentralised
the keyboard system so that the keyboard driver doesn't have to call video functions directly,
they now use callbacks</message>
  <tree>c7581e297d42452a395a14439ef76574c16a2981</tree>
  <committer>
    <name>Andrew Etches</name>
    <email>seadog@mehmoo.com</email>
  </committer>
</commit>
