Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 1d5a5405546f3f0a0cab965cb3a4339c902e5e26)
+++ uspace/lib/c/Makefile	(revision efb94a77e3094dd70870fe340c3efdf55682f60f)
@@ -95,4 +95,5 @@
 	generic/inetping.c \
 	generic/io/asprintf.c \
+	generic/io/input.c \
 	generic/io/io.c \
 	generic/io/chargrid.c \
Index: uspace/lib/c/generic/io/input.c
===================================================================
--- uspace/lib/c/generic/io/input.c	(revision efb94a77e3094dd70870fe340c3efdf55682f60f)
+++ uspace/lib/c/generic/io/input.c	(revision efb94a77e3094dd70870fe340c3efdf55682f60f)
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2012 Jiri Svoboda
+ * 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 libc
+ * @{
+ */
+/**
+ * @file
+ * @brief Input protocol client stub
+ */
+
+#include <async.h>
+#include <assert.h>
+#include <errno.h>
+#include <io/kbd_event.h>
+#include <io/input.h>
+#include <ipc/input.h>
+#include <stdlib.h>
+
+static void input_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg);
+
+int input_open(async_sess_t *sess, input_ev_ops_t *ev_ops,
+    void *arg, input_t **rinput)
+{
+	input_t *input = calloc(1, sizeof(input_t));
+	if (input == NULL)
+		return ENOMEM;
+
+	input->sess = sess;
+	input->ev_ops = ev_ops;
+	input->user = arg;
+
+	async_exch_t *exch = async_exchange_begin(sess);
+
+	int rc = async_connect_to_me(exch, 0, 0, 0, input_cb_conn, input);
+	async_exchange_end(exch);
+
+	if (rc != EOK)
+		goto error;
+
+	*rinput = input;
+	return EOK;
+
+error:
+	if (input != NULL)
+		free(input);
+
+	return rc;
+}
+
+void input_close(input_t *input)
+{
+	/* XXX Synchronize with input_cb_conn */
+	free(input);
+}
+
+int input_yield(input_t *input)
+{
+	async_exch_t *exch = async_exchange_begin(input->sess);
+
+	int rc = async_req_0_0(exch, INPUT_YIELD);
+	async_exchange_end(exch);
+
+	return rc;
+}
+
+int input_reclaim(input_t *input)
+{
+	async_exch_t *exch = async_exchange_begin(input->sess);
+
+	int rc = async_req_0_0(exch, INPUT_RECLAIM);
+	async_exchange_end(exch);
+
+	return rc;
+}
+
+static void input_ev_key(input_t *input, ipc_callid_t callid,
+    ipc_call_t *call)
+{
+	kbd_event_type_t type;
+	keycode_t key;
+	keymod_t mods;
+	wchar_t c;
+	int rc;
+
+	type = IPC_GET_ARG1(*call);
+	key = IPC_GET_ARG2(*call);
+	mods = IPC_GET_ARG3(*call);
+	c = IPC_GET_ARG4(*call);
+
+	rc = input->ev_ops->key(input, type, key, mods, c);
+	async_answer_0(callid, rc);
+}
+
+static void input_ev_move(input_t *input, ipc_callid_t callid,
+    ipc_call_t *call)
+{
+	int dx;
+	int dy;
+	int rc;
+
+	dx = IPC_GET_ARG1(*call);
+	dy = IPC_GET_ARG2(*call);
+
+	rc = input->ev_ops->move(input, dx, dy);
+	async_answer_0(callid, rc);
+}
+
+static void input_ev_abs_move(input_t *input, ipc_callid_t callid,
+    ipc_call_t *call)
+{
+	unsigned x;
+	unsigned y;
+	unsigned max_x;
+	unsigned max_y;
+	int rc;
+
+	x = IPC_GET_ARG1(*call);
+	y = IPC_GET_ARG2(*call);
+	max_x = IPC_GET_ARG2(*call);
+	max_y = IPC_GET_ARG3(*call);
+
+	rc = input->ev_ops->abs_move(input, x, y, max_x, max_y);
+	async_answer_0(callid, rc);
+}
+
+static void input_ev_button(input_t *input, ipc_callid_t callid,
+    ipc_call_t *call)
+{
+	int bnum;
+	int press;
+	int rc;
+
+	bnum = IPC_GET_ARG1(*call);
+	press = IPC_GET_ARG2(*call);
+
+	rc = input->ev_ops->button(input, bnum, press);
+	async_answer_0(callid, rc);
+}
+
+static void input_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
+{
+	input_t *input = (input_t *)arg;
+
+	while (true) {
+		ipc_call_t call;
+		ipc_callid_t callid = async_get_call(&call);
+
+		if (!IPC_GET_IMETHOD(call)) {
+			/* TODO: Handle hangup */
+			return;
+		}
+
+		switch (IPC_GET_IMETHOD(call)) {
+		case INPUT_EVENT_KEY:
+			input_ev_key(input, callid, &call);
+			break;
+		case INPUT_EVENT_MOVE:
+			input_ev_move(input, callid, &call);
+			break;
+		case INPUT_EVENT_ABS_MOVE:
+			input_ev_abs_move(input, callid, &call);
+			break;
+		case INPUT_EVENT_BUTTON:
+			input_ev_button(input, callid, &call);
+			break;
+		default:
+			async_answer_0(callid, ENOTSUP);
+		}
+	}
+}
+
+/** @}
+ */
Index: uspace/lib/c/include/io/console.h
===================================================================
--- uspace/lib/c/include/io/console.h	(revision 1d5a5405546f3f0a0cab965cb3a4339c902e5e26)
+++ uspace/lib/c/include/io/console.h	(revision efb94a77e3094dd70870fe340c3efdf55682f60f)
@@ -37,4 +37,5 @@
 
 #include <sys/time.h>
+#include <io/kbd_event.h>
 #include <io/keycode.h>
 #include <async.h>
@@ -70,27 +71,4 @@
 } console_ctrl_t;
 
-typedef enum {
-	KEY_PRESS,
-	KEY_RELEASE
-} kbd_event_type_t;
-
-/** Console event structure. */
-typedef struct {
-	/** List handle */
-	link_t link;
-	
-	/** Press or release event. */
-	kbd_event_type_t type;
-	
-	/** Keycode of the key that was pressed or released. */
-	keycode_t key;
-	
-	/** Bitmask of modifiers held. */
-	keymod_t mods;
-	
-	/** The character that was generated or '\0' for none. */
-	wchar_t c;
-} kbd_event_t;
-
 extern console_ctrl_t *console_init(FILE *, FILE *);
 extern void console_done(console_ctrl_t *);
Index: uspace/lib/c/include/io/input.h
===================================================================
--- uspace/lib/c/include/io/input.h	(revision efb94a77e3094dd70870fe340c3efdf55682f60f)
+++ uspace/lib/c/include/io/input.h	(revision efb94a77e3094dd70870fe340c3efdf55682f60f)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2012 Jiri Svoboda
+ * 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 libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_IO_INPUT_H_
+#define LIBC_IO_INPUT_H_
+
+#include <async.h>
+#include <io/kbd_event.h>
+#include <sys/types.h>
+
+struct input_ev_ops;
+
+typedef struct {
+	async_sess_t *sess;
+	struct input_ev_ops *ev_ops;
+	void *user;
+} input_t;
+
+typedef struct input_ev_ops {
+	int (*key)(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t);
+	int (*move)(input_t *, int, int);
+	int (*abs_move)(input_t *, unsigned, unsigned, unsigned, unsigned);
+	int (*button)(input_t *, int, int);
+} input_ev_ops_t;
+
+extern int input_open(async_sess_t *, input_ev_ops_t *, void *, input_t **);
+extern void input_close(input_t *);
+extern int input_yield(input_t *);
+extern int input_reclaim(input_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/io/kbd_event.h
===================================================================
--- uspace/lib/c/include/io/kbd_event.h	(revision efb94a77e3094dd70870fe340c3efdf55682f60f)
+++ uspace/lib/c/include/io/kbd_event.h	(revision efb94a77e3094dd70870fe340c3efdf55682f60f)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2012 Jiri Svoboda
+ * 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 libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_IO_KBD_EVENT_H_
+#define LIBC_IO_KBD_EVENT_H_
+
+#include <adt/list.h>
+#include <io/keycode.h>
+
+typedef enum {
+	KEY_PRESS,
+	KEY_RELEASE
+} kbd_event_type_t;
+
+/** Console event structure. */
+typedef struct {
+	/** List handle */
+	link_t link;
+	
+	/** Press or release event. */
+	kbd_event_type_t type;
+	
+	/** Keycode of the key that was pressed or released. */
+	keycode_t key;
+	
+	/** Bitmask of modifiers held. */
+	keymod_t mods;
+	
+	/** The character that was generated or '\0' for none. */
+	wchar_t c;
+} kbd_event_t;
+
+#endif
+
+/** @}
+ */
