Index: uspace/srv/kbd/Makefile
===================================================================
--- uspace/srv/kbd/Makefile	(revision bbdbf864caf174598e10071c9291344c461489ef)
+++ uspace/srv/kbd/Makefile	(revision 215abc165fc8eda817e4c859ba67ddcadb7c1e64)
@@ -47,5 +47,5 @@
 	genarch/gsp.c \
 	genarch/stroke.c \
-	generic/key_buffer.c
+	generic/keybuffer.c
 
 ARCH_SOURCES =
Index: uspace/srv/kbd/ctl/gxe_fb.c
===================================================================
--- uspace/srv/kbd/ctl/gxe_fb.c	(revision bbdbf864caf174598e10071c9291344c461489ef)
+++ uspace/srv/kbd/ctl/gxe_fb.c	(revision 215abc165fc8eda817e4c859ba67ddcadb7c1e64)
@@ -37,6 +37,6 @@
 
 #include <kbd.h>
-#include <kbd/kbd.h>
-#include <kbd/keycode.h>
+#include <io/console.h>
+#include <io/keycode.h>
 #include <kbd_ctl.h>
 #include <gsp.h>
Index: uspace/srv/kbd/ctl/pc.c
===================================================================
--- uspace/srv/kbd/ctl/pc.c	(revision bbdbf864caf174598e10071c9291344c461489ef)
+++ uspace/srv/kbd/ctl/pc.c	(revision 215abc165fc8eda817e4c859ba67ddcadb7c1e64)
@@ -33,10 +33,10 @@
 /**
  * @file
- * @brief	PC keyboard controller driver.
+ * @brief PC keyboard controller driver.
  */
 
 #include <kbd.h>
-#include <kbd/kbd.h>
-#include <kbd/keycode.h>
+#include <io/console.h>
+#include <io/keycode.h>
 #include <kbd_ctl.h>
 #include <gsp.h>
@@ -189,5 +189,5 @@
 void kbd_ctl_parse_scancode(int scancode)
 {
-	kbd_ev_type_t type;
+	console_ev_type_t type;
 	unsigned int key;
 	int *map;
@@ -214,7 +214,7 @@
 	if (scancode & 0x80) {
 		scancode &= ~0x80;
-		type = KE_RELEASE;
+		type = KEY_RELEASE;
 	} else {
-		type = KE_PRESS;
+		type = KEY_PRESS;
 	}
 
Index: uspace/srv/kbd/ctl/stty.c
===================================================================
--- uspace/srv/kbd/ctl/stty.c	(revision bbdbf864caf174598e10071c9291344c461489ef)
+++ uspace/srv/kbd/ctl/stty.c	(revision 215abc165fc8eda817e4c859ba67ddcadb7c1e64)
@@ -37,6 +37,5 @@
 
 #include <kbd.h>
-#include <kbd/kbd.h>
-#include <kbd/keycode.h>
+#include <io/keycode.h>
 #include <kbd_ctl.h>
 #include <gsp.h>
Index: uspace/srv/kbd/ctl/sun.c
===================================================================
--- uspace/srv/kbd/ctl/sun.c	(revision bbdbf864caf174598e10071c9291344c461489ef)
+++ uspace/srv/kbd/ctl/sun.c	(revision 215abc165fc8eda817e4c859ba67ddcadb7c1e64)
@@ -37,6 +37,6 @@
 
 #include <kbd.h>
-#include <kbd/kbd.h>
-#include <kbd/keycode.h>
+#include <io/console.h>
+#include <io/keycode.h>
 #include <kbd_ctl.h>
 
@@ -53,5 +53,5 @@
 void kbd_ctl_parse_scancode(int scancode)
 {
-	kbd_ev_type_t type;
+	console_ev_type_t type;
 	unsigned int key;
 
@@ -64,7 +64,7 @@
 	if (scancode & KBD_KEY_RELEASE) {
 		scancode &= ~KBD_KEY_RELEASE;
-		type = KE_RELEASE;
+		type = KEY_RELEASE;
 	} else {
-		type = KE_PRESS;
+		type = KEY_PRESS;
 	}
 
Index: uspace/srv/kbd/genarch/stroke.c
===================================================================
--- uspace/srv/kbd/genarch/stroke.c	(revision bbdbf864caf174598e10071c9291344c461489ef)
+++ uspace/srv/kbd/genarch/stroke.c	(revision 215abc165fc8eda817e4c859ba67ddcadb7c1e64)
@@ -32,15 +32,16 @@
 /**
  * @file
- * @brief	Stroke simulator.
+ * @brief Stroke simulator.
  *
  * When simulating a keyboard using a serial TTY we need to convert the
  * recognized strokes (such as Shift-A) to sequences of key presses and
  * releases (such as 'press Shift, press A, release A, release Shift').
+ *
  */
 
 #include <stroke.h>
 #include <kbd.h>
-#include <kbd/kbd.h>
-#include <kbd/keycode.h>
+#include <io/console.h>
+#include <io/keycode.h>
 
 /** Correspondence between modifers and the modifier keycodes. */
@@ -59,5 +60,5 @@
 	while (mods_keys[i][0] != 0) {
 		if (mod & mods_keys[i][0]) {
-			kbd_push_ev(KE_PRESS, mods_keys[i][1]);
+			kbd_push_ev(KEY_PRESS, mods_keys[i][1]);
 		}
 		++i;
@@ -66,6 +67,6 @@
 	/* Simulate key press and release. */
 	if (key != 0) {
-		kbd_push_ev(KE_PRESS, key);
-		kbd_push_ev(KE_RELEASE, key);
+		kbd_push_ev(KEY_PRESS, key);
+		kbd_push_ev(KEY_RELEASE, key);
 	}
 
@@ -74,5 +75,5 @@
 	while (mods_keys[i][0] != 0) {
 		if (mod & mods_keys[i][0]) {
-			kbd_push_ev(KE_RELEASE, mods_keys[i][1]);
+			kbd_push_ev(KEY_RELEASE, mods_keys[i][1]);
 		}
 		++i;
@@ -82,3 +83,3 @@
 /**
  * @}
- */ 
+ */
Index: uspace/srv/kbd/generic/kbd.c
===================================================================
--- uspace/srv/kbd/generic/kbd.c	(revision bbdbf864caf174598e10071c9291344c461489ef)
+++ uspace/srv/kbd/generic/kbd.c	(revision 215abc165fc8eda817e4c859ba67ddcadb7c1e64)
@@ -29,8 +29,8 @@
 /**
  * @addtogroup kbdgen generic
- * @brief	HelenOS generic uspace keyboard handler.
- * @ingroup  kbd
+ * @brief HelenOS generic uspace keyboard handler.
+ * @ingroup kbd
  * @{
- */ 
+ */
 /** @file
  */
@@ -47,9 +47,9 @@
 #include <errno.h>
 #include <libadt/fifo.h>
-#include <kbd/kbd.h>
-#include <kbd/keycode.h>
+#include <io/console.h>
+#include <io/keycode.h>
 
 #include <kbd.h>
-#include <key_buffer.h>
+#include <keybuffer.h>
 #include <kbd_port.h>
 #include <kbd_ctl.h>
@@ -89,5 +89,5 @@
 void kbd_push_ev(int type, unsigned int key)
 {
-	kbd_event_t ev;
+	console_event_t ev;
 	unsigned mod_mask;
 
@@ -103,5 +103,5 @@
 
 	if (mod_mask != 0) {
-		if (type == KE_PRESS)
+		if (type == KEY_PRESS)
 			mods = mods | mod_mask;
 		else
@@ -117,5 +117,5 @@
 
 	if (mod_mask != 0) {
-		if (type == KE_PRESS) {
+		if (type == KEY_PRESS) {
 			/*
 			 * Only change lock state on transition from released
@@ -134,5 +134,5 @@
 	printf("keycode: %u\n", key);
 */
-	if (type == KE_PRESS && (mods & KM_LCTRL) &&
+	if (type == KEY_PRESS && (mods & KM_LCTRL) &&
 		key == KC_F1) {
 		active_layout = 0;
@@ -141,5 +141,5 @@
 	}
 
-	if (type == KE_PRESS && (mods & KM_LCTRL) &&
+	if (type == KEY_PRESS && (mods & KM_LCTRL) &&
 		key == KC_F2) {
 		active_layout = 1;
@@ -148,5 +148,5 @@
 	}
 
-	if (type == KE_PRESS && (mods & KM_LCTRL) &&
+	if (type == KEY_PRESS && (mods & KM_LCTRL) &&
 		key == KC_F3) {
 		active_layout = 2;
Index: pace/srv/kbd/generic/key_buffer.c
===================================================================
--- uspace/srv/kbd/generic/key_buffer.c	(revision bbdbf864caf174598e10071c9291344c461489ef)
+++ 	(revision )
@@ -1,117 +1,0 @@
-/*
- * Copyright (c) 2006 Josef Cejka
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup kbdgen
- * @brief	HelenOS generic uspace keyboard handler.
- * @ingroup  kbd
- * @{
- */ 
-/** @file
- */
-#include <key_buffer.h>
-#include <futex.h>
-
-atomic_t keybuffer_futex = FUTEX_INITIALIZER;
-
-/** Clear key buffer.
- */
-void keybuffer_free(keybuffer_t *keybuffer)
-{
-	futex_down(&keybuffer_futex);
-	keybuffer->head = 0;
-	keybuffer->tail = 0;
-	keybuffer->items = 0;
-	futex_up(&keybuffer_futex);
-}
-
-/** Key buffer initialization.
- *
- */
-void keybuffer_init(keybuffer_t *keybuffer)
-{
-	keybuffer_free(keybuffer);
-}
-
-/** Get free space in buffer.
- * This function is useful for processing some scancodes that are translated 
- * to more than one character.
- * @return empty buffer space
- */
-int keybuffer_available(keybuffer_t *keybuffer)
-{
-	return KEYBUFFER_SIZE - keybuffer->items;
-}
-
-/**
- * @return nonzero, if buffer is not empty.
- */
-int keybuffer_empty(keybuffer_t *keybuffer)
-{
-	return (keybuffer->items == 0);
-}
-
-/** Push key event to key buffer.
- *
- * If the buffer is full, the event is ignored.
- *
- * @param keybuffer	The keybuffer.
- * @param ev		The event to push.
- */
-void keybuffer_push(keybuffer_t *keybuffer, const kbd_event_t *ev)
-{
-	futex_down(&keybuffer_futex);
-	if (keybuffer->items < KEYBUFFER_SIZE) {
-		keybuffer->fifo[keybuffer->tail] = *ev;
-		keybuffer->tail = (keybuffer->tail + 1) % KEYBUFFER_SIZE;
-		keybuffer->items++;
-	}
-	futex_up(&keybuffer_futex);
-}
-
-/** Pop event from buffer.
- *
- * @param edst	Pointer to where the event should be saved.
- * @return	Zero on empty buffer, nonzero otherwise.
- */
-int keybuffer_pop(keybuffer_t *keybuffer, kbd_event_t *edst)
-{
-	futex_down(&keybuffer_futex);
-	if (keybuffer->items > 0) {
-		keybuffer->items--;
-		*edst = (keybuffer->fifo[keybuffer->head]) ;
-		keybuffer->head = (keybuffer->head + 1) % KEYBUFFER_SIZE;
-		futex_up(&keybuffer_futex);
-		return 1;
-	}
-	futex_up(&keybuffer_futex);
-	return 0;
-}
-
-/**
- * @}
- */ 
Index: uspace/srv/kbd/generic/keybuffer.c
===================================================================
--- uspace/srv/kbd/generic/keybuffer.c	(revision 215abc165fc8eda817e4c859ba67ddcadb7c1e64)
+++ uspace/srv/kbd/generic/keybuffer.c	(revision 215abc165fc8eda817e4c859ba67ddcadb7c1e64)
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2006 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup kbdgen
+ * @brief HelenOS generic uspace keyboard handler.
+ * @ingroup kbd
+ * @{
+ */
+/** @file
+ */
+
+#include <keybuffer.h>
+#include <futex.h>
+
+atomic_t keybuffer_futex = FUTEX_INITIALIZER;
+
+/** Clear key buffer.
+ */
+void keybuffer_free(keybuffer_t *keybuffer)
+{
+	futex_down(&keybuffer_futex);
+	keybuffer->head = 0;
+	keybuffer->tail = 0;
+	keybuffer->items = 0;
+	futex_up(&keybuffer_futex);
+}
+
+/** Key buffer initialization.
+ *
+ */
+void keybuffer_init(keybuffer_t *keybuffer)
+{
+	keybuffer_free(keybuffer);
+}
+
+/** Get free space in buffer.
+ *
+ * This function is useful for processing some scancodes that are translated
+ * to more than one character.
+ *
+ * @return empty buffer space
+ *
+ */
+size_t keybuffer_available(keybuffer_t *keybuffer)
+{
+	return KEYBUFFER_SIZE - keybuffer->items;
+}
+
+/**
+ *
+ * @return nonzero, if buffer is not empty.
+ *
+ */
+bool keybuffer_empty(keybuffer_t *keybuffer)
+{
+	return (keybuffer->items == 0);
+}
+
+/** Push key event to key buffer.
+ *
+ * If the buffer is full, the event is ignored.
+ *
+ * @param keybuffer The keybuffer.
+ * @param ev        The event to push.
+ *
+ */
+void keybuffer_push(keybuffer_t *keybuffer, const console_event_t *ev)
+{
+	futex_down(&keybuffer_futex);
+	
+	if (keybuffer->items < KEYBUFFER_SIZE) {
+		keybuffer->fifo[keybuffer->tail] = *ev;
+		keybuffer->tail = (keybuffer->tail + 1) % KEYBUFFER_SIZE;
+		keybuffer->items++;
+	}
+	
+	futex_up(&keybuffer_futex);
+}
+
+/** Pop event from buffer.
+ *
+ * @param edst Pointer to where the event should be saved.
+ *
+ * @return True if an event was popped.
+ *
+ */
+bool keybuffer_pop(keybuffer_t *keybuffer, console_event_t *edst)
+{
+	futex_down(&keybuffer_futex);
+	
+	if (keybuffer->items > 0) {
+		keybuffer->items--;
+		*edst = (keybuffer->fifo[keybuffer->head]);
+		keybuffer->head = (keybuffer->head + 1) % KEYBUFFER_SIZE;
+		futex_up(&keybuffer_futex);
+		
+		return true;
+	}
+	
+	futex_up(&keybuffer_futex);
+	
+	return false;
+}
+
+/**
+ * @}
+ */
Index: uspace/srv/kbd/include/kbd.h
===================================================================
--- uspace/srv/kbd/include/kbd.h	(revision bbdbf864caf174598e10071c9291344c461489ef)
+++ uspace/srv/kbd/include/kbd.h	(revision 215abc165fc8eda817e4c859ba67ddcadb7c1e64)
@@ -28,8 +28,8 @@
 
 /** @addtogroup kbdgen generic
- * @brief	HelenOS generic uspace keyboard handler.
- * @ingroup  kbd
+ * @brief HelenOS generic uspace keyboard handler.
+ * @ingroup kbd
  * @{
- */ 
+ */
 /** @file
  */
@@ -38,15 +38,15 @@
 #define KBD_KBD_H_
 
-#include <key_buffer.h>
+#include <keybuffer.h>
 #include <ipc/ipc.h>
 
-#define KBD_EVENT	1024
-#define KBD_MS_LEFT	1025
-#define KBD_MS_RIGHT	1026
-#define KBD_MS_MIDDLE	1027
-#define KBD_MS_MOVE	1028
+#define KBD_EVENT      1024
+#define KBD_MS_LEFT    1025
+#define KBD_MS_RIGHT   1026
+#define KBD_MS_MIDDLE  1027
+#define KBD_MS_MOVE    1028
 
 typedef enum {
-	KBD_YIELD	= IPC_FIRST_USER_METHOD,
+	KBD_YIELD = IPC_FIRST_USER_METHOD,
 	KBD_RECLAIM
 } kbd_request_t;
@@ -62,4 +62,3 @@
 /**
  * @}
- */ 
-
+ */
Index: pace/srv/kbd/include/key_buffer.h
===================================================================
--- uspace/srv/kbd/include/key_buffer.h	(revision bbdbf864caf174598e10071c9291344c461489ef)
+++ 	(revision )
@@ -1,65 +1,0 @@
-/*
- * Copyright (c) 2006 Josef Cejka
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup kbdgen
- * @brief	HelenOS generic uspace keyboard handler.
- * @ingroup  kbd
- * @{
- */ 
-/** @file
- */
-
-#ifndef __KEY_BUFFER_H__
-#define __KEY_BUFFER_H__
-
-#include <sys/types.h>
-#include <kbd/kbd.h>
-
-/** Size of buffer for pressed keys */
-#define KEYBUFFER_SIZE 128 
-
-typedef struct {
-	kbd_event_t fifo[KEYBUFFER_SIZE];
-	unsigned long head;
-	unsigned long tail;
-	unsigned long items;
-} keybuffer_t;
-
-extern void keybuffer_free(keybuffer_t *);
-extern void keybuffer_init(keybuffer_t *);
-extern int keybuffer_available(keybuffer_t *);
-extern int keybuffer_empty(keybuffer_t *);
-extern void keybuffer_push(keybuffer_t *, const kbd_event_t *);
-extern int keybuffer_pop(keybuffer_t *, kbd_event_t *);
-
-#endif
-
-/**
- * @}
- */ 
-
Index: uspace/srv/kbd/include/keybuffer.h
===================================================================
--- uspace/srv/kbd/include/keybuffer.h	(revision 215abc165fc8eda817e4c859ba67ddcadb7c1e64)
+++ uspace/srv/kbd/include/keybuffer.h	(revision 215abc165fc8eda817e4c859ba67ddcadb7c1e64)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2006 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup kbdgen
+ * @brief HelenOS generic uspace keyboard handler.
+ * @ingroup kbd
+ * @{
+ */
+/** @file
+ */
+
+#ifndef __KEYBUFFER_H__
+#define __KEYBUFFER_H__
+
+#include <sys/types.h>
+#include <io/console.h>
+#include <bool.h>
+
+/** Size of buffer for pressed keys */
+#define KEYBUFFER_SIZE  128
+
+typedef struct {
+	console_event_t fifo[KEYBUFFER_SIZE];
+	unsigned long head;
+	unsigned long tail;
+	unsigned long items;
+} keybuffer_t;
+
+extern void keybuffer_free(keybuffer_t *);
+extern void keybuffer_init(keybuffer_t *);
+extern size_t keybuffer_available(keybuffer_t *);
+extern bool keybuffer_empty(keybuffer_t *);
+extern void keybuffer_push(keybuffer_t *, const console_event_t *);
+extern bool keybuffer_pop(keybuffer_t *, console_event_t *);
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/srv/kbd/include/layout.h
===================================================================
--- uspace/srv/kbd/include/layout.h	(revision bbdbf864caf174598e10071c9291344c461489ef)
+++ uspace/srv/kbd/include/layout.h	(revision 215abc165fc8eda817e4c859ba67ddcadb7c1e64)
@@ -28,8 +28,8 @@
 
 /** @addtogroup kbdgen generic
- * @brief	HelenOS generic uspace keyboard handler.
- * @ingroup  kbd
+ * @brief HelenOS generic uspace keyboard handler.
+ * @ingroup kbd
  * @{
- */ 
+ */
 /** @file
  */
@@ -38,10 +38,10 @@
 #define KBD_LAYOUT_H_
 
-#include <kbd/kbd.h>
 #include <sys/types.h>
+#include <io/console.h>
 
 typedef struct {
 	void (*reset)(void);
-	wchar_t (*parse_ev)(kbd_event_t *);
+	wchar_t (*parse_ev)(console_event_t *);
 } layout_op_t;
 
@@ -54,4 +54,3 @@
 /**
  * @}
- */ 
-
+ */
Index: uspace/srv/kbd/layout/cz.c
===================================================================
--- uspace/srv/kbd/layout/cz.c	(revision bbdbf864caf174598e10071c9291344c461489ef)
+++ uspace/srv/kbd/layout/cz.c	(revision 215abc165fc8eda817e4c859ba67ddcadb7c1e64)
@@ -28,21 +28,21 @@
 
 /** @addtogroup kbd
- * @brief	US QWERTY leyout.
+ * @brief US QWERTY leyout.
  * @{
- */ 
+ */
 
 #include <kbd.h>
-#include <kbd/kbd.h>
-#include <kbd/keycode.h>
+#include <io/console.h>
+#include <io/keycode.h>
 #include <bool.h>
 #include <layout.h>
 
 static void layout_reset(void);
-static wchar_t layout_parse_ev(kbd_event_t *ev);
+static wchar_t layout_parse_ev(console_event_t *ev);
 
 enum m_state {
 	ms_start,
 	ms_hacek,
-	ms_carka	
+	ms_carka
 };
 
@@ -273,5 +273,5 @@
 }
 
-static wchar_t parse_ms_hacek(kbd_event_t *ev)
+static wchar_t parse_ms_hacek(console_event_t *ev)
 {
 	wchar_t c;
@@ -291,5 +291,5 @@
 }
 
-static wchar_t parse_ms_carka(kbd_event_t *ev)
+static wchar_t parse_ms_carka(console_event_t *ev)
 {
 	wchar_t c;
@@ -309,5 +309,5 @@
 }
 
-static wchar_t parse_ms_start(kbd_event_t *ev)
+static wchar_t parse_ms_start(console_event_t *ev)
 {
 	wchar_t c;
@@ -384,16 +384,19 @@
 }
 
-static wchar_t layout_parse_ev(kbd_event_t *ev)
-{
-	if (ev->type != KE_PRESS)
-		return '\0';
-
+static wchar_t layout_parse_ev(console_event_t *ev)
+{
+	if (ev->type != KEY_PRESS)
+		return 0;
+	
 	if (key_is_mod(ev->key))
-		return '\0';
-
+		return 0;
+	
 	switch (mstate) {
-	case ms_start: return parse_ms_start(ev);
-	case ms_hacek: return parse_ms_hacek(ev);
-	case ms_carka: return parse_ms_carka(ev);
+	case ms_start:
+		return parse_ms_start(ev);
+	case ms_hacek:
+		return parse_ms_hacek(ev);
+	case ms_carka:
+		return parse_ms_carka(ev);
 	}
 }
@@ -401,3 +404,3 @@
 /**
  * @}
- */ 
+ */
Index: uspace/srv/kbd/layout/us_dvorak.c
===================================================================
--- uspace/srv/kbd/layout/us_dvorak.c	(revision bbdbf864caf174598e10071c9291344c461489ef)
+++ uspace/srv/kbd/layout/us_dvorak.c	(revision 215abc165fc8eda817e4c859ba67ddcadb7c1e64)
@@ -33,10 +33,10 @@
 
 #include <kbd.h>
-#include <kbd/kbd.h>
-#include <kbd/keycode.h>
+#include <io/console.h>
+#include <io/keycode.h>
 #include <layout.h>
 
 static void layout_reset(void);
-static wchar_t layout_parse_ev(kbd_event_t *ev);
+static wchar_t layout_parse_ev(console_event_t *ev);
 
 layout_op_t us_dvorak_op = {
@@ -210,5 +210,5 @@
 }
 
-static wchar_t layout_parse_ev(kbd_event_t *ev)
+static wchar_t layout_parse_ev(console_event_t *ev)
 {
 	wchar_t c;
Index: uspace/srv/kbd/layout/us_qwerty.c
===================================================================
--- uspace/srv/kbd/layout/us_qwerty.c	(revision bbdbf864caf174598e10071c9291344c461489ef)
+++ uspace/srv/kbd/layout/us_qwerty.c	(revision 215abc165fc8eda817e4c859ba67ddcadb7c1e64)
@@ -33,10 +33,10 @@
 
 #include <kbd.h>
-#include <kbd/kbd.h>
-#include <kbd/keycode.h>
+#include <io/console.h>
+#include <io/keycode.h>
 #include <layout.h>
 
 static void layout_reset(void);
-static wchar_t layout_parse_ev(kbd_event_t *ev);
+static wchar_t layout_parse_ev(console_event_t *ev);
 
 layout_op_t us_qwerty_op = {
@@ -204,5 +204,5 @@
 }
 
-static wchar_t layout_parse_ev(kbd_event_t *ev)
+static wchar_t layout_parse_ev(console_event_t *ev)
 {
 	wchar_t c;
