Index: .bzrignore
===================================================================
--- .bzrignore	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ .bzrignore	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -9,4 +9,7 @@
 _link.ld
 ./*.iso
+_link-dlexe.ld
+_link-loader.ld
+_link-shlib.ld
 
 ./tools/__pycache__/
Index: boot/Makefile.common
===================================================================
--- boot/Makefile.common	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ boot/Makefile.common	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -157,4 +157,5 @@
 	$(USPACE_PATH)/app/usbinfo/usbinfo \
 	$(USPACE_PATH)/app/vuhid/vuh \
+	$(USPACE_PATH)/app/mkbd/mkbd \
 	$(USPACE_PATH)/app/websrv/websrv
 
Index: boot/arch/amd64/Makefile.inc
===================================================================
--- boot/arch/amd64/Makefile.inc	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ boot/arch/amd64/Makefile.inc	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -49,5 +49,4 @@
 	usbflbk \
 	usbhub \
-	usbkbd \
 	usbhid \
 	usbmast \
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/Makefile	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -59,4 +59,5 @@
 	app/websrv \
 	app/sysinfo \
+	app/mkbd \
 	srv/clip \
 	srv/devmap \
@@ -122,5 +123,4 @@
 		drv/uhci-rhd \
 		drv/usbflbk \
-		drv/usbkbd \
 		drv/usbhid \
 		drv/usbhub \
@@ -144,5 +144,4 @@
 		drv/uhci-rhd \
 		drv/usbflbk \
-		drv/usbkbd \
 		drv/usbhid \
 		drv/usbhub \
Index: uspace/app/lsusb/main.c
===================================================================
--- uspace/app/lsusb/main.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/app/lsusb/main.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -44,5 +44,5 @@
 #include <devman.h>
 #include <devmap.h>
-#include <usb/hub.h>
+#include <usb/dev/hub.h>
 #include <usb/host.h>
 
Index: uspace/app/mkbd/Makefile
===================================================================
--- uspace/app/mkbd/Makefile	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/app/mkbd/Makefile	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,44 @@
+#
+# Copyright (c) 2011 Vojtech Horky
+# 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.
+#
+
+USPACE_PREFIX = ../..
+BINARY = mkbd
+
+LIBS = \
+	$(LIBUSBDEV_PREFIX)/libusbdev.a \
+	$(LIBUSB_PREFIX)/libusb.a \
+	$(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS = \
+	-I$(LIBUSB_PREFIX)/include \
+	-I$(LIBUSBDEV_PREFIX)/include \
+	-I$(LIBDRV_PREFIX)/include
+
+SOURCES = \
+	main.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/app/mkbd/main.c
===================================================================
--- uspace/app/mkbd/main.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/app/mkbd/main.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,299 @@
+/*
+ * Copyright (c) 2011 Lubos Slovak
+ * 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 mkbd
+ * @{
+ */
+/**
+ * @file
+ * Sample application using the data from multimedia keys on keyboard
+ */
+
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <str_error.h>
+#include <bool.h>
+#include <getopt.h>
+#include <devman.h>
+#include <devmap.h>
+#include <usb/dev/hub.h>
+#include <usb/host.h>
+#include <usb/driver.h>
+#include <usb/dev/pipes.h>
+
+#define NAME "mkbd"
+
+static int dev_phone = -1;
+
+//static void print_found_hc(size_t class_index, const char *path)
+//{
+//	// printf(NAME ": host controller %zu is `%s'.\n", class_index, path);
+//	printf("Bus %02zu: %s\n", class_index, path);
+//}
+//static void print_found_dev(usb_address_t addr, const char *path)
+//{
+//	// printf(NAME ":     device with address %d is `%s'.\n", addr, path);
+//	printf("  Device %02d: %s\n", addr, path);
+//}
+
+//static void print_hc_devices(devman_handle_t hc_handle)
+//{
+//	int rc;
+//	usb_hc_connection_t conn;
+
+//	usb_hc_connection_initialize(&conn, hc_handle);
+//	rc = usb_hc_connection_open(&conn);
+//	if (rc != EOK) {
+//		printf(NAME ": failed to connect to HC: %s.\n",
+//		    str_error(rc));
+//		return;
+//	}
+//	usb_address_t addr;
+//	for (addr = 1; addr < 5; addr++) {
+//		devman_handle_t dev_handle;
+//		rc = usb_hc_get_handle_by_address(&conn, addr, &dev_handle);
+//		if (rc != EOK) {
+//			continue;
+//		}
+//		char path[MAX_PATH_LENGTH];
+//		rc = devman_get_device_path(dev_handle, path, MAX_PATH_LENGTH);
+//		if (rc != EOK) {
+//			continue;
+//		}
+//		print_found_dev(addr, path);
+//	}
+//	usb_hc_connection_close(&conn);
+//}
+
+static bool try_parse_class_and_address(const char *path,
+    devman_handle_t *out_hc_handle, usb_address_t *out_device_address)
+{
+	size_t class_index;
+	size_t address;
+	int rc;
+	char *ptr;
+
+	rc = str_size_t(path, &ptr, 10, false, &class_index);
+	if (rc != EOK) {
+		return false;
+	}
+	if ((*ptr == ':') || (*ptr == '.')) {
+		ptr++;
+	} else {
+		return false;
+	}
+	rc = str_size_t(ptr, NULL, 10, true, &address);
+	if (rc != EOK) {
+		return false;
+	}
+	rc = usb_ddf_get_hc_handle_by_class(class_index, out_hc_handle);
+	if (rc != EOK) {
+		return false;
+	}
+	if (out_device_address != NULL) {
+		*out_device_address = (usb_address_t) address;
+	}
+	return true;
+}
+
+static bool resolve_hc_handle_and_dev_addr(const char *devpath,
+    devman_handle_t *out_hc_handle, usb_address_t *out_device_address)
+{
+	int rc;
+
+	/* Hack for QEMU to save-up on typing ;-). */
+	if (str_cmp(devpath, "qemu") == 0) {
+		devpath = "/hw/pci0/00:01.2/uhci-rh/usb00_a1";
+	}
+
+	/* Hack for virtual keyboard. */
+	if (str_cmp(devpath, "virt") == 0) {
+		devpath = "/virt/usbhc/usb00_a1/usb00_a2";
+	}
+
+	if (try_parse_class_and_address(devpath,
+	    out_hc_handle, out_device_address)) {
+		return true;
+	}
+
+	char *path = str_dup(devpath);
+	if (path == NULL) {
+		return ENOMEM;
+	}
+
+	devman_handle_t hc = 0;
+	bool hc_found = false;
+	usb_address_t addr = 0;
+	bool addr_found = false;
+
+	/* Remove suffixes and hope that we will encounter device node. */
+	while (str_length(path) > 0) {
+		/* Get device handle first. */
+		devman_handle_t dev_handle;
+		rc = devman_device_get_handle(path, &dev_handle, 0);
+		if (rc != EOK) {
+			free(path);
+			return false;
+		}
+
+		/* Try to find its host controller. */
+		if (!hc_found) {
+			rc = usb_hc_find(dev_handle, &hc);
+			if (rc == EOK) {
+				hc_found = true;
+			}
+		}
+		/* Try to get its address. */
+		if (!addr_found) {
+			addr = usb_device_get_assigned_address(dev_handle);
+			if (addr >= 0) {
+				addr_found = true;
+			}
+		}
+
+		/* Speed-up. */
+		if (hc_found && addr_found) {
+			break;
+		}
+
+		/* Remove the last suffix. */
+		char *slash_pos = str_rchr(path, '/');
+		if (slash_pos != NULL) {
+			*slash_pos = 0;
+		}
+	}
+
+	free(path);
+
+	if (hc_found && addr_found) {
+		if (out_hc_handle != NULL) {
+			*out_hc_handle = hc;
+		}
+		if (out_device_address != NULL) {
+			*out_device_address = addr;
+		}
+		return true;
+	} else {
+		return false;
+	}
+}
+
+static void print_usage(char *app_name)
+{
+#define _INDENT "      "
+
+	printf(NAME ": Print out what multimedia keys were pressed.\n\n");
+	printf("Usage: %s device\n", app_name);
+	printf(_INDENT "The device is a devman path to the device.\n");
+
+#undef _OPTION
+#undef _INDENT
+}
+
+int main(int argc, char *argv[])
+{
+	
+	if (argc <= 1) {
+		print_usage(argv[0]);
+		return -1;
+	}
+	
+	char *devpath = argv[1];
+
+	/* The initialization is here only to make compiler happy. */
+	devman_handle_t hc_handle = 0;
+	usb_address_t dev_addr = 0;
+	bool found = resolve_hc_handle_and_dev_addr(devpath,
+	    &hc_handle, &dev_addr);
+	if (!found) {
+		fprintf(stderr, NAME ": device `%s' not found "
+		    "or not of USB kind. Exiting.\n", devpath);
+		return -1;
+	}
+	
+	int rc;
+	usb_hc_connection_t conn;
+
+	usb_hc_connection_initialize(&conn, hc_handle);
+	rc = usb_hc_connection_open(&conn);
+	if (rc != EOK) {
+		printf(NAME ": failed to connect to HC: %s.\n",
+		    str_error(rc));
+		return -1;
+	}
+	usb_address_t addr = 0;
+
+	devman_handle_t dev_handle;
+	rc = usb_hc_get_handle_by_address(&conn, addr, &dev_handle);
+	if (rc != EOK) {
+		printf(NAME ": failed getting handle to the device: %s.\n",
+		       str_error(rc));
+		return -1;
+	}
+
+	usb_hc_connection_close(&conn);
+	
+	rc = devman_device_connect(dev_handle, 0);
+	if (rc < 0) {
+		printf(NAME ": failed to connect to the device: %s.\n",
+		       str_error(rc));
+		return -1;
+	}
+	
+	dev_phone = rc;
+	printf("Got phone to the device: %d\n", dev_phone);
+	
+	
+//	size_t class_index = 0;
+//	size_t failed_attempts = 0;
+
+//	while (failed_attempts < MAX_FAILED_ATTEMPTS) {
+//		class_index++;
+//		devman_handle_t hc_handle = 0;
+//		int rc = usb_ddf_get_hc_handle_by_class(class_index, &hc_handle);
+//		if (rc != EOK) {
+//			failed_attempts++;
+//			continue;
+//		}
+//		char path[MAX_PATH_LENGTH];
+//		rc = devman_get_device_path(hc_handle, path, MAX_PATH_LENGTH);
+//		if (rc != EOK) {
+//			continue;
+//		}
+//		print_found_hc(class_index, path);
+//		print_hc_devices(hc_handle);
+//	}
+	
+	return 0;
+}
+
+
+/** @}
+ */
Index: uspace/app/usbinfo/desctree.c
===================================================================
--- uspace/app/usbinfo/desctree.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/app/usbinfo/desctree.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -47,5 +47,5 @@
 
 #include "usbinfo.h"
-#include <usb/dp.h>
+#include <usb/dev/dp.h>
 
 static void browse_descriptor_tree_internal(usb_dp_parser_t *parser,
Index: uspace/app/usbinfo/dev.c
===================================================================
--- uspace/app/usbinfo/dev.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/app/usbinfo/dev.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -34,8 +34,8 @@
  * Representation of queried device.
  */
-#include <usb/pipes.h>
+#include <usb/dev/pipes.h>
 #include <errno.h>
 #include <str_error.h>
-#include <usb/request.h>
+#include <usb/dev/request.h>
 #include "usbinfo.h"
 
Index: uspace/app/usbinfo/dump.c
===================================================================
--- uspace/app/usbinfo/dump.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/app/usbinfo/dump.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -47,5 +47,5 @@
 
 #include "usbinfo.h"
-#include <usb/dp.h>
+#include <usb/dev/dp.h>
 
 #define INDENT "  "
Index: uspace/app/usbinfo/info.c
===================================================================
--- uspace/app/usbinfo/info.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/app/usbinfo/info.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -37,7 +37,7 @@
 #include <str_error.h>
 #include <errno.h>
-#include <usb/pipes.h>
-#include <usb/recognise.h>
-#include <usb/request.h>
+#include <usb/dev/pipes.h>
+#include <usb/dev/recognise.h>
+#include <usb/dev/request.h>
 #include <usb/classes/classes.h>
 #include <usb/classes/hub.h>
Index: uspace/app/usbinfo/main.c
===================================================================
--- uspace/app/usbinfo/main.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/app/usbinfo/main.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -43,6 +43,6 @@
 #include <devman.h>
 #include <devmap.h>
-#include <usb/usbdevice.h>
-#include <usb/pipes.h>
+#include <usb/dev/hc.h>
+#include <usb/dev/pipes.h>
 #include <usb/host.h>
 #include <usb/driver.h>
Index: uspace/app/usbinfo/usbinfo.h
===================================================================
--- uspace/app/usbinfo/usbinfo.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/app/usbinfo/usbinfo.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -38,7 +38,7 @@
 #include <usb/usb.h>
 #include <usb/descriptor.h>
-#include <usb/pipes.h>
+#include <usb/dev/pipes.h>
 #include <usb/debug.h>
-#include <usb/dp.h>
+#include <usb/dev/dp.h>
 #include <ipc/devman.h>
 
Index: uspace/app/vuhid/hids/bootkbd.c
===================================================================
--- uspace/app/vuhid/hids/bootkbd.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/app/vuhid/hids/bootkbd.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -36,6 +36,6 @@
 #include <errno.h>
 #include <usb/debug.h>
-#include <usb/classes/hid.h>
-#include <usb/classes/hidut.h>
+#include <usb/hid/hid.h>
+#include <usb/hid/usages/core.h>
 
 #include "../report.h"
Index: uspace/app/vuhid/main.c
===================================================================
--- uspace/app/vuhid/main.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/app/vuhid/main.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -45,5 +45,5 @@
 #include <usb/debug.h>
 #include <usb/classes/classes.h>
-#include <usb/classes/hid.h>
+#include <usb/hid/hid.h>
 #include <usbvirt/device.h>
 
Index: uspace/doc/doxygroups.h
===================================================================
--- uspace/doc/doxygroups.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/doc/doxygroups.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -172,7 +172,26 @@
  */
 	/**
-	 * @defgroup libusb USB library
-	 * @ingroup usb
-	 * @brief Library for creating USB devices drivers.
+	 * @defgroup libusb Base USB library
+	 * @ingroup usb
+	 * @brief Common definitions for any driver or application
+	 * dealing with USB.
+	 */
+
+	/**
+	 * @defgroup libusbdev USB library for device drivers
+	 * @ingroup usb
+	 * @brief Library for writing drivers of endpoint devices (functions).
+	 */
+
+	/**
+	 * @defgroup libusbhost USB library for host controller drivers
+	 * @ingroup usb
+	 * @brief Library for writing host controller drivers.
+	 */
+
+	/**
+	 * @defgroup libusbhid USB library for HID devices
+	 * @ingroup usb
+	 * @brief Library for writing USB HID drivers.
 	 */
 
Index: uspace/drv/ohci/root_hub.c
===================================================================
--- uspace/drv/ohci/root_hub.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/ohci/root_hub.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -39,9 +39,9 @@
 
 #include "root_hub.h"
-#include "usb/classes/classes.h"
-#include "usb/devdrv.h"
+#include <usb/classes/classes.h>
+#include <usb/dev/driver.h>
 #include "ohci_regs.h"
 
-#include <usb/request.h>
+#include <usb/dev/request.h>
 #include <usb/classes/hub.h>
 
Index: uspace/drv/ohci/root_hub.h
===================================================================
--- uspace/drv/ohci/root_hub.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/ohci/root_hub.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -36,5 +36,5 @@
 
 #include <usb/usb.h>
-#include <usb/devdrv.h>
+#include <usb/dev/driver.h>
 
 #include "ohci_regs.h"
Index: uspace/drv/uhci-rhd/port.c
===================================================================
--- uspace/drv/uhci-rhd/port.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/uhci-rhd/port.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -40,5 +40,5 @@
 
 #include <usb/usb.h>    /* usb_address_t */
-#include <usb/hub.h>    /* usb_hc_new_device_wrapper */
+#include <usb/dev/hub.h>    /* usb_hc_new_device_wrapper */
 #include <usb/debug.h>
 
Index: uspace/drv/uhci-rhd/port.h
===================================================================
--- uspace/drv/uhci-rhd/port.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/uhci-rhd/port.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -38,5 +38,5 @@
 #include <fibril.h>
 #include <ddf/driver.h>
-#include <usb/usbdevice.h> /* usb_hc_connection_t */
+#include <usb/dev/hc.h> /* usb_hc_connection_t */
 
 typedef uint16_t port_status_t;
Index: uspace/drv/usbflbk/main.c
===================================================================
--- uspace/drv/usbflbk/main.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbflbk/main.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -34,5 +34,5 @@
  * Main routines of USB fallback driver.
  */
-#include <usb/devdrv.h>
+#include <usb/dev/driver.h>
 #include <usb/debug.h>
 #include <errno.h>
Index: uspace/drv/usbhid/Makefile
===================================================================
--- uspace/drv/usbhid/Makefile	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhid/Makefile	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -57,6 +57,6 @@
 	generic/hiddev.c \
 	mouse/mousedev.c \
-	lgtch-ultrax/lgtch-ultrax.c \
-	lgtch-ultrax/keymap.c \
+	multimedia/multimedia.c \
+	multimedia/keymap.c \
 	$(STOLEN_LAYOUT_SOURCES)
 
Index: uspace/drv/usbhid/generic/hiddev.c
===================================================================
--- uspace/drv/usbhid/generic/hiddev.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhid/generic/hiddev.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -162,5 +162,5 @@
 /*----------------------------------------------------------------------------*/
 
-int usb_generic_hid_init(usb_hid_dev_t *hid_dev)
+int usb_generic_hid_init(usb_hid_dev_t *hid_dev, void **data)
 {
 	if (hid_dev == NULL) {
@@ -173,5 +173,5 @@
 /*----------------------------------------------------------------------------*/
 
-bool usb_generic_hid_polling_callback(usb_hid_dev_t *hid_dev, 
+bool usb_generic_hid_polling_callback(usb_hid_dev_t *hid_dev, void *data, 
     uint8_t *buffer, size_t buffer_size)
 {
Index: uspace/drv/usbhid/generic/hiddev.h
===================================================================
--- uspace/drv/usbhid/generic/hiddev.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhid/generic/hiddev.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -37,5 +37,5 @@
 #define USB_HID_HIDDDEV_H_
 
-#include <usb/devdrv.h>
+#include <usb/dev/driver.h>
 
 struct usb_hid_dev;
@@ -48,7 +48,7 @@
 /*----------------------------------------------------------------------------*/
 
-int usb_generic_hid_init(struct usb_hid_dev *hid_dev);
+int usb_generic_hid_init(struct usb_hid_dev *hid_dev, void **data);
 
-bool usb_generic_hid_polling_callback(struct usb_hid_dev *hid_dev,
+bool usb_generic_hid_polling_callback(struct usb_hid_dev *hid_dev, void *data,
     uint8_t *buffer, size_t buffer_size);
 
Index: uspace/drv/usbhid/kbd/kbddev.c
===================================================================
--- uspace/drv/usbhid/kbd/kbddev.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhid/kbd/kbddev.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -46,17 +46,17 @@
 
 #include <usb/usb.h>
-#include <usb/dp.h>
-#include <usb/request.h>
-#include <usb/classes/hid.h>
-#include <usb/pipes.h>
+#include <usb/dev/dp.h>
+#include <usb/dev/request.h>
+#include <usb/hid/hid.h>
+#include <usb/dev/pipes.h>
 #include <usb/debug.h>
-#include <usb/classes/hidparser.h>
+#include <usb/hid/hidparser.h>
 #include <usb/classes/classes.h>
-#include <usb/classes/hidut.h>
-#include <usb/classes/hidreq.h>
-#include <usb/classes/hidreport.h>
-#include <usb/classes/hid/utled.h>
-
-#include <usb/devdrv.h>
+#include <usb/hid/usages/core.h>
+#include <usb/hid/request.h>
+#include <usb/hid/hidreport.h>
+#include <usb/hid/usages/led.h>
+
+#include <usb/dev/driver.h>
 
 #include "kbddev.h"
@@ -252,7 +252,6 @@
 	sysarg_t method = IPC_GET_IMETHOD(*icall);
 	
-	usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data;
-	
-	if (hid_dev == NULL || hid_dev->data == NULL) {
+	usb_kbd_t *kbd_dev = (usb_kbd_t *)fun->driver_data;
+	if (kbd_dev == NULL) {
 		usb_log_debug("default_connection_handler: "
 		    "Missing parameter.\n");
@@ -260,8 +259,4 @@
 		return;
 	}
-	
-	assert(hid_dev != NULL);
-	assert(hid_dev->data != NULL);
-	usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;
 
 	if (method == IPC_M_CONNECT_TO_ME) {
@@ -313,9 +308,9 @@
 	usb_hid_report_field_t *field = usb_hid_report_get_sibling(
 	    hid_dev->report, NULL, kbd_dev->led_path, 
-	    USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY | USB_HID_PATH_COMPARE_END,
+	    USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
 	    USB_HID_REPORT_TYPE_OUTPUT);
 	
-	while (field != NULL) {
-
+	while (field != NULL) {		
+		
 		if ((field->usage == USB_HID_LED_NUM_LOCK) 
 		    && (kbd_dev->mods & KM_NUM_LOCK)){
@@ -334,6 +329,7 @@
 		
 		field = usb_hid_report_get_sibling(hid_dev->report, field,
-		    kbd_dev->led_path, USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY 
-		    | USB_HID_PATH_COMPARE_END, USB_HID_REPORT_TYPE_OUTPUT);
+		    kbd_dev->led_path,  
+	    	USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
+			USB_HID_REPORT_TYPE_OUTPUT);
 	}
 	
@@ -662,12 +658,10 @@
  *     usb_hid_parse_report().
  */
-static void usb_kbd_process_data(usb_hid_dev_t *hid_dev,
+static void usb_kbd_process_data(usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev,
                                  uint8_t *buffer, size_t actual_size)
 {
 	assert(hid_dev->report != NULL);
 	assert(hid_dev != NULL);
-	assert(hid_dev->data != NULL);
-	
-	usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;
+	assert(kbd_dev != NULL);
 
 	usb_log_debug("Calling usb_hid_parse_report() with "
@@ -774,8 +768,9 @@
 /*----------------------------------------------------------------------------*/
 
-static int usb_kbd_create_function(usb_hid_dev_t *hid_dev)
+static int usb_kbd_create_function(usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev)
 {
 	assert(hid_dev != NULL);
 	assert(hid_dev->usb_dev != NULL);
+	assert(kbd_dev != NULL);
 	
 	/* Create the function exposed under /dev/devices. */
@@ -792,6 +787,6 @@
 	 * to the DDF function.
 	 */
-	fun->ops = &hid_dev->ops;
-	fun->driver_data = hid_dev;   // TODO: maybe change to hid_dev->data
+	fun->ops = &kbd_dev->ops;
+	fun->driver_data = kbd_dev;
 
 	int rc = ddf_fun_bind(fun);
@@ -840,5 +835,5 @@
  * @return Other value inherited from function usbhid_dev_init().
  */
-int usb_kbd_init(usb_hid_dev_t *hid_dev)
+int usb_kbd_init(usb_hid_dev_t *hid_dev, void **data)
 {
 	usb_log_debug("Initializing HID/KBD structure...\n");
@@ -865,7 +860,6 @@
 	usb_hid_report_path_set_report_id(path, 0);
 	
-	kbd_dev->key_count = usb_hid_report_input_length(
-	    hid_dev->report, path, 
-	    USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY);
+	kbd_dev->key_count = usb_hid_report_size(
+	    hid_dev->report, 0, USB_HID_REPORT_TYPE_INPUT); 
 	usb_hid_report_path_free(path);
 	
@@ -908,7 +902,6 @@
 	    kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0);
 	
-	kbd_dev->led_output_size = usb_hid_report_output_size(hid_dev->report, 
-	    kbd_dev->led_path, 
-	    USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY);
+	kbd_dev->led_output_size = usb_hid_report_size(hid_dev->report, 
+	    0, USB_HID_REPORT_TYPE_OUTPUT);
 	
 	usb_log_debug("Output report size (in items): %zu\n", 
@@ -955,8 +948,9 @@
 	
 	// save the KBD device structure into the HID device structure
-	hid_dev->data = kbd_dev;
+	//hid_dev->data = kbd_dev;
+	*data = kbd_dev;
 	
 	// set handler for incoming calls
-	hid_dev->ops.default_handler = default_connection_handler;
+	kbd_dev->ops.default_handler = default_connection_handler;
 	
 	/*
@@ -983,5 +977,5 @@
 	
 	usb_log_debug("Creating KBD function...\n");
-	int rc = usb_kbd_create_function(hid_dev);
+	int rc = usb_kbd_create_function(hid_dev, kbd_dev);
 	if (rc != EOK) {
 		usb_kbd_free(&kbd_dev);
@@ -994,14 +988,17 @@
 /*----------------------------------------------------------------------------*/
 
-bool usb_kbd_polling_callback(usb_hid_dev_t *hid_dev, uint8_t *buffer,
-     size_t buffer_size)
-{
-	if (hid_dev == NULL || buffer == NULL) {
+bool usb_kbd_polling_callback(usb_hid_dev_t *hid_dev, void *data, 
+     uint8_t *buffer, size_t buffer_size)
+{
+	if (hid_dev == NULL || buffer == NULL || data == NULL) {
 		// do not continue polling (???)
 		return false;
 	}
 	
+	usb_kbd_t *kbd_dev = (usb_kbd_t *)data;
+	assert(kbd_dev != NULL);
+	
 	// TODO: add return value from this function
-	usb_kbd_process_data(hid_dev, buffer, buffer_size);
+	usb_kbd_process_data(hid_dev, kbd_dev, buffer, buffer_size);
 	
 	return true;
@@ -1066,5 +1063,5 @@
 /*----------------------------------------------------------------------------*/
 
-void usb_kbd_deinit(usb_hid_dev_t *hid_dev)
+void usb_kbd_deinit(usb_hid_dev_t *hid_dev, void *data)
 {
 	if (hid_dev == NULL) {
@@ -1072,11 +1069,10 @@
 	}
 	
-	if (hid_dev->data != NULL) {
-		usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;
+	if (data != NULL) {
+		usb_kbd_t *kbd_dev = (usb_kbd_t *)data;
 		if (usb_kbd_is_initialized(kbd_dev)) {
 			usb_kbd_mark_unusable(kbd_dev);
 		} else {
 			usb_kbd_free(&kbd_dev);
-			hid_dev->data = NULL;
 		}
 	}
Index: uspace/drv/usbhid/kbd/kbddev.h
===================================================================
--- uspace/drv/usbhid/kbd/kbddev.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhid/kbd/kbddev.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -41,9 +41,9 @@
 #include <fibril_synch.h>
 
-#include <usb/classes/hid.h>
-#include <usb/classes/hidparser.h>
+#include <usb/hid/hid.h>
+#include <usb/hid/hidparser.h>
 #include <ddf/driver.h>
-#include <usb/pipes.h>
-#include <usb/devdrv.h>
+#include <usb/dev/pipes.h>
+#include <usb/dev/driver.h>
 
 #include "kbdrepeat.h"
@@ -83,4 +83,7 @@
 	int console_phone;
 	
+	/** @todo What is this actually? */
+	ddf_dev_ops_t ops;
+	
 	/** Information for auto-repeat of keys. */
 	usb_kbd_repeat_t repeat;
@@ -117,8 +120,8 @@
 /*----------------------------------------------------------------------------*/
 
-int usb_kbd_init(struct usb_hid_dev *hid_dev);
+int usb_kbd_init(struct usb_hid_dev *hid_dev, void **data);
 
-bool usb_kbd_polling_callback(struct usb_hid_dev *hid_dev, uint8_t *buffer,
-    size_t buffer_size);
+bool usb_kbd_polling_callback(struct usb_hid_dev *hid_dev, void *data, 
+                              uint8_t *buffer, size_t buffer_size);
 
 int usb_kbd_is_initialized(const usb_kbd_t *kbd_dev);
@@ -131,5 +134,5 @@
     int type, unsigned int key);
 
-void usb_kbd_deinit(struct usb_hid_dev *hid_dev);
+void usb_kbd_deinit(struct usb_hid_dev *hid_dev, void *data);
 
 int usb_kbd_set_boot_protocol(struct usb_hid_dev *hid_dev);
Index: uspace/drv/usbhid/kbd/main.c
===================================================================
--- uspace/drv/usbhid/kbd/main.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhid/kbd/main.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -41,5 +41,5 @@
 #include <str_error.h>
 
-#include <usb/devdrv.h>
+#include <usb/dev/driver.h>
 
 #include "kbddev.h"
Index: pace/drv/usbhid/lgtch-ultrax/keymap.c
===================================================================
--- uspace/drv/usbhid/lgtch-ultrax/keymap.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,101 +1,0 @@
-/*
- * Copyright (c) 2011 Lubos Slovak
- * 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 drvusbhid
- * @{
- */
-/** @file
- * UUSB multimedia key to keycode mapping.
- */
-
-#include <io/keycode.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <usb/debug.h>
-#include "keymap.h"
-
-/**
- * Mapping between USB HID multimedia usages (from HID Usage Tables) and 
- * corresponding HelenOS key codes.
- *
- * Currently only Usages used by Logitech UltraX keyboard are present. All other
- * should result in 0.
- */
-static int usb_hid_keymap_consumer[0x29c] = {
-	[0xf] = KC_F1, /* Just for testing purposes */
-	[0x5] = KC_F1, /* Just for testing purposes */
-	[0x8] = KC_F3, /* Just for testing purposes */
-	[0x6] = KC_F4, /* Just for testing purposes */
-	[0x7] = KC_F5, /* Just for testing purposes */
-	[0xc] = KC_F6, /* Just for testing purposes */
-	
-	[0xb5] = 0,       /* Scan Next Track */
-	[0xb6] = 0,       /* Scan Previous Track */
-	[0xb7] = 0,       /* Stop */
-	[0xb8] = 0,       /* Eject */
-	[0xcd] = KC_F2,   /* Play/Pause */
-	[0xe2] = KC_F3,   /* Mute */
-	[0xe9] = KC_F5,   /* Volume Increment */
-	[0xea] = KC_F4,   /* Volume Decrement */
-	[0x183] = 0,      /* AL Consumer Control Configuration */
-	[0x18a] = 0,      /* AL Email Reader */
-	[0x192] = 0,      /* AL Calculator */
-	[0x221] = 0,      /* AC Search */
-	[0x223] = 0,      /* AC Home */
-	[0x224] = 0,      /* AC Back */
-	[0x225] = 0,      /* AC Forward */
-	[0x226] = 0,      /* AC Stop */
-	[0x227] = KC_F1,  /* AC Refresh */
-	[0x22a] = KC_F6   /* AC Bookmarks */
-};
-
-/**
- * Translates USB HID Usages from the Consumer Page into HelenOS keycodes.
- *
- * @param usage USB HID Consumer Page Usage number.
- * 
- * @retval HelenOS key code corresponding to the given USB Consumer Page Usage.
- */
-unsigned int usb_lgtch_map_usage(int usage)
-{
-	unsigned int key;
-	int *map = usb_hid_keymap_consumer;
-	size_t map_length = sizeof(usb_hid_keymap_consumer) / sizeof(int);
-
-	if ((usage < 0) || ((size_t)usage >= map_length))
-		return -1;
-
-	/*! @todo What if the usage is not in the table? */
-	key = map[usage];
-	
-	return key;
-}
-
-/**
- * @}
- */
Index: pace/drv/usbhid/lgtch-ultrax/keymap.h
===================================================================
--- uspace/drv/usbhid/lgtch-ultrax/keymap.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/*
- * Copyright (c) 2011 Lubos Slovak
- * 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 drvusbhid
- * @{
- */
-/** @file
- * USB multimedia key to keycode mapping.
- */
-
-#ifndef USB_HID_LGTCH_ULTRAX_KEYMAP_H_
-#define USB_HID_LGTCH_ULTRAX_KEYMAP_H_
-
-unsigned int usb_lgtch_map_usage(int usage);
-
-#endif /* USB_HID_LGTCH_ULTRAX_KEYMAP_H_ */
-
-/**
- * @}
- */
Index: pace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.c
===================================================================
--- uspace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,427 +1,0 @@
-/*
- * Copyright (c) 2011 Lubos Slovak, Vojtech Horky
- * 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 drvusbhid
- * @{
- */
-/**
- * @file
- * USB Logitech UltraX Keyboard sample driver.
- */
-
-
-#include "lgtch-ultrax.h"
-#include "../usbhid.h"
-#include "keymap.h"
-
-#include <usb/classes/hidparser.h>
-#include <usb/debug.h>
-#include <usb/classes/hidut.h>
-
-#include <errno.h>
-#include <str_error.h>
-
-#include <ipc/kbd.h>
-#include <io/console.h>
-
-#define NAME "lgtch-ultrax"
-
-typedef enum usb_lgtch_flags {
-	USB_LGTCH_STATUS_UNINITIALIZED = 0,
-	USB_LGTCH_STATUS_INITIALIZED = 1,
-	USB_LGTCH_STATUS_TO_DESTROY = -1
-} usb_lgtch_flags;
-
-/*----------------------------------------------------------------------------*/
-/**
- * Logitech UltraX device type.
- */
-typedef struct usb_lgtch_ultrax_t {
-	/** Previously pressed keys (not translated to key codes). */
-	int32_t *keys_old;
-	/** Currently pressed keys (not translated to key codes). */
-	int32_t *keys;
-	/** Count of stored keys (i.e. number of keys in the report). */
-	size_t key_count;
-	
-	/** IPC phone to the console device (for sending key events). */
-	int console_phone;
-
-	/** Information for auto-repeat of keys. */
-//	usb_kbd_repeat_t repeat;
-	
-	/** Mutex for accessing the information about auto-repeat. */
-//	fibril_mutex_t *repeat_mtx;
-
-	/** State of the structure (for checking before use). 
-	 * 
-	 * 0 - not initialized
-	 * 1 - initialized
-	 * -1 - ready for destroying
-	 */
-	int initialized;
-} usb_lgtch_ultrax_t;
-
-
-/*----------------------------------------------------------------------------*/
-/** 
- * Default handler for IPC methods not handled by DDF.
- *
- * Currently recognizes only one method (IPC_M_CONNECT_TO_ME), in which case it
- * assumes the caller is the console and thus it stores IPC phone to it for 
- * later use by the driver to notify about key events.
- *
- * @param fun Device function handling the call.
- * @param icallid Call id.
- * @param icall Call data.
- */
-static void default_connection_handler(ddf_fun_t *fun,
-    ipc_callid_t icallid, ipc_call_t *icall)
-{
-	usb_log_debug(NAME " default_connection_handler()\n");
-	
-	sysarg_t method = IPC_GET_IMETHOD(*icall);
-	
-	usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data;
-	
-	if (hid_dev == NULL || hid_dev->data == NULL) {
-		async_answer_0(icallid, EINVAL);
-		return;
-	}
-	
-	assert(hid_dev != NULL);
-	assert(hid_dev->data != NULL);
-	usb_lgtch_ultrax_t *lgtch_dev = (usb_lgtch_ultrax_t *)hid_dev->data;
-
-	if (method == IPC_M_CONNECT_TO_ME) {
-		int callback = IPC_GET_ARG5(*icall);
-
-		if (lgtch_dev->console_phone != -1) {
-			async_answer_0(icallid, ELIMIT);
-			return;
-		}
-
-		lgtch_dev->console_phone = callback;
-		usb_log_debug(NAME " Saved phone to console: %d\n", callback);
-		async_answer_0(icallid, EOK);
-		return;
-	}
-	
-	async_answer_0(icallid, EINVAL);
-}
-
-/*----------------------------------------------------------------------------*/
-
-static ddf_dev_ops_t lgtch_ultrax_ops = {
-	.default_handler = default_connection_handler
-};
-
-/*----------------------------------------------------------------------------*/
-
-//static void usb_lgtch_process_keycodes(const uint8_t *key_codes, size_t count,
-//    uint8_t report_id, void *arg);
-
-//static const usb_hid_report_in_callbacks_t usb_lgtch_parser_callbacks = {
-//	.keyboard = usb_lgtch_process_keycodes
-//};
-
-///*----------------------------------------------------------------------------*/
-
-//static void usb_lgtch_process_keycodes(const uint8_t *key_codes, size_t count,
-//    uint8_t report_id, void *arg)
-//{
-//	// TODO: checks
-	
-//	usb_log_debug(NAME " Got keys from parser (report id: %u): %s\n", 
-//	    report_id, usb_debug_str_buffer(key_codes, count, 0));
-//}
-
-/*----------------------------------------------------------------------------*/
-/**
- * Processes key events.
- *
- * @note This function was copied from AT keyboard driver and modified to suit
- *       USB keyboard.
- *
- * @note Lock keys are not sent to the console, as they are completely handled
- *       in the driver. It may, however, be required later that the driver
- *       sends also these keys to application (otherwise it cannot use those
- *       keys at all).
- * 
- * @param hid_dev 
- * @param lgtch_dev 
- * @param type Type of the event (press / release). Recognized values: 
- *             KEY_PRESS, KEY_RELEASE
- * @param key Key code of the key according to HID Usage Tables.
- */
-static void usb_lgtch_push_ev(usb_hid_dev_t *hid_dev, int type, 
-    unsigned int key)
-{
-	assert(hid_dev != NULL);
-	assert(hid_dev->data != NULL);
-	
-	usb_lgtch_ultrax_t *lgtch_dev = (usb_lgtch_ultrax_t *)hid_dev->data;
-	
-	console_event_t ev;
-	
-	ev.type = type;
-	ev.key = key;
-	ev.mods = 0;
-
-	ev.c = 0;
-
-	usb_log_debug2(NAME " Sending key %d to the console\n", ev.key);
-	if (lgtch_dev->console_phone < 0) {
-		usb_log_warning(
-		    "Connection to console not ready, key discarded.\n");
-		return;
-	}
-	
-	async_msg_4(lgtch_dev->console_phone, KBD_EVENT, ev.type, ev.key, 
-	    ev.mods, ev.c);
-}
-
-/*----------------------------------------------------------------------------*/
-
-static void usb_lgtch_free(usb_lgtch_ultrax_t **lgtch_dev)
-{
-	if (lgtch_dev == NULL || *lgtch_dev == NULL) {
-		return;
-	}
-	
-	// hangup phone to the console
-	async_hangup((*lgtch_dev)->console_phone);
-	
-//	if ((*lgtch_dev)->repeat_mtx != NULL) {
-//		/* TODO: replace by some check and wait */
-//		assert(!fibril_mutex_is_locked((*lgtch_dev)->repeat_mtx));
-//		free((*lgtch_dev)->repeat_mtx);
-//	}
-	
-	// free all buffers
-	if ((*lgtch_dev)->keys != NULL) {
-		free((*lgtch_dev)->keys);
-	}
-	if ((*lgtch_dev)->keys_old != NULL) {
-		free((*lgtch_dev)->keys_old);
-	}
-
-	free(*lgtch_dev);
-	*lgtch_dev = NULL;
-}
-
-/*----------------------------------------------------------------------------*/
-
-static int usb_lgtch_create_function(usb_hid_dev_t *hid_dev)
-{
-	/* Create the function exposed under /dev/devices. */
-	ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed, 
-	    NAME);
-	if (fun == NULL) {
-		usb_log_error("Could not create DDF function node.\n");
-		return ENOMEM;
-	}
-	
-	/*
-	 * Store the initialized HID device and HID ops
-	 * to the DDF function.
-	 */
-	fun->ops = &lgtch_ultrax_ops;
-	fun->driver_data = hid_dev;   // TODO: maybe change to hid_dev->data
-	
-	int rc = ddf_fun_bind(fun);
-	if (rc != EOK) {
-		usb_log_error("Could not bind DDF function: %s.\n",
-		    str_error(rc));
-		// TODO: Can / should I destroy the DDF function?
-		ddf_fun_destroy(fun);
-		return rc;
-	}
-	
-	rc = ddf_fun_add_to_class(fun, "keyboard");
-	if (rc != EOK) {
-		usb_log_error(
-		    "Could not add DDF function to class 'keyboard': %s.\n",
-		    str_error(rc));
-		// TODO: Can / should I destroy the DDF function?
-		ddf_fun_destroy(fun);
-		return rc;
-	}
-	
-	return EOK;
-}
-
-/*----------------------------------------------------------------------------*/
-
-int usb_lgtch_init(struct usb_hid_dev *hid_dev)
-{
-	if (hid_dev == NULL || hid_dev->usb_dev == NULL) {
-		return EINVAL; /*! @todo Other return code? */
-	}
-	
-	usb_log_debug(NAME " Initializing HID/lgtch_ultrax structure...\n");
-	
-	usb_lgtch_ultrax_t *lgtch_dev = (usb_lgtch_ultrax_t *)malloc(
-	    sizeof(usb_lgtch_ultrax_t));
-	if (lgtch_dev == NULL) {
-		return ENOMEM;
-	}
-	
-	lgtch_dev->console_phone = -1;
-	
-	usb_hid_report_path_t *path = usb_hid_report_path();
-	usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_CONSUMER, 0);
-	
-	usb_hid_report_path_set_report_id(path, 1);
-	
-	lgtch_dev->key_count = usb_hid_report_input_length(
-	    hid_dev->report, path, 
-	    USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY);
-	usb_hid_report_path_free(path);
-	
-	usb_log_debug(NAME " Size of the input report: %zu\n", 
-	    lgtch_dev->key_count);
-	
-	lgtch_dev->keys = (int32_t *)calloc(lgtch_dev->key_count, 
-	    sizeof(int32_t));
-	
-	if (lgtch_dev->keys == NULL) {
-		usb_log_fatal("No memory!\n");
-		free(lgtch_dev);
-		return ENOMEM;
-	}
-	
-	lgtch_dev->keys_old = 
-		(int32_t *)calloc(lgtch_dev->key_count, sizeof(int32_t));
-	
-	if (lgtch_dev->keys_old == NULL) {
-		usb_log_fatal("No memory!\n");
-		free(lgtch_dev->keys);
-		free(lgtch_dev);
-		return ENOMEM;
-	}
-	
-	/*! @todo Autorepeat */
-	
-	// save the KBD device structure into the HID device structure
-	hid_dev->data = lgtch_dev;
-	
-	lgtch_dev->initialized = USB_LGTCH_STATUS_INITIALIZED;
-	usb_log_debug(NAME " HID/lgtch_ultrax device structure initialized.\n");
-	
-	int rc = usb_lgtch_create_function(hid_dev);
-	if (rc != EOK) {
-		usb_lgtch_free(&lgtch_dev);
-		return rc;
-	}
-	
-	usb_log_debug(NAME " HID/lgtch_ultrax structure initialized.\n");
-	
-	return EOK;
-}
-
-/*----------------------------------------------------------------------------*/
-
-void usb_lgtch_deinit(struct usb_hid_dev *hid_dev)
-{
-	if (hid_dev == NULL) {
-		return;
-	}
-	
-	if (hid_dev->data != NULL) {
-		usb_lgtch_ultrax_t *lgtch_dev = 
-		    (usb_lgtch_ultrax_t *)hid_dev->data;
-//		if (usb_kbd_is_initialized(kbd_dev)) {
-//			usb_kbd_mark_unusable(kbd_dev);
-//		} else {
-			usb_lgtch_free(&lgtch_dev);
-			hid_dev->data = NULL;
-//		}
-	}
-}
-
-/*----------------------------------------------------------------------------*/
-
-bool usb_lgtch_polling_callback(struct usb_hid_dev *hid_dev, 
-    uint8_t *buffer, size_t buffer_size)
-{
-	// TODO: checks
-	
-	usb_log_debug(NAME " usb_lgtch_polling_callback(%p, %p, %zu)\n",
-	    hid_dev, buffer, buffer_size);
-
-	usb_log_debug(NAME " Calling usb_hid_parse_report() with "
-	    "buffer %s\n", usb_debug_str_buffer(buffer, buffer_size, 0));
-	
-	usb_hid_report_path_t *path = usb_hid_report_path();
-	usb_hid_report_path_append_item(path, 0xc, 0);
-
-	uint8_t report_id;
-	
-	int rc = usb_hid_parse_report(hid_dev->report, buffer, buffer_size, 
-	    &report_id);
-	
-	if (rc != EOK) {
-		usb_log_warning(NAME "Error in usb_hid_parse_report(): %s\n", 
-		    str_error(rc));
-		return true;
-	}
-	
-	usb_hid_report_path_set_report_id(path, report_id);
-
-	usb_hid_report_field_t *field = usb_hid_report_get_sibling(
-	    hid_dev->report, NULL, path, USB_HID_PATH_COMPARE_END 
-	    | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 
-	    USB_HID_REPORT_TYPE_INPUT);
-	
-	unsigned int key;
-	
-	/*! @todo Is this iterating OK if done multiple times? 
-	 *  @todo The parsing is not OK
-	 */
-	while (field != NULL) {
-		usb_log_debug(NAME " KEY VALUE(%X) USAGE(%X)\n", field->value, 
-		    field->usage);
-		
-		key = usb_lgtch_map_usage(field->usage);
-		usb_lgtch_push_ev(hid_dev, KEY_PRESS, key);
-		
-		field = usb_hid_report_get_sibling(
-		    hid_dev->report, field, path, USB_HID_PATH_COMPARE_END
-		    | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 
-		    USB_HID_REPORT_TYPE_INPUT);
-	}	
-
-	usb_hid_report_path_free(path);
-	
-	return true;
-}
-
-/**
- * @}
- */
Index: pace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.h
===================================================================
--- uspace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,58 +1,0 @@
-/*
- * Copyright (c) 2011 Lubos Slovak
- * 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 drvusbhid
- * @{
- */
-/** @file
- * USB Logitech UltraX Keyboard sample driver.
- */
-
-#ifndef USB_HID_LGTCH_ULTRAX_H_
-#define USB_HID_LGTCH_ULTRAX_H_
-
-#include <usb/devdrv.h>
-
-struct usb_hid_dev;
-
-/*----------------------------------------------------------------------------*/
-
-int usb_lgtch_init(struct usb_hid_dev *hid_dev);
-
-void usb_lgtch_deinit(struct usb_hid_dev *hid_dev);
-
-bool usb_lgtch_polling_callback(struct usb_hid_dev *hid_dev, uint8_t *buffer,
-    size_t buffer_size);
-
-/*----------------------------------------------------------------------------*/
-
-#endif // USB_HID_LGTCH_ULTRAX_H_
-
-/**
- * @}
- */
Index: uspace/drv/usbhid/main.c
===================================================================
--- uspace/drv/usbhid/main.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhid/main.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -41,6 +41,6 @@
 #include <str_error.h>
 
-#include <usb/devdrv.h>
-#include <usb/devpoll.h>
+#include <usb/dev/driver.h>
+#include <usb/dev/poll.h>
 
 #include "usbhid.h"
Index: uspace/drv/usbhid/mouse/mousedev.c
===================================================================
--- uspace/drv/usbhid/mouse/mousedev.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhid/mouse/mousedev.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -37,7 +37,7 @@
 #include <usb/debug.h>
 #include <usb/classes/classes.h>
-#include <usb/classes/hid.h>
-#include <usb/classes/hidreq.h>
-#include <usb/classes/hidut.h>
+#include <usb/hid/hid.h>
+#include <usb/hid/request.h>
+#include <usb/hid/usages/core.h>
 #include <errno.h>
 #include <str_error.h>
@@ -122,7 +122,7 @@
 	sysarg_t method = IPC_GET_IMETHOD(*icall);
 	
-	usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data;
-	
-	if (hid_dev == NULL || hid_dev->data == NULL) {
+	usb_mouse_t *mouse_dev = (usb_mouse_t *)fun->driver_data;
+	
+	if (mouse_dev == NULL) {
 		usb_log_debug("default_connection_handler: Missing "
 		    "parameters.\n");
@@ -131,7 +131,8 @@
 	}
 	
-	assert(hid_dev != NULL);
-	assert(hid_dev->data != NULL);
-	usb_mouse_t *mouse_dev = (usb_mouse_t *)hid_dev->data;
+	usb_log_debug("default_connection_handler: fun->name: %s\n",
+	              fun->name);
+	usb_log_debug("default_connection_handler: mouse_phone: %d, wheel "
+	    "phone: %d\n", mouse_dev->mouse_phone, mouse_dev->wheel_phone);
 	
 	int *phone = (str_cmp(fun->name, HID_MOUSE_FUN_NAME) == 0) 
@@ -145,10 +146,9 @@
 			    "phone to mouse already set.\n");
 			async_answer_0(icallid, ELIMIT);
-			//async_answer_0(icallid, EOK);
 			return;
 		}
 
 		*phone = callback;
-		usb_log_debug("Console phone to mouse set ok (%d).\n", callback);
+		usb_log_debug("Console phone to mouse set ok (%d).\n", *phone);
 		async_answer_0(icallid, EOK);
 		return;
@@ -224,8 +224,9 @@
 /*----------------------------------------------------------------------------*/
 
-static bool usb_mouse_process_report(usb_hid_dev_t *hid_dev, uint8_t *buffer,
-    size_t buffer_size)
-{
-	usb_mouse_t *mouse_dev = (usb_mouse_t *)hid_dev->data;
+static bool usb_mouse_process_report(usb_hid_dev_t *hid_dev, 
+                                     usb_mouse_t *mouse_dev, uint8_t *buffer,
+                                     size_t buffer_size)
+{
+	assert(mouse_dev != NULL);
 	
 	usb_log_debug2("got buffer: %s.\n",
@@ -378,6 +379,9 @@
 /*----------------------------------------------------------------------------*/
 
-static int usb_mouse_create_function(usb_hid_dev_t *hid_dev)
-{
+static int usb_mouse_create_function(usb_hid_dev_t *hid_dev, usb_mouse_t *mouse)
+{
+	assert(hid_dev != NULL);
+	assert(mouse != NULL);
+	
 	/* Create the function exposed under /dev/devices. */
 	usb_log_debug("Creating DDF function %s...\n", HID_MOUSE_FUN_NAME);
@@ -389,10 +393,6 @@
 	}
 	
-	/*
-	 * Store the initialized HID device and HID ops
-	 * to the DDF function.
-	 */
-	fun->ops = &hid_dev->ops;
-	fun->driver_data = hid_dev;   // TODO: maybe change to hid_dev->data
+	fun->ops = &mouse->ops;
+	fun->driver_data = mouse;   // TODO: maybe change to hid_dev->data
 
 	int rc = ddf_fun_bind(fun);
@@ -431,6 +431,6 @@
 	 * to the DDF function.
 	 */
-	fun->ops = &hid_dev->ops;
-	fun->driver_data = hid_dev;   // TODO: maybe change to hid_dev->data
+	fun->ops = &mouse->ops;
+	fun->driver_data = mouse;   // TODO: maybe change to hid_dev->data
 
 	rc = ddf_fun_bind(fun);
@@ -458,5 +458,5 @@
 /*----------------------------------------------------------------------------*/
 
-int usb_mouse_init(usb_hid_dev_t *hid_dev)
+int usb_mouse_init(usb_hid_dev_t *hid_dev, void **data)
 {
 	usb_log_debug("Initializing HID/Mouse structure...\n");
@@ -485,8 +485,9 @@
 	
 	// save the Mouse device structure into the HID device structure
-	hid_dev->data = mouse_dev;
+	*data = mouse_dev;
 	
 	// set handler for incoming calls
-	hid_dev->ops.default_handler = default_connection_handler;
+	// TODO: must be one for each subdriver!!
+	mouse_dev->ops.default_handler = default_connection_handler;
 	
 	// TODO: how to know if the device supports the request???
@@ -494,5 +495,5 @@
 //	    hid_dev->usb_dev->interface_no, IDLE_RATE);
 	
-	int rc = usb_mouse_create_function(hid_dev);
+	int rc = usb_mouse_create_function(hid_dev, mouse_dev);
 	if (rc != EOK) {
 		usb_mouse_free(&mouse_dev);
@@ -505,11 +506,11 @@
 /*----------------------------------------------------------------------------*/
 
-bool usb_mouse_polling_callback(usb_hid_dev_t *hid_dev, uint8_t *buffer,
-     size_t buffer_size)
+bool usb_mouse_polling_callback(usb_hid_dev_t *hid_dev, void *data, 
+     uint8_t *buffer, size_t buffer_size)
 {
 	usb_log_debug("usb_mouse_polling_callback()\n");
 	usb_debug_str_buffer(buffer, buffer_size, 0);
 	
-	if (hid_dev == NULL) {
+	if (hid_dev == NULL || data == NULL) {
 		usb_log_error("Missing argument to the mouse polling callback."
 		    "\n");
@@ -517,18 +518,17 @@
 	}
 	
-	if (hid_dev->data == NULL) {
-		usb_log_error("Wrong argument to the mouse polling callback."
-		    "\n");
-		return false;
-	}
-	
-	return usb_mouse_process_report(hid_dev, buffer, buffer_size);
-}
-
-/*----------------------------------------------------------------------------*/
-
-void usb_mouse_deinit(usb_hid_dev_t *hid_dev)
-{
-	usb_mouse_free((usb_mouse_t **)&hid_dev->data);
+	usb_mouse_t *mouse_dev = (usb_mouse_t *)data;
+		
+	return usb_mouse_process_report(hid_dev, mouse_dev, buffer, 
+	                                buffer_size);
+}
+
+/*----------------------------------------------------------------------------*/
+
+void usb_mouse_deinit(usb_hid_dev_t *hid_dev, void *data)
+{
+	if (data != NULL) {
+		usb_mouse_free((usb_mouse_t **)&data);
+	}
 }
 
Index: uspace/drv/usbhid/mouse/mousedev.h
===================================================================
--- uspace/drv/usbhid/mouse/mousedev.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhid/mouse/mousedev.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -37,5 +37,5 @@
 #define USB_HID_MOUSEDEV_H_
 
-#include <usb/devdrv.h>
+#include <usb/dev/driver.h>
 
 struct usb_hid_dev;
@@ -52,4 +52,6 @@
 	
 	int32_t *buttons;
+	
+	ddf_dev_ops_t ops;
 } usb_mouse_t;
 
@@ -63,10 +65,10 @@
 /*----------------------------------------------------------------------------*/
 
-int usb_mouse_init(struct usb_hid_dev *hid_dev);
+int usb_mouse_init(struct usb_hid_dev *hid_dev, void **data);
 
-bool usb_mouse_polling_callback(struct usb_hid_dev *hid_dev, uint8_t *buffer,
-    size_t buffer_size);
+bool usb_mouse_polling_callback(struct usb_hid_dev *hid_dev, void *data, 
+    uint8_t *buffer, size_t buffer_size);
 
-void usb_mouse_deinit(struct usb_hid_dev *hid_dev);
+void usb_mouse_deinit(struct usb_hid_dev *hid_dev, void *data);
 
 int usb_mouse_set_boot_protocol(struct usb_hid_dev *hid_dev);
Index: uspace/drv/usbhid/multimedia/keymap.c
===================================================================
--- uspace/drv/usbhid/multimedia/keymap.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/drv/usbhid/multimedia/keymap.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,791 @@
+/*
+ * Copyright (c) 2011 Lubos Slovak
+ * 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 drvusbhid
+ * @{
+ */
+/** @file
+ * UUSB multimedia key to keycode mapping.
+ */
+
+#include <io/keycode.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <usb/debug.h>
+#include "keymap.h"
+
+/**
+ * Mapping between USB HID multimedia usages (from HID Usage Tables) and 
+ * corresponding HelenOS key codes.
+ *
+ * Currently only Usages used by Logitech UltraX keyboard are present. All other
+ * should result in 0.
+ */
+static int usb_hid_keymap_consumer[0x29c] = {
+	[0xf] = KC_F1, /* Just for testing purposes */
+	[0x5] = KC_F2, /* Just for testing purposes */
+	[0x8] = KC_F3, /* Just for testing purposes */
+	[0x6] = KC_F4, /* Just for testing purposes */
+	[0x7] = KC_F5, /* Just for testing purposes */
+	[0xc] = KC_F6, /* Just for testing purposes */
+	
+	[0xb5] = 0,       /* Scan Next Track */
+	[0xb6] = 0,       /* Scan Previous Track */
+	[0xb7] = 0,       /* Stop */
+	[0xb8] = 0,       /* Eject */
+	[0xcd] = KC_F2,   /* Play/Pause */
+	[0xe2] = KC_F3,   /* Mute */
+	[0xe9] = KC_F5,   /* Volume Increment */
+	[0xea] = KC_F4,   /* Volume Decrement */
+	[0x183] = 0,      /* AL Consumer Control Configuration */
+	[0x18a] = 0,      /* AL Email Reader */
+	[0x192] = 0,      /* AL Calculator */
+	[0x221] = 0,      /* AC Search */
+	[0x223] = 0,      /* AC Home */
+	[0x224] = 0,      /* AC Back */
+	[0x225] = 0,      /* AC Forward */
+	[0x226] = 0,      /* AC Stop */
+	[0x227] = KC_F1,  /* AC Refresh */
+	[0x22a] = KC_F6   /* AC Bookmarks */
+};
+
+static const char *usb_hid_consumer_usage_str[0x29d] = {
+	[0x01] = "Consumer Control",
+	[0x02] = "Numeric Key Pad",
+	[0x03] = "Programmable Buttons",
+	[0x04] = "Microphone",
+	[0x05] = "Headphone",
+	[0x06] = "Graphic Equalizer",
+	[0x07] = "Reserved",
+	[0x08] = "Reserved",
+	[0x09] = "Reserved",
+	[0x0a] = "Reserved",
+	[0x0b] = "Reserved",
+	[0x0c] = "Reserved",
+	[0x0d] = "Reserved",
+	[0x0e] = "Reserved",
+	[0x0f] = "Reserved",
+	[0x10] = "Reserved",
+	[0x11] = "Reserved",
+	[0x12] = "Reserved",
+	[0x13] = "Reserved",
+	[0x14] = "Reserved",
+	[0x15] = "Reserved",
+	[0x16] = "Reserved",
+	[0x17] = "Reserved",
+	[0x18] = "Reserved",
+	[0x19] = "Reserved",
+	[0x1a] = "Reserved",
+	[0x1b] = "Reserved",
+	[0x1c] = "Reserved",
+	[0x1d] = "Reserved",
+	[0x1e] = "Reserved",
+	[0x1f] = "Reserved",
+	[0x20] = "+10",
+	[0x21] = "+100",
+	[0x22] = "AM/PM",
+	[0x23] = "Reserved",
+	[0x24] = "Reserved",
+	[0x25] = "Reserved",
+	[0x26] = "Reserved",
+	[0x27] = "Reserved",
+	[0x28] = "Reserved",
+	[0x29] = "Reserved",
+	[0x2a] = "Reserved",
+	[0x2b] = "Reserved",
+	[0x2c] = "Reserved",
+	[0x2d] = "Reserved",
+	[0x2e] = "Reserved",
+	[0x2f] = "Reserved",
+	[0x30] = "Reserved",
+	[0x31] = "Reserved",
+	[0x32] = "Reserved",
+	[0x33] = "Reserved",
+	[0x34] = "Reserved",
+	[0x35] = "Reserved",
+	[0x36] = "Reserved",
+	[0x37] = "Reserved",
+	[0x38] = "Reserved",
+	[0x39] = "Reserved",
+	[0x3a] = "Reserved",
+	[0x3b] = "Reserved",
+	[0x3c] = "Reserved",
+	[0x3d] = "Reserved",
+	[0x3e] = "Reserved",
+	[0x3f] = "Reserved",
+	[0x40] = "Menu",
+	[0x41] = "Menu Pick",
+	[0x42] = "Menu Up",
+	[0x43] = "Menu Down",
+	[0x44] = "Menu Left",
+	[0x45] = "Menu Right",
+	[0x46] = "Menu Escape",
+	[0x47] = "Menu Value Increase",
+	[0x48] = "Menu Value Decrease",
+	[0x49] = "Reserved",
+	[0x4a] = "Reserved",
+	[0x4b] = "Reserved",
+	[0x4c] = "Reserved",
+	[0x4d] = "Reserved",
+	[0x4e] = "Reserved",
+	[0x4f] = "Reserved",
+	[0x50] = "Reserved",
+	[0x51] = "Reserved",
+	[0x52] = "Reserved",
+	[0x53] = "Reserved",
+	[0x54] = "Reserved",
+	[0x55] = "Reserved",
+	[0x56] = "Reserved",
+	[0x57] = "Reserved",
+	[0x58] = "Reserved",
+	[0x59] = "Reserved",
+	[0x5a] = "Reserved",
+	[0x5b] = "Reserved",
+	[0x5c] = "Reserved",
+	[0x5d] = "Reserved",
+	[0x5e] = "Reserved",
+	[0x5f] = "Reserved",
+	[0x60] = "Data On Screen",
+	[0x61] = "Closed Caption",
+	[0x62] = "Closed Caption Select",
+	[0x63] = "VCR/TV",
+	[0x64] = "Broadcast Mode",
+	[0x65] = "Snapshot",
+	[0x66] = "Still",
+	[0x67] = "Reserved",
+	[0x68] = "Reserved",
+	[0x69] = "Reserved",
+	[0x6a] = "Reserved",
+	[0x6b] = "Reserved",
+	[0x6c] = "Reserved",
+	[0x6d] = "Reserved",
+	[0x6e] = "Reserved",
+	[0x6f] = "Reserved",
+	[0x70] = "Reserved",
+	[0x71] = "Reserved",
+	[0x72] = "Reserved",
+	[0x73] = "Reserved",
+	[0x74] = "Reserved",
+	[0x75] = "Reserved",
+	[0x76] = "Reserved",
+	[0x77] = "Reserved",
+	[0x78] = "Reserved",
+	[0x79] = "Reserved",
+	[0x7a] = "Reserved",
+	[0x7b] = "Reserved",
+	[0x7c] = "Reserved",
+	[0x7d] = "Reserved",
+	[0x7e] = "Reserved",
+	[0x7f] = "Reserved",
+	[0x80] = "Selection",
+	[0x81] = "Assign Selection",
+	[0x82] = "Mode Step",
+	[0x83] = "Recall Last",
+	[0x84] = "Enter Channel",
+	[0x85] = "Order Movie",
+	[0x86] = "Channel",
+	[0x87] = "Media Selection",
+	[0x88] = "Media Select Computer",
+	[0x89] = "Media Select TV",
+	[0x8a] = "Media Select WWW",
+	[0x8b] = "Media Select DVD",
+	[0x8c] = "Media Select Telephone",
+	[0x8d] = "Media Select Program Guide",
+	[0x8e] = "Media Select Video Phone",
+	[0x8f] = "Media Select Games",
+	[0x90] = "Media Select Messages",
+	[0x91] = "Media Select CD",
+	[0x92] = "Media Select VCR",
+	[0x93] = "Media Select Tuner",
+	[0x94] = "Quit",
+	[0x95] = "Help",
+	[0x96] = "Media Select Tape",
+	[0x97] = "Media Select Cable",
+	[0x98] = "Media Select Satellite",
+	[0x99] = "Media Select Security",
+	[0x9a] = "Media Select Home",
+	[0x9b] = "Media Select Call",
+	[0x9c] = "Channel Increment",
+	[0x9d] = "Channel Decrement",
+	[0x9e] = "Media Select SAP",
+	[0x9f] = "Reserved",
+	[0xa0] = "VCR Plus",
+	[0xa1] = "Once",
+	[0xa2] = "Daily",
+	[0xa3] = "Weekly",
+	[0xa4] = "Monthly",
+	[0xa5] = "Reserved",
+	[0xa6] = "Reserved",
+	[0xa7] = "Reserved",
+	[0xa8] = "Reserved",
+	[0xa9] = "Reserved",
+	[0xaa] = "Reserved",
+	[0xab] = "Reserved",
+	[0xac] = "Reserved",
+	[0xad] = "Reserved",
+	[0xae] = "Reserved",
+	[0xaf] = "Reserved",
+	[0xb0] = "Play",
+	[0xb1] = "Pause",
+	[0xb2] = "Record",
+	[0xb3] = "Fast Forward",
+	[0xb4] = "Rewind",
+	[0xb5] = "Scan Next Track",
+	[0xb6] = "Scan Previous Trac",
+	[0xb7] = "Stop",
+	[0xb8] = "Eject",
+	[0xb9] = "Random Play",
+	[0xba] = "Select Disc",
+	[0xbb] = "Enter Disc",
+	[0xbc] = "Repeat",
+	[0xbd] = "Tracking",
+	[0xbe] = "Track Normal",
+	[0xbf] = "Slow Tracking",
+	[0xc0] = "Frame Forward",
+	[0xc1] = "Frame Back",
+	[0xc2] = "Mark",
+	[0xc3] = "Clear Mark",
+	[0xc4] = "Repeat From Mark",
+	[0xc5] = "Return to Mark",
+	[0xc6] = "Search Mark Forward",
+	[0xc7] = "Search Mark Backwards",
+	[0xc8] = "Counter Reset",
+	[0xc9] = "Show Counter",
+	[0xca] = "Tracking Increment",
+	[0xcb] = "Tracking Decrement",
+	[0xcc] = "Stop/Eject",
+	[0xcd] = "Play/Pause",
+	[0xce] = "Play/Skip",
+	[0xcf] = "Reserved",
+	[0xd0] = "Reserved",
+	[0xd1] = "Reserved",
+	[0xd2] = "Reserved",
+	[0xd3] = "Reserved",
+	[0xd4] = "Reserved",
+	[0xd5] = "Reserved",
+	[0xd6] = "Reserved",
+	[0xd7] = "Reserved",
+	[0xd8] = "Reserved",
+	[0xd9] = "Reserved",
+	[0xda] = "Reserved",
+	[0xdb] = "Reserved",
+	[0xdc] = "Reserved",
+	[0xdd] = "Reserved",
+	[0xde] = "Reserved",
+	[0xdf] = "Reserved",
+	[0xe0] = "Volume",
+	[0xe1] = "Balance",
+	[0xe2] = "Mute",
+	[0xe3] = "Bass",
+	[0xe4] = "Treble",
+	[0xe5] = "Bass Boost",
+	[0xe6] = "Surround Mode",
+	[0xe7] = "Loudness",
+	[0xe8] = "MPX",
+	[0xe9] = "Volume Increment",
+	[0xea] = "Volume Decrement",
+	[0xeb] = "Reserved",
+	[0xec] = "Reserved",
+	[0xed] = "Reserved",
+	[0xee] = "Reserved",
+	[0xef] = "Reserved",
+	[0xf0] = "Speed Select",
+	[0xf1] = "Playback Speed",
+	[0xf2] = "Standard Play",
+	[0xf3] = "Long Play",
+	[0xf4] = "Extended Play",
+	[0xf5] = "Slow",
+	[0xf6] = "Reserved",
+	[0xf7] = "Reserved",
+	[0xf8] = "Reserved",
+	[0xf9] = "Reserved",
+	[0xfa] = "Reserved",
+	[0xfb] = "Reserved",
+	[0xfc] = "Reserved",
+	[0xfd] = "Reserved",
+	[0xfe] = "Reserved",
+	[0xff] = "Reserved",
+	[0x100] = "Fan Enable",
+	[0x101] = "Fan Speed",
+	[0x102] = "Light Enable",
+	[0x103] = "Light Illumination Level",
+	[0x104] = "Climate Control Enable",
+	[0x105] = "Room Temperature",
+	[0x106] = "Security Enable",
+	[0x107] = "Fire Alarm",
+	[0x108] = "Police Alarm",
+	[0x109] = "Proximity",
+	[0x10a] = "Motion",
+	[0x10b] = "Duress Alarm",
+	[0x10c] = "Holdup Alarm",
+	[0x10d] = "Medical Alarm",
+	[0x10e] = "Reserved",
+	[0x10f] = "Reserved",
+	[0x110] = "Reserved",
+	[0x111] = "Reserved",
+	[0x112] = "Reserved",
+	[0x113] = "Reserved",
+	[0x114] = "Reserved",
+	[0x115] = "Reserved",
+	[0x116] = "Reserved",
+	[0x117] = "Reserved",
+	[0x118] = "Reserved",
+	[0x119] = "Reserved",
+	[0x11a] = "Reserved",
+	[0x11b] = "Reserved",
+	[0x11c] = "Reserved",
+	[0x11d] = "Reserved",
+	[0x11e] = "Reserved",
+	[0x11f] = "Reserved",
+	[0x120] = "Reserved", 
+	[0x121] = "Reserved",
+	[0x122] = "Reserved",
+	[0x123] = "Reserved",
+	[0x124] = "Reserved",
+	[0x125] = "Reserved",
+	[0x126] = "Reserved",
+	[0x127] = "Reserved",
+	[0x128] = "Reserved",
+	[0x129] = "Reserved",
+	[0x12a] = "Reserved",
+	[0x12b] = "Reserved",
+	[0x12c] = "Reserved",
+	[0x12d] = "Reserved",
+	[0x12e] = "Reserved",
+	[0x12f] = "Reserved",
+	[0x130] = "Reserved", 
+	[0x131] = "Reserved",
+	[0x132] = "Reserved",
+	[0x133] = "Reserved",
+	[0x134] = "Reserved",
+	[0x135] = "Reserved",
+	[0x136] = "Reserved",
+	[0x137] = "Reserved",
+	[0x138] = "Reserved",
+	[0x139] = "Reserved",
+	[0x13a] = "Reserved",
+	[0x13b] = "Reserved",
+	[0x13c] = "Reserved",
+	[0x13d] = "Reserved",
+	[0x13e] = "Reserved",
+	[0x13f] = "Reserved",
+	[0x140] = "Reserved", 
+	[0x141] = "Reserved",
+	[0x142] = "Reserved",
+	[0x143] = "Reserved",
+	[0x144] = "Reserved",
+	[0x145] = "Reserved",
+	[0x146] = "Reserved",
+	[0x147] = "Reserved",
+	[0x148] = "Reserved",
+	[0x149] = "Reserved",
+	[0x14a] = "Reserved",
+	[0x14b] = "Reserved",
+	[0x14c] = "Reserved",
+	[0x14d] = "Reserved",
+	[0x14e] = "Reserved",
+	[0x14f] = "Reserved",
+	[0x150] = "Balance Right",
+	[0x151] = "Balance Left",
+	[0x152] = "Bass Increment",
+	[0x153] = "Bass Decrement",
+	[0x154] = "Treble Increment",
+	[0x155] = "Treble Decrement",
+	[0x156] = "Reserved",
+	[0x157] = "Reserved",
+	[0x158] = "Reserved",
+	[0x159] = "Reserved",
+	[0x15a] = "Reserved",
+	[0x15b] = "Reserved",
+	[0x15c] = "Reserved",
+	[0x15d] = "Reserved",
+	[0x15e] = "Reserved",
+	[0x15f] = "Reserved",
+	[0x160] = "Speaker System",
+	[0x161] = "Channel Left",
+	[0x162] = "Channel Right",
+	[0x163] = "Channel Center",
+	[0x164] = "Channel Front",
+	[0x165] = "Channel Center Front",
+	[0x166] = "Channel Side",
+	[0x167] = "Channel Surround",
+	[0x168] = "Channel Low Frequency Enhancement",
+	[0x169] = "Channel Top",
+	[0x16a] = "Channel Unknown",
+	[0x16b] = "Reserved",
+	[0x16c] = "Reserved",
+	[0x16d] = "Reserved",
+	[0x16e] = "Reserved",
+	[0x16f] = "Reserved",
+	[0x170] = "Sub-channel",
+	[0x171] = "Sub-channel Increment",
+	[0x172] = "Sub-channel Decrement",
+	[0x173] = "Alternate Audio Increment",
+	[0x174] = "Alternate Audio Decrement",
+	[0x175] = "Reserved",
+	[0x176] = "Reserved",
+	[0x177] = "Reserved",
+	[0x178] = "Reserved",
+	[0x179] = "Reserved",
+	[0x17a] = "Reserved",
+	[0x17b] = "Reserved",
+	[0x17c] = "Reserved",
+	[0x17d] = "Reserved",
+	[0x17e] = "Reserved",
+	[0x17f] = "Reserved",
+	[0x180] = "Application Launch Buttons",
+	[0x181] = "AL Launch Buttion Configuration Tool",
+	[0x182] = "AL Programmable Button Configuration",
+	[0x183] = "AL Consumer Control Configuration",
+	[0x184] = "AL Word Processor",
+	[0x185] = "AL Text Editor",
+	[0x186] = "AL Spreadsheet",
+	[0x187] = "AL Graphics Editor",
+	[0x188] = "AL Presentation App",
+	[0x189] = "AL Database App",
+	[0x18a] = "AL Email Reader",
+	[0x18b] = "AL Newsreader",
+	[0x18c] = "AL Voicemail",
+	[0x18d] = "AL Contacts/Address Book",
+	[0x18e] = "AL Calendar/Schedule",
+	[0x18f] = "AL Task/Project Manager",
+	[0x190] = "AL Log/Journal/Timecard",
+	[0x191] = "AL Checkbook/Finance",
+	[0x192] = "AL Calculator",
+	[0x193] = "AL A/V Capture/Playback",
+	[0x194] = "AL Local Machine Browser",
+	[0x195] = "AL LAN/WAN Browser",
+	[0x196] = "AL Internet Browser",
+	[0x197] = "AL Remote Networking/ISP Connect",
+	[0x198] = "AL Network Conference",
+	[0x199] = "AL Network Chat",
+	[0x19a] = "AL Telephony/Dialer",
+	[0x19b] = "AL Logon",
+	[0x19c] = "AL Logoff",
+	[0x19d] = "AL Logon/Logoff",
+	[0x19e] = "AL Terminal Lock/Screensaver",
+	[0x19f] = "AL Control Panel",
+	[0x1a0] = "AL Command Line Processor/Run",
+	[0x1a1] = "AL Process/Task Manager",
+	[0x1a2] = "AL Select Task/Application",
+	[0x1a3] = "AL Next Task/Application",
+	[0x1a4] = "AL Previous Task/Application",
+	[0x1a5] = "AL Preemptive Halt Task/Application",
+	[0x1a6] = "AL Integrated Help Center",
+	[0x1a7] = "AL Documents",
+	[0x1a8] = "AL Thesaurus",
+	[0x1a9] = "AL Dictionary",
+	[0x1aa] = "AL Desktop",
+	[0x1ab] = "AL Spell Check",
+	[0x1ac] = "AL Grammar Check",
+	[0x1ad] = "AL Wireless Status",
+	[0x1ae] = "AL Keyboard Layout",
+	[0x1af] = "AL Virus Protection",
+	[0x1b0] = "AL Encryption",
+	[0x1b1] = "AL Screen Saver",
+	[0x1b2] = "AL Alarms",
+	[0x1b3] = "AL Clock",
+	[0x1b4] = "AL File Browser",
+	[0x1b5] = "AL Power Status",
+	[0x1b6] = "AL Image Browser",
+	[0x1b7] = "AL Audio Browser",
+	[0x1b8] = "AL Movie Browser",
+	[0x1b9] = "AL Digital Rights Manager",
+	[0x1ba] = "AL Digital Wallet",
+	[0x1bb] = "Reserved",
+	[0x1bc] = "AL Instant Messaging",
+	[0x1bd] = "AL OEM Features Tips/Tutorial Browser",
+	[0x1be] = "AL OEM Help",
+	[0x1bf] = "AL Online Community",
+	[0x1c0] = "AL Entertainment Content Browser",
+	[0x1c1] = "AL Online Shopping Browser",
+	[0x1c2] = "AL SmartCard Information/Help",
+	[0x1c3] = "AL Market Monitor/Finance Browser",
+	[0x1c4] = "AL Customized Corporate News Browser",
+	[0x1c5] = "AL Online Activity Browser",
+	[0x1c6] = "AL Research/Search Browser",
+	[0x1c7] = "AL Audio Player",
+	[0x1c8] = "Reserved",
+	[0x1c9] = "Reserved",
+	[0x1ca] = "Reserved",
+	[0x1cb] = "Reserved",
+	[0x1cc] = "Reserved",
+	[0x1cd] = "Reserved",
+	[0x1ce] = "Reserved",
+	[0x1cf] = "Reserved",
+	[0x1d0] = "Reserved",
+	[0x1d1] = "Reserved",
+	[0x1d2] = "Reserved",
+	[0x1d3] = "Reserved",
+	[0x1d4] = "Reserved",
+	[0x1d5] = "Reserved",
+	[0x1d6] = "Reserved",
+	[0x1d7] = "Reserved",
+	[0x1d8] = "Reserved",
+	[0x1d9] = "Reserved",
+	[0x1da] = "Reserved",
+	[0x1db] = "Reserved",
+	[0x1dc] = "Reserved",
+	[0x1dd] = "Reserved",
+	[0x1de] = "Reserved",
+	[0x1df] = "Reserved",
+	[0x1e0] = "Reserved",
+	[0x1e1] = "Reserved",
+	[0x1e2] = "Reserved",
+	[0x1e3] = "Reserved",
+	[0x1e4] = "Reserved",
+	[0x1e5] = "Reserved",
+	[0x1e6] = "Reserved",
+	[0x1e7] = "Reserved",
+	[0x1e8] = "Reserved",
+	[0x1e9] = "Reserved",
+	[0x1ea] = "Reserved",
+	[0x1eb] = "Reserved",
+	[0x1ec] = "Reserved",
+	[0x1ed] = "Reserved",
+	[0x1ee] = "Reserved",
+	[0x1ef] = "Reserved",
+	[0x1f0] = "Reserved",
+	[0x1f1] = "Reserved",
+	[0x1f2] = "Reserved",
+	[0x1f3] = "Reserved",
+	[0x1f4] = "Reserved",
+	[0x1f5] = "Reserved",
+	[0x1f6] = "Reserved",
+	[0x1f7] = "Reserved",
+	[0x1f8] = "Reserved",
+	[0x1f9] = "Reserved",
+	[0x1fa] = "Reserved",
+	[0x1fb] = "Reserved",
+	[0x1fc] = "Reserved",
+	[0x1fd] = "Reserved",
+	[0x1fe] = "Reserved",
+	[0x1ff] = "Reserved",
+	[0x200] = "Generic GUI Application Controls",
+	[0x201] = "AC New",
+	[0x202] = "AC Open",
+	[0x203] = "AC Close",
+	[0x204] = "AC Exit",
+	[0x205] = "AC Maximize",
+	[0x206] = "AC Minimize",
+	[0x207] = "AC Save",
+	[0x208] = "AC Print",
+	[0x209] = "AC Properties",
+	[0x20a] = "",
+	[0x20b] = "",
+	[0x20c] = "",
+	[0x20d] = "",
+	[0x20e] = "",
+	[0x20f] = "",
+	[0x210] = "",
+	[0x211] = "",
+	[0x212] = "",
+	[0x213] = "",
+	[0x214] = "",
+	[0x215] = "",
+	[0x216] = "",
+	[0x217] = "",
+	[0x218] = "",
+	[0x219] = "",
+	[0x21a] = "AC Undo",
+	[0x21b] = "AC Copy",
+	[0x21c] = "AC Cut",
+	[0x21d] = "AC Paste",
+	[0x21e] = "AC Select All",
+	[0x21f] = "AC Find",
+	[0x220] = "AC Find and Replace",
+	[0x221] = "AC Search",
+	[0x222] = "AC Go To",
+	[0x223] = "AC Home",
+	[0x224] = "AC Back",
+	[0x225] = "AC Forward",
+	[0x226] = "AC Stop",
+	[0x227] = "AC Refresh",
+	[0x228] = "AC Previous Link",
+	[0x229] = "AC Next Link",
+	[0x22a] = "AC Bookmarks",
+	[0x22b] = "AC History",
+	[0x22c] = "AC Subscriptions",
+	[0x22d] = "AC Zoom In",
+	[0x22e] = "AC Zoom Out",
+	[0x22f] = "AC Zoom",
+	[0x230] = "AC Full Screen View",
+	[0x231] = "AC Normal View",
+	[0x232] = "AC View Toggle",
+	[0x233] = "AC Scroll Up",
+	[0x234] = "AC Scroll Down",
+	[0x235] = "AC Scroll",
+	[0x236] = "AC Pan Left",
+	[0x237] = "AC Pan Right",
+	[0x238] = "AC Pan",
+	[0x239] = "AC New Window",
+	[0x23a] = "AC Tile Horizontally",
+	[0x23b] = "AC Tile Vertically",
+	[0x23c] = "AC Format",
+	[0x23d] = "AC Edit",
+	[0x23e] = "AC Bold",
+	[0x23f] = "AC Italics",
+	[0x240] = "AC Undeline",
+	[0x241] = "AC Strikethrough",
+	[0x242] = "AC Subscript",
+	[0x243] = "AC Superscript",
+	[0x244] = "AC All Caps",
+	[0x245] = "AC Rotate",
+	[0x246] = "AC Resize",
+	[0x247] = "AC Flip Horizontal",
+	[0x248] = "AC Flip Vertical",
+	[0x249] = "AC Mirror Horizontal",
+	[0x24a] = "AC Mirror Vertical",
+	[0x24b] = "AC Font Select",
+	[0x24c] = "AC Font Color",
+	[0x24d] = "AC Font Size",
+	[0x24e] = "AC Justify Left",
+	[0x24f] = "AC Justify Center H",
+	[0x250] = "AC Justify Right",
+	[0x251] = "AC Justify Block H",
+	[0x252] = "AC Justify Top",
+	[0x253] = "AC Justify Center V",
+	[0x254] = "AC Justify Bottom",
+	[0x255] = "AC Justify Block V",
+	[0x256] = "AC Indent Decrease",
+	[0x257] = "AC Indent Increase",
+	[0x258] = "AC Numbered List",
+	[0x259] = "AC Restart Numbering",
+	[0x25a] = "AC Bulleted List",
+	[0x25b] = "AC Promote",
+	[0x25c] = "AC Demote",
+	[0x25d] = "AC Yes",
+	[0x25e] = "AC No",
+	[0x25f] = "AC Cancel",
+	[0x260] = "AC Catalog",
+	[0x261] = "AC Buy/Checkout",
+	[0x262] = "AC Add to Cart",
+	[0x263] = "AC Expand",
+	[0x264] = "AC Expand All",
+	[0x265] = "AC Collapse",
+	[0x266] = "AC Collapse All",
+	[0x267] = "AC Print Preview",
+	[0x268] = "AC Paste Special",
+	[0x269] = "AC Insert Mode",
+	[0x26a] = "AC Delete",
+	[0x26b] = "AC Lock",
+	[0x26c] = "AC Unlock",
+	[0x26d] = "AC Protect",
+	[0x26e] = "AC Unprotect",
+	[0x26f] = "AC Attach Comment",
+	[0x270] = "AC Delete Comment",
+	[0x271] = "AC View Comment",
+	[0x272] = "AC Select Word",
+	[0x273] = "AC Select Sentence",
+	[0x274] = "AC Select Paragraph",
+	[0x275] = "AC Select Column",
+	[0x276] = "AC Select Row",
+	[0x277] = "AC Select Table",
+	[0x278] = "AC Select Object",
+	[0x279] = "AC Redo/Repeat",
+	[0x27a] = "AC Sort",
+	[0x27b] = "AC Sort Ascending",
+	[0x27c] = "AC Sort Descending",
+	[0x27d] = "AC Filter",
+	[0x27e] = "AC Set Clock",
+	[0x27f] = "AC View Clock",
+	[0x280] = "AC Select Time Zone",
+	[0x281] = "AC Edit Time Zones",
+	[0x282] = "AC Set Alarm",
+	[0x283] = "AC Clear Alarm",
+	[0x284] = "AC Snooze Alarm",
+	[0x285] = "AC Reset Alarm",
+	[0x286] = "AC Synchronize",
+	[0x287] = "AC Send/Receive",
+	[0x288] = "AC Send To",
+	[0x289] = "AC Reply",
+	[0x28a] = "AC Reply All",
+	[0x28b] = "AC Forward Msg",
+	[0x28c] = "AC Send",
+	[0x28d] = "AC Attach File",
+	[0x28e] = "AC Upload",
+	[0x28f] = "AC Download (Save Target As)",
+	[0x290] = "AC Set Borders",
+	[0x291] = "AC Insert Row",
+	[0x292] = "AC Insert Column",
+	[0x293] = "AC Insert File",
+	[0x294] = "AC Insert Picture",
+	[0x295] = "AC Insert Object",
+	[0x296] = "AC Insert Symbol",
+	[0x297] = "AC Save and Close",
+	[0x298] = "AC Rename",
+	[0x299] = "AC Merge",
+	[0x29a] = "AC Split",
+	[0x29b] = "AC Distrubute Horizontally",
+	[0x29c] = "AC Distrubute Vertically"
+};
+
+/**
+ * Translates USB HID Usages from the Consumer Page into HelenOS keycodes.
+ *
+ * @param usage USB HID Consumer Page Usage number.
+ * 
+ * @retval HelenOS key code corresponding to the given USB Consumer Page Usage.
+ */
+unsigned int usb_multimedia_map_usage(int usage)
+{
+	unsigned int key;
+	int *map = usb_hid_keymap_consumer;
+	size_t map_length = sizeof(usb_hid_keymap_consumer) / sizeof(int);
+
+	if ((usage < 0) || ((size_t)usage >= map_length))
+		return -1;
+
+	/*! @todo What if the usage is not in the table? */
+	key = map[usage];
+	
+	return key;
+}
+
+/**
+ * Translates USB HID Usages from the Consumer Page into their string 
+ * representation.
+ *
+ * @param usage USB HID Consumer Page Usage number.
+ * 
+ * @retval HelenOS key code corresponding to the given USB Consumer Page Usage.
+ */
+const char *usb_multimedia_usage_to_str(int usage)
+{
+	size_t map_length = sizeof(usb_hid_consumer_usage_str) / sizeof(char *);
+
+	if ((usage < 0) || ((size_t)usage >= map_length))
+		return "Unknown usage";
+
+	/*! @todo What if the usage is not in the table? */
+	return usb_hid_consumer_usage_str[usage];
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/usbhid/multimedia/keymap.h
===================================================================
--- uspace/drv/usbhid/multimedia/keymap.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/drv/usbhid/multimedia/keymap.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2011 Lubos Slovak
+ * 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 drvusbhid
+ * @{
+ */
+/** @file
+ * USB multimedia key to keycode mapping.
+ */
+
+#ifndef USB_HID_MULTIMEDIA_KEYMAP_H_
+#define USB_HID_MULTIMEDIA_KEYMAP_H_
+
+unsigned int usb_multimedia_map_usage(int usage);
+
+const char *usb_multimedia_usage_to_str(int usage);
+
+#endif /* USB_HID_MULTIMEDIA_KEYMAP_H_ */
+
+/**
+ * @}
+ */
Index: uspace/drv/usbhid/multimedia/multimedia.c
===================================================================
--- uspace/drv/usbhid/multimedia/multimedia.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/drv/usbhid/multimedia/multimedia.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,378 @@
+/*
+ * Copyright (c) 2011 Lubos Slovak, Vojtech Horky
+ * 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 drvusbhid
+ * @{
+ */
+/**
+ * @file
+ * USB Keyboard multimedia keys subdriver.
+ */
+
+
+#include "multimedia.h"
+#include "../usbhid.h"
+#include "keymap.h"
+
+#include <usb/hid/hidparser.h>
+#include <usb/debug.h>
+#include <usb/hid/usages/core.h>
+
+#include <errno.h>
+#include <str_error.h>
+
+#include <ipc/kbd.h>
+#include <io/console.h>
+
+#define NAME "multimedia-keys"
+
+/*----------------------------------------------------------------------------*/
+/**
+ * Logitech UltraX device type.
+ */
+typedef struct usb_multimedia_t {
+	/** Previously pressed keys (not translated to key codes). */
+	int32_t *keys_old;
+	/** Currently pressed keys (not translated to key codes). */
+	int32_t *keys;
+	/** Count of stored keys (i.e. number of keys in the report). */
+	size_t key_count;	
+	/** IPC phone to the console device (for sending key events). */
+	int console_phone;
+} usb_multimedia_t;
+
+
+/*----------------------------------------------------------------------------*/
+/** 
+ * Default handler for IPC methods not handled by DDF.
+ *
+ * Currently recognizes only one method (IPC_M_CONNECT_TO_ME), in which case it
+ * assumes the caller is the console and thus it stores IPC phone to it for 
+ * later use by the driver to notify about key events.
+ *
+ * @param fun Device function handling the call.
+ * @param icallid Call id.
+ * @param icall Call data.
+ */
+static void default_connection_handler(ddf_fun_t *fun,
+    ipc_callid_t icallid, ipc_call_t *icall)
+{
+	usb_log_debug(NAME " default_connection_handler()\n");
+	
+	sysarg_t method = IPC_GET_IMETHOD(*icall);
+	
+	usb_multimedia_t *multim_dev = (usb_multimedia_t *)fun->driver_data;
+	//usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data;
+	
+	if (multim_dev == NULL) {
+		async_answer_0(icallid, EINVAL);
+		return;
+	}
+
+	if (method == IPC_M_CONNECT_TO_ME) {
+		int callback = IPC_GET_ARG5(*icall);
+
+		if (multim_dev->console_phone != -1) {
+			async_answer_0(icallid, ELIMIT);
+			return;
+		}
+
+		multim_dev->console_phone = callback;
+		usb_log_debug(NAME " Saved phone to console: %d\n", callback);
+		async_answer_0(icallid, EOK);
+		return;
+	}
+	
+	async_answer_0(icallid, EINVAL);
+}
+
+/*----------------------------------------------------------------------------*/
+
+static ddf_dev_ops_t multimedia_ops = {
+	.default_handler = default_connection_handler
+};
+
+/*----------------------------------------------------------------------------*/
+/**
+ * Processes key events.
+ *
+ * @note This function was copied from AT keyboard driver and modified to suit
+ *       USB keyboard.
+ *
+ * @note Lock keys are not sent to the console, as they are completely handled
+ *       in the driver. It may, however, be required later that the driver
+ *       sends also these keys to application (otherwise it cannot use those
+ *       keys at all).
+ * 
+ * @param hid_dev 
+ * @param lgtch_dev 
+ * @param type Type of the event (press / release). Recognized values: 
+ *             KEY_PRESS, KEY_RELEASE
+ * @param key Key code of the key according to HID Usage Tables.
+ */
+static void usb_multimedia_push_ev(usb_hid_dev_t *hid_dev, 
+    usb_multimedia_t *multim_dev, int type, unsigned int key)
+{
+	assert(hid_dev != NULL);
+	assert(multim_dev != NULL);
+	
+//	usb_multimedia_t *multim_dev = (usb_multimedia_t *)hid_dev->data;
+	
+	console_event_t ev;
+	
+	ev.type = type;
+	ev.key = key;
+	ev.mods = 0;
+	ev.c = 0;
+
+	usb_log_debug2(NAME " Sending key %d to the console\n", ev.key);
+	if (multim_dev->console_phone < 0) {
+		usb_log_warning(
+		    "Connection to console not ready, key discarded.\n");
+		return;
+	}
+	
+	async_msg_4(multim_dev->console_phone, KBD_EVENT, ev.type, ev.key, 
+	    ev.mods, ev.c);
+}
+
+/*----------------------------------------------------------------------------*/
+
+static void usb_multimedia_free(usb_multimedia_t **multim_dev)
+{
+	if (multim_dev == NULL || *multim_dev == NULL) {
+		return;
+	}
+	
+	// hangup phone to the console
+	async_hangup((*multim_dev)->console_phone);
+	
+	// free all buffers
+	if ((*multim_dev)->keys != NULL) {
+		free((*multim_dev)->keys);
+	}
+	if ((*multim_dev)->keys_old != NULL) {
+		free((*multim_dev)->keys_old);
+	}
+
+	free(*multim_dev);
+	*multim_dev = NULL;
+}
+
+/*----------------------------------------------------------------------------*/
+
+static int usb_multimedia_create_function(usb_hid_dev_t *hid_dev, 
+    usb_multimedia_t *multim_dev)
+{
+	/* Create the function exposed under /dev/devices. */
+	ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed, 
+	    NAME);
+	if (fun == NULL) {
+		usb_log_error("Could not create DDF function node.\n");
+		return ENOMEM;
+	}
+	
+	fun->ops = &multimedia_ops;
+	fun->driver_data = multim_dev;   // TODO: maybe change to hid_dev->data
+	
+	int rc = ddf_fun_bind(fun);
+	if (rc != EOK) {
+		usb_log_error("Could not bind DDF function: %s.\n",
+		    str_error(rc));
+		// TODO: Can / should I destroy the DDF function?
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+	
+	rc = ddf_fun_add_to_class(fun, "keyboard");
+	if (rc != EOK) {
+		usb_log_error(
+		    "Could not add DDF function to class 'keyboard': %s.\n",
+		    str_error(rc));
+		// TODO: Can / should I destroy the DDF function?
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+	
+	return EOK;
+}
+
+/*----------------------------------------------------------------------------*/
+
+int usb_multimedia_init(struct usb_hid_dev *hid_dev, void **data)
+{
+	if (hid_dev == NULL || hid_dev->usb_dev == NULL) {
+		return EINVAL; /*! @todo Other return code? */
+	}
+	
+	usb_log_debug(NAME " Initializing HID/multimedia structure...\n");
+	
+	usb_multimedia_t *multim_dev = (usb_multimedia_t *)malloc(
+	    sizeof(usb_multimedia_t));
+	if (multim_dev == NULL) {
+		return ENOMEM;
+	}
+	
+	multim_dev->console_phone = -1;
+	
+	usb_hid_report_path_t *path = usb_hid_report_path();
+	usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_CONSUMER, 0);
+	
+	usb_hid_report_path_set_report_id(path, 1);
+	
+	multim_dev->key_count = usb_hid_report_size(
+	    hid_dev->report, 0, USB_HID_REPORT_TYPE_INPUT);
+
+	usb_hid_report_path_free(path);
+	
+	usb_log_debug(NAME " Size of the input report: %zu\n", 
+	    multim_dev->key_count);
+	
+	multim_dev->keys = (int32_t *)calloc(multim_dev->key_count, 
+	    sizeof(int32_t));
+	
+	if (multim_dev->keys == NULL) {
+		usb_log_fatal("No memory!\n");
+		free(multim_dev);
+		return ENOMEM;
+	}
+	
+	multim_dev->keys_old = 
+		(int32_t *)calloc(multim_dev->key_count, sizeof(int32_t));
+	
+	if (multim_dev->keys_old == NULL) {
+		usb_log_fatal("No memory!\n");
+		free(multim_dev->keys);
+		free(multim_dev);
+		return ENOMEM;
+	}
+	
+	/*! @todo Autorepeat */
+	
+	// save the KBD device structure into the HID device structure
+	*data = multim_dev;
+	
+	usb_log_debug(NAME " HID/multimedia device structure initialized.\n");
+	
+	int rc = usb_multimedia_create_function(hid_dev, multim_dev);
+	if (rc != EOK) {
+		usb_multimedia_free(&multim_dev);
+		return rc;
+	}
+	
+	usb_log_debug(NAME " HID/multimedia structure initialized.\n");
+	
+	return EOK;
+}
+
+/*----------------------------------------------------------------------------*/
+
+void usb_multimedia_deinit(struct usb_hid_dev *hid_dev, void *data)
+{
+	if (hid_dev == NULL) {
+		return;
+	}
+	
+	if (data != NULL) {
+		usb_multimedia_t *multim_dev = (usb_multimedia_t *)data;
+		usb_multimedia_free(&multim_dev);
+	}
+}
+
+/*----------------------------------------------------------------------------*/
+
+bool usb_multimedia_polling_callback(struct usb_hid_dev *hid_dev, void *data, 
+    uint8_t *buffer, size_t buffer_size)
+{
+	// TODO: checks
+	
+	usb_log_debug(NAME " usb_lgtch_polling_callback(%p, %p, %zu)\n",
+	    hid_dev, buffer, buffer_size);
+	
+	if (data == NULL) {
+		return EINVAL;	// TODO: other error code?
+	}
+	
+	usb_multimedia_t *multim_dev = (usb_multimedia_t *)data;
+
+	usb_log_debug(NAME " Calling usb_hid_parse_report() with "
+	    "buffer %s\n", usb_debug_str_buffer(buffer, buffer_size, 0));
+	
+	usb_hid_report_path_t *path = usb_hid_report_path();
+	usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_CONSUMER, 0);
+
+	uint8_t report_id;
+	
+	int rc = usb_hid_parse_report(hid_dev->report, buffer, buffer_size, 
+	    &report_id);
+	
+	if (rc != EOK) {
+		usb_log_warning(NAME "Error in usb_hid_parse_report(): %s\n", 
+		    str_error(rc));
+		return true;
+	}
+	
+	usb_hid_report_path_set_report_id(path, report_id);
+
+	usb_hid_report_field_t *field = usb_hid_report_get_sibling(
+	    hid_dev->report, NULL, path, USB_HID_PATH_COMPARE_END 
+	    | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 
+	    USB_HID_REPORT_TYPE_INPUT);
+	
+//	unsigned int key;
+	
+	/*! @todo Is this iterating OK if done multiple times? 
+	 *  @todo The parsing is not OK
+	 */
+	while (field != NULL) {
+		if(field->value != 0) {
+			usb_log_debug(NAME " KEY VALUE(%X) USAGE(%X)\n", 
+			    field->value, field->usage);
+			unsigned int key = 
+			    usb_multimedia_map_usage(field->usage);
+			const char *key_str = 
+			    usb_multimedia_usage_to_str(field->usage);
+			usb_log_info("Pressed key: %s\n", key_str);
+			usb_multimedia_push_ev(hid_dev, multim_dev, KEY_PRESS, 
+			                       key);
+		}
+		
+		field = usb_hid_report_get_sibling(
+		    hid_dev->report, field, path, USB_HID_PATH_COMPARE_END
+		    | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 
+		    USB_HID_REPORT_TYPE_INPUT);
+	}	
+
+	usb_hid_report_path_free(path);
+	
+	return true;
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/usbhid/multimedia/multimedia.h
===================================================================
--- uspace/drv/usbhid/multimedia/multimedia.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/drv/usbhid/multimedia/multimedia.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011 Lubos Slovak
+ * 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 drvusbhid
+ * @{
+ */
+/** @file
+ * USB Keyboard multimedia keys subdriver.
+ */
+
+#ifndef USB_HID_MULTIMEDIA_H_
+#define USB_HID_MULTIMEDIA_H_
+
+#include <usb/dev/driver.h>
+
+struct usb_hid_dev;
+
+/*----------------------------------------------------------------------------*/
+
+int usb_multimedia_init(struct usb_hid_dev *hid_dev, void **data);
+
+void usb_multimedia_deinit(struct usb_hid_dev *hid_dev, void *data);
+
+bool usb_multimedia_polling_callback(struct usb_hid_dev *hid_dev, void *data,
+    uint8_t *buffer, size_t buffer_size);
+
+/*----------------------------------------------------------------------------*/
+
+#endif // USB_HID_MULTIMEDIA_H_
+
+/**
+ * @}
+ */
Index: uspace/drv/usbhid/subdrivers.c
===================================================================
--- uspace/drv/usbhid/subdrivers.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhid/subdrivers.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -35,22 +35,24 @@
 
 #include "subdrivers.h"
-#include "usb/classes/hidut.h"
-#include "usb/classes/hidpath.h"
+#include <usb/hid/usages/core.h>
+#include <usb/hid/hidpath.h>
 
-#include "lgtch-ultrax/lgtch-ultrax.h"
+//#include "lgtch-ultrax/lgtch-ultrax.h"
+#include "multimedia/multimedia.h"
 #include "mouse/mousedev.h"
 
 static usb_hid_subdriver_usage_t path_kbd[] = {
-	{USB_HIDUT_PAGE_KEYBOARD, 0}, 
+	{USB_HIDUT_PAGE_GENERIC_DESKTOP, 
+	 USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYBOARD}, 
 	{0, 0}
 };
 
-static usb_hid_subdriver_usage_t path_mouse2[] = {
-	{USB_HIDUT_PAGE_GENERIC_DESKTOP, USB_HIDUT_USAGE_GENERIC_DESKTOP_X},
+static usb_hid_subdriver_usage_t path_mouse[] = {
+	{USB_HIDUT_PAGE_GENERIC_DESKTOP, USB_HIDUT_USAGE_GENERIC_DESKTOP_MOUSE},
 	{0, 0}
 };
 
-static usb_hid_subdriver_usage_t lgtch_path[] = {
-	{0xc, 0},
+static usb_hid_subdriver_usage_t multim_key_path[] = {
+	{USB_HIDUT_PAGE_CONSUMER, USB_HIDUT_USAGE_CONSUMER_CONSUMER_CONTROL},
 	{0, 0}
 };
@@ -60,6 +62,5 @@
 		path_kbd,
 		-1,
-		USB_HID_PATH_COMPARE_END 
-		| USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
+		USB_HID_PATH_COMPARE_BEGIN,
 		-1,
 		-1,
@@ -73,22 +74,20 @@
 	},
 	{
-		lgtch_path,
+		multim_key_path,
 		1,
-		USB_HID_PATH_COMPARE_END 
-		| USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
-		0x046d,
-		0xc30e,
+		USB_HID_PATH_COMPARE_BEGIN,
+		-1,
+		-1,
 		{
-			.init = usb_lgtch_init,
-			.deinit = usb_lgtch_deinit,
-			.poll = usb_lgtch_polling_callback,
+			.init = usb_multimedia_init,
+			.deinit = usb_multimedia_deinit,
+			.poll = usb_multimedia_polling_callback,
 			.poll_end = NULL
 		}
 	},
 	{
-		path_mouse2,
+		path_mouse,
 		-1,
-		USB_HID_PATH_COMPARE_END 
-		| USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
+		USB_HID_PATH_COMPARE_BEGIN,
 		-1,
 		-1,
@@ -100,5 +99,5 @@
 		}
 	},
-	{NULL, -1, 0, -1, -1, {NULL, NULL, NULL, NULL}}
+	{NULL, -1, 0, -1, -1, {NULL, NULL, NULL, NULL, NULL}}
 };
 
Index: uspace/drv/usbhid/usbhid.c
===================================================================
--- uspace/drv/usbhid/usbhid.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhid/usbhid.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -37,8 +37,8 @@
 #include <usb/debug.h>
 #include <usb/classes/classes.h>
-#include <usb/classes/hid.h>
-#include <usb/classes/hidparser.h>
-#include <usb/classes/hidreport.h>
-#include <usb/classes/hidreq.h>
+#include <usb/hid/hid.h>
+#include <usb/hid/hidparser.h>
+#include <usb/hid/hidreport.h>
+#include <usb/hid/request.h>
 #include <errno.h>
 #include <str_error.h>
@@ -203,8 +203,17 @@
 	
 	usb_log_debug("Compare flags: %d\n", mapping->compare);
-	size_t size = usb_hid_report_input_length(hid_dev->report, usage_path, 
-	    mapping->compare);
+//	size_t size = usb_hid_report_size(hid_dev->report, 0, 
+//	    USB_HID_REPORT_TYPE_INPUT);
+	size_t size = 0;
+	usb_hid_report_field_t *field = usb_hid_report_get_sibling (hid_dev->report,
+		NULL, usage_path, mapping->compare, USB_HID_REPORT_TYPE_INPUT);
+	while(field != NULL) {
+		size++;
+		field = usb_hid_report_get_sibling (hid_dev->report,
+					field, usage_path, mapping->compare, 
+		            USB_HID_REPORT_TYPE_INPUT);
+	}
+	
 	usb_log_debug("Size of the input report: %zuB\n", size);
-	
 	usb_hid_report_path_free(usage_path);
 	
@@ -457,5 +466,6 @@
 			if (hid_dev->subdrivers[i].init != NULL) {
 				usb_log_debug("Initializing subdriver %d.\n",i);
-				rc = hid_dev->subdrivers[i].init(hid_dev);
+				rc = hid_dev->subdrivers[i].init(hid_dev,
+				    &hid_dev->subdrivers[i].data);
 				if (rc != EOK) {
 					usb_log_warning("Failed to initialize"
@@ -522,6 +532,6 @@
 	for (i = 0; i < hid_dev->subdriver_count; ++i) {
 		if (hid_dev->subdrivers[i].poll != NULL
-		    && hid_dev->subdrivers[i].poll(hid_dev, buffer, 
-		    buffer_size)) {
+		    && hid_dev->subdrivers[i].poll(hid_dev, 
+		        hid_dev->subdrivers[i].data, buffer, buffer_size)) {
 			cont = true;
 		}
@@ -546,5 +556,6 @@
 	for (i = 0; i < hid_dev->subdriver_count; ++i) {
 		if (hid_dev->subdrivers[i].poll_end != NULL) {
-			hid_dev->subdrivers[i].poll_end(hid_dev, reason);
+			hid_dev->subdrivers[i].poll_end(hid_dev,
+			    hid_dev->subdrivers[i].data, reason);
 		}
 	}
@@ -627,5 +638,6 @@
 	for (i = 0; i < (*hid_dev)->subdriver_count; ++i) {
 		if ((*hid_dev)->subdrivers[i].deinit != NULL) {
-			(*hid_dev)->subdrivers[i].deinit(*hid_dev);
+			(*hid_dev)->subdrivers[i].deinit(*hid_dev,
+			    (*hid_dev)->subdrivers[i].data);
 		}
 	}
Index: uspace/drv/usbhid/usbhid.h
===================================================================
--- uspace/drv/usbhid/usbhid.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhid/usbhid.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -39,17 +39,19 @@
 #include <stdint.h>
 
-#include <usb/classes/hidparser.h>
+#include <usb/hid/hidparser.h>
 #include <ddf/driver.h>
-#include <usb/pipes.h>
-#include <usb/devdrv.h>
-#include <usb/classes/hid.h>
+#include <usb/dev/pipes.h>
+#include <usb/dev/driver.h>
+#include <usb/hid/hid.h>
 #include <bool.h>
 
 struct usb_hid_dev;
 
-typedef int (*usb_hid_driver_init_t)(struct usb_hid_dev *);
-typedef void (*usb_hid_driver_deinit_t)(struct usb_hid_dev *);
-typedef bool (*usb_hid_driver_poll)(struct usb_hid_dev *, uint8_t *, size_t);
-typedef int (*usb_hid_driver_poll_ended)(struct usb_hid_dev *, bool reason);
+typedef int (*usb_hid_driver_init_t)(struct usb_hid_dev *, void **data);
+typedef void (*usb_hid_driver_deinit_t)(struct usb_hid_dev *, void *data);
+typedef bool (*usb_hid_driver_poll)(struct usb_hid_dev *, void *data, uint8_t *,
+                                    size_t);
+typedef int (*usb_hid_driver_poll_ended)(struct usb_hid_dev *, void *data, 
+                                         bool reason);
 
 // TODO: add function and class name??
@@ -63,4 +65,6 @@
 	/** Function to be called when polling ends. */
 	usb_hid_driver_poll_ended poll_end;
+	/** Arbitrary data needed by the subdriver. */
+	void *data;
 } usb_hid_subdriver_t;
 
@@ -72,7 +76,4 @@
 	/** Structure holding generic USB device information. */
 	usb_device_t *usb_dev;
-	
-	/** @todo What is this actually? */
-	ddf_dev_ops_t ops;
 	
 	/** Index of the polling pipe in usb_hid_endpoints array. */
@@ -97,7 +98,4 @@
 	
 	size_t input_report_size;
-	
-	/** Arbitrary data (e.g. a special structure for handling keyboard). */
-	void *data;
 } usb_hid_dev_t;
 
Index: uspace/drv/usbhub/main.c
===================================================================
--- uspace/drv/usbhub/main.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhub/main.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -36,5 +36,5 @@
 #include <stdio.h>
 
-#include <usb/devdrv.h>
+#include <usb/dev/driver.h>
 #include <usb/classes/classes.h>
 
Index: uspace/drv/usbhub/port_status.h
===================================================================
--- uspace/drv/usbhub/port_status.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhub/port_status.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -35,5 +35,5 @@
 #include <bool.h>
 #include <sys/types.h>
-#include <usb/request.h>
+#include <usb/dev/request.h>
 #include "usbhub_private.h"
 
Index: uspace/drv/usbhub/ports.h
===================================================================
--- uspace/drv/usbhub/ports.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhub/ports.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -36,6 +36,6 @@
 #define DRV_USBHUB_PORTS_H
 
-#include <usb/devdrv.h>
-#include <usb/hub.h>
+#include <usb/dev/driver.h>
+#include <usb/dev/hub.h>
 
 typedef struct usb_hub_info_t usb_hub_info_t;
Index: uspace/drv/usbhub/usbhub.c
===================================================================
--- uspace/drv/usbhub/usbhub.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhub/usbhub.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -42,8 +42,8 @@
 #include <usb/ddfiface.h>
 #include <usb/descriptor.h>
-#include <usb/recognise.h>
-#include <usb/request.h>
+#include <usb/dev/recognise.h>
+#include <usb/dev/request.h>
 #include <usb/classes/hub.h>
-#include <usb/devpoll.h>
+#include <usb/dev/poll.h>
 #include <stdio.h>
 
@@ -51,7 +51,7 @@
 #include "usbhub_private.h"
 #include "port_status.h"
-#include "usb/usb.h"
-#include "usb/pipes.h"
-#include "usb/classes/classes.h"
+#include <usb/usb.h>
+#include <usb/dev/pipes.h>
+#include <usb/classes/classes.h>
 
 
Index: uspace/drv/usbhub/usbhub.h
===================================================================
--- uspace/drv/usbhub/usbhub.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhub/usbhub.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -39,9 +39,9 @@
 #include <ddf/driver.h>
 
-#include <usb/hub.h>
+#include <usb/dev/hub.h>
 #include <usb/classes/hub.h>
 
-#include <usb/pipes.h>
-#include <usb/devdrv.h>
+#include <usb/dev/pipes.h>
+#include <usb/dev/driver.h>
 
 #include <fibril_synch.h>
Index: uspace/drv/usbhub/usbhub_private.h
===================================================================
--- uspace/drv/usbhub/usbhub_private.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbhub/usbhub_private.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -47,5 +47,5 @@
 #include <usb/usb.h>
 #include <usb/debug.h>
-#include <usb/request.h>
+#include <usb/dev/request.h>
 
 //************
Index: pace/drv/usbkbd/Makefile
===================================================================
--- uspace/drv/usbkbd/Makefile	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,64 +1,0 @@
-#
-# Copyright (c) 2010-2011 Vojtech Horky
-# 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.
-#
-
-USPACE_PREFIX = ../..
-
-LIBS = \
-	$(LIBUSBHID_PREFIX)/libusbhid.a \
-	$(LIBUSBDEV_PREFIX)/libusbdev.a \
-	$(LIBUSB_PREFIX)/libusb.a \
-	$(LIBDRV_PREFIX)/libdrv.a
-EXTRA_CFLAGS += \
-	-I. \
-	-I$(LIBUSB_PREFIX)/include \
-	-I$(LIBUSBDEV_PREFIX)/include \
-	-I$(LIBUSBHID_PREFIX)/include \
-	-I$(LIBDRV_PREFIX)/include
-
-BINARY = usbkbd
-
-STOLEN_LAYOUT_SOURCES = \
-	layout/us_qwerty.c \
-	layout/us_dvorak.c \
-	layout/cz.c
-
-SOURCES = \
-	main.c \
-	conv.c \
-	kbddev.c \
-	kbdrepeat.c \
-	$(STOLEN_LAYOUT_SOURCES)
-
-EXTRA_CLEAN = $(STOLEN_LAYOUT_SOURCES)
-
-SRV_KBD = $(USPACE_PREFIX)/srv/hid/kbd
-
-include $(USPACE_PREFIX)/Makefile.common
-
-layout/%.c: $(SRV_KBD)/layout/%.c
-	ln -sfn ../$< $@
Index: pace/drv/usbkbd/conv.c
===================================================================
--- uspace/drv/usbkbd/conv.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,193 +1,0 @@
-/*
- * Copyright (c) 2011 Lubos Slovak
- * 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 drvusbhid
- * @{
- */
-/** @file
- * USB scancode parser.
- */
-
-#include <io/keycode.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <usb/debug.h>
-#include "conv.h"
-
-/**
- * Mapping between USB HID key codes (from HID Usage Tables) and corresponding
- * HelenOS key codes.
- */
-static int scanmap_simple[255] = {
-
-//	[0x29] = KC_BACKTICK,
-
-//	[0x02] = KC_1,
-//	[0x03] = KC_2,
-	[0x04] = KC_A,
-	[0x05] = KC_B,
-	[0x06] = KC_C,
-	[0x07] = KC_D,
-	[0x08] = KC_E,
-	[0x09] = KC_F,
-	[0x0a] = KC_G,
-	[0x0b] = KC_H,
-	[0x0c] = KC_I,
-	[0x0d] = KC_J,
-	[0x0e] = KC_K,
-	[0x0f] = KC_L,
-	[0x10] = KC_M,
-	[0x11] = KC_N,
-	[0x12] = KC_O,
-	[0x13] = KC_P,
-	[0x14] = KC_Q,
-	[0x15] = KC_R,
-	[0x16] = KC_S,
-	[0x17] = KC_T,
-	[0x18] = KC_U,
-	[0x19] = KC_V,
-	[0x1a] = KC_W,
-	[0x1b] = KC_X,
-	[0x1c] = KC_Y,
-	[0x1d] = KC_Z,
-
-	[0x1e] = KC_1,
-	[0x1f] = KC_2,
-	[0x20] = KC_3,
-	[0x21] = KC_4,
-	[0x22] = KC_5,
-	[0x23] = KC_6,
-	[0x24] = KC_7,
-	[0x25] = KC_8,
-	[0x26] = KC_9,
-	[0x27] = KC_0,
-	
-	[0x28] = KC_ENTER,
-	[0x29] = KC_ESCAPE,
-	[0x2a] = KC_BACKSPACE,
-	[0x2b] = KC_TAB,
-	[0x2c] = KC_SPACE,
-
-	[0x2d] = KC_MINUS,  // same as DASH? (- or _)
-	[0x2e] = KC_EQUALS,
-	[0x2f] = KC_LBRACKET,
-	[0x30] = KC_RBRACKET,
-	[0x31] = KC_BACKSLASH,
-	//[0x32] = KC_,	// TODO: HASH??? maybe some as 0x31 - backslash
-	[0x33] = KC_SEMICOLON,
-	[0x34] = KC_QUOTE,  // same as APOSTROPHE? (')
-	[0x35] = KC_BACKTICK,  // same as GRAVE ACCENT?? (`)
-	[0x36] = KC_COMMA,
-	[0x37] = KC_PERIOD,
-	[0x38] = KC_SLASH,
-
-	[0x39] = KC_CAPS_LOCK,
-	
-	[0x3a] = KC_F1,
-	[0x3b] = KC_F2,
-	[0x3c] = KC_F3,
-	[0x3d] = KC_F4,
-	[0x3e] = KC_F5,
-	[0x3f] = KC_F6,
-	[0x40] = KC_F7,
-	[0x41] = KC_F8,
-	[0x42] = KC_F9,
-	[0x43] = KC_F10,
-	[0x44] = KC_F11,
-	[0x45] = KC_F12,
-	
-	[0x46] = KC_PRTSCR,
-	[0x47] = KC_SCROLL_LOCK,
-	[0x48] = KC_PAUSE,
-	[0x49] = KC_INSERT,
-	[0x4a] = KC_HOME,
-	[0x4b] = KC_PAGE_UP,
-	[0x4c] = KC_DELETE,
-	[0x4d] = KC_END,
-	[0x4e] = KC_PAGE_DOWN,
-	[0x4f] = KC_RIGHT,
-	[0x50] = KC_LEFT,
-	[0x51] = KC_DOWN,
-	[0x52] = KC_UP,
-	
-	//[0x64] = // some funny key
-	
-	[0xe0] = KC_LCTRL,
-	[0xe1] = KC_LSHIFT,
-	[0xe2] = KC_LALT,
-	//[0xe3] = KC_L	// TODO: left GUI
-	[0xe4] = KC_RCTRL,
-	[0xe5] = KC_RSHIFT,
-	[0xe6] = KC_RALT,
-	//[0xe7] = KC_R	// TODO: right GUI
-	
-	[0x53] = KC_NUM_LOCK,
-	[0x54] = KC_NSLASH,
-	[0x55] = KC_NTIMES,
-	[0x56] = KC_NMINUS,
-	[0x57] = KC_NPLUS,
-	[0x58] = KC_NENTER,
-	[0x59] = KC_N1,
-	[0x5a] = KC_N2,
-	[0x5b] = KC_N3,
-	[0x5c] = KC_N4,
-	[0x5d] = KC_N5,
-	[0x5e] = KC_N6,
-	[0x5f] = KC_N7,
-	[0x60] = KC_N8,
-	[0x61] = KC_N9,
-	[0x62] = KC_N0,
-	[0x63] = KC_NPERIOD
-	
-};
-
-/**
- * Translate USB HID key codes (from HID Usage Tables) to generic key codes
- * recognized by HelenOS.
- *
- * @param scancode USB HID key code (from HID Usage Tables).
- * 
- * @retval HelenOS key code corresponding to the given USB HID key code.
- */
-unsigned int usbhid_parse_scancode(int scancode)
-{
-	unsigned int key;
-	int *map = scanmap_simple;
-	size_t map_length = sizeof(scanmap_simple) / sizeof(int);
-
-	if ((scancode < 0) || ((size_t) scancode >= map_length))
-		return -1;
-
-	key = map[scancode];
-	
-	return key;
-}
-
-/**
- * @}
- */
Index: pace/drv/usbkbd/conv.h
===================================================================
--- uspace/drv/usbkbd/conv.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/*
- * Copyright (c) 2011 Lubos Slovak
- * 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 drvusbhid
- * @{
- */
-/** @file
- * USB scancode parser.
- */
-
-#ifndef USB_KBD_CONV_H_
-#define USB_KBD_CONV_H_
-
-unsigned int usbhid_parse_scancode(int scancode);
-
-#endif /* USB_KBD_CONV_H_ */
-
-/**
- * @}
- */
Index: pace/drv/usbkbd/kbd.h
===================================================================
--- uspace/drv/usbkbd/kbd.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,5 +1,0 @@
-/*
- * Dummy file because of shared layout sources.
- *
- * Do not delete.
- */
Index: pace/drv/usbkbd/kbddev.c
===================================================================
--- uspace/drv/usbkbd/kbddev.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,951 +1,0 @@
-/*
- * Copyright (c) 2011 Lubos Slovak
- * 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 drvusbhid
- * @{
- */
-/**
- * @file
- * USB HID keyboard device structure and API.
- */
-
-#include <errno.h>
-#include <str_error.h>
-#include <stdio.h>
-
-#include <io/keycode.h>
-#include <ipc/kbd.h>
-#include <async.h>
-#include <fibril.h>
-#include <fibril_synch.h>
-
-#include <usb/usb.h>
-#include <usb/dp.h>
-#include <usb/request.h>
-#include <usb/classes/hid.h>
-#include <usb/pipes.h>
-#include <usb/debug.h>
-#include <usb/classes/hidparser.h>
-#include <usb/classes/classes.h>
-#include <usb/classes/hidut.h>
-#include <usb/classes/hidreq.h>
-#include <usb/classes/hidreport.h>
-#include <usb/classes/hid/utled.h>
-
-#include <usb/devdrv.h>
-
-#include "kbddev.h"
-
-#include "layout.h"
-#include "conv.h"
-#include "kbdrepeat.h"
-
-/*----------------------------------------------------------------------------*/
-/** Default modifiers when the keyboard is initialized. */
-static const unsigned DEFAULT_ACTIVE_MODS = KM_NUM_LOCK;
-
-///** Boot protocol report size (key part). */
-//static const size_t BOOTP_REPORT_SIZE = 6;
-
-///** Boot protocol total report size. */
-//static const size_t BOOTP_BUFFER_SIZE = 8;
-
-///** Boot protocol output report size. */
-//static const size_t BOOTP_BUFFER_OUT_SIZE = 1;
-
-///** Boot protocol error key code. */
-//static const uint8_t BOOTP_ERROR_ROLLOVER = 1;
-static const uint8_t ERROR_ROLLOVER = 1;
-
-/** Default idle rate for keyboards. */
-static const uint8_t IDLE_RATE = 0;
-
-/** Delay before a pressed key starts auto-repeating. */
-static const unsigned int DEFAULT_DELAY_BEFORE_FIRST_REPEAT = 500 * 1000;
-
-/** Delay between two repeats of a pressed key when auto-repeating. */
-static const unsigned int DEFAULT_REPEAT_DELAY = 50 * 1000;
-
-/*----------------------------------------------------------------------------*/
-
-/** Keyboard polling endpoint description for boot protocol class. */
-static usb_endpoint_description_t boot_poll_endpoint_description = {
-	.transfer_type = USB_TRANSFER_INTERRUPT,
-	.direction = USB_DIRECTION_IN,
-	.interface_class = USB_CLASS_HID,
-	.interface_subclass = USB_HID_SUBCLASS_BOOT,
-	.interface_protocol = USB_HID_PROTOCOL_KEYBOARD,
-	.flags = 0
-};
-
-/* Array of endpoints expected on the device, NULL terminated. */
-usb_endpoint_description_t 
-    *usb_kbd_endpoints[USB_KBD_POLL_EP_COUNT + 1] = {
-	&boot_poll_endpoint_description,
-	NULL
-};
-
-/*----------------------------------------------------------------------------*/
-
-enum {
-	BOOT_REPORT_DESCRIPTOR_SIZE = 63
-};
-
-static const uint8_t BOOT_REPORT_DESCRIPTOR[BOOT_REPORT_DESCRIPTOR_SIZE] = {
-        0x05, 0x01,  // Usage Page (Generic Desktop),
-        0x09, 0x06,  // Usage (Keyboard),
-        0xA1, 0x01,  // Collection (Application),
-        0x75, 0x01,  //   Report Size (1),
-        0x95, 0x08,  //   Report Count (8),       
-        0x05, 0x07,  //   Usage Page (Key Codes);
-        0x19, 0xE0,  //   Usage Minimum (224),
-        0x29, 0xE7,  //   Usage Maximum (231),
-        0x15, 0x00,  //   Logical Minimum (0),
-        0x25, 0x01,  //   Logical Maximum (1),
-	//0x85, 0x00,  //   Report ID,
-	//0xA4,	     //   Push
-        0x81, 0x02,  //   Input (Data, Variable, Absolute),   ; Modifier byte
-	//0xB4,	     //   Pop
-        0x75, 0x08,  //   Report Size (1),
-        0x95, 0x01,  //   Report Count (8),       
-        0x81, 0x01,  //   Input (Constant),                   ; Reserved byte
-        0x95, 0x05,  //   Report Count (5),
-        0x75, 0x01,  //   Report Size (1),
-        0x05, 0x08,  //   Usage Page (Page# for LEDs),
-        0x19, 0x01,  //   Usage Minimum (1),
-        0x29, 0x05,  //   Usage Maxmimum (5),
-        0x91, 0x02,  //   Output (Data, Variable, Absolute),  ; LED report
-        0x95, 0x01,  //   Report Count (1),
-        0x75, 0x03,  //   Report Size (3),
-        0x91, 0x01,  //   Output (Constant),              ; LED report padding
-        0x95, 0x06,  //   Report Count (6),
-        0x75, 0x08,  //   Report Size (8),
-        0x15, 0x00,  //   Logical Minimum (0),
-        0x25, 0xff,  //   Logical Maximum (255),
-        0x05, 0x07,  //   Usage Page (Key Codes),
-        0x19, 0x00,  //   Usage Minimum (0),
-        0x29, 0xff,  //   Usage Maximum (255),
-        0x81, 0x00,  //   Input (Data, Array),            ; Key arrays (6 bytes)
-        0xC0           // End Collection
-
-};
-
-/*----------------------------------------------------------------------------*/
-
-typedef enum usb_kbd_flags {
-	USB_KBD_STATUS_UNINITIALIZED = 0,
-	USB_KBD_STATUS_INITIALIZED = 1,
-	USB_KBD_STATUS_TO_DESTROY = -1
-} usb_kbd_flags;
-
-/*----------------------------------------------------------------------------*/
-/* Keyboard layouts                                                           */
-/*----------------------------------------------------------------------------*/
-
-#define NUM_LAYOUTS 3
-
-/** Keyboard layout map. */
-static layout_op_t *layout[NUM_LAYOUTS] = {
-	&us_qwerty_op,
-	&us_dvorak_op,
-	&cz_op
-};
-
-static int active_layout = 0;
-
-/*----------------------------------------------------------------------------*/
-/* Modifier constants                                                         */
-/*----------------------------------------------------------------------------*/
-/** Mapping of USB modifier key codes to generic modifier key codes. */
-static const keycode_t usbhid_modifiers_keycodes[USB_HID_MOD_COUNT] = {
-	KC_LCTRL,         /* USB_HID_MOD_LCTRL */
-	KC_LSHIFT,        /* USB_HID_MOD_LSHIFT */
-	KC_LALT,          /* USB_HID_MOD_LALT */
-	0,                /* USB_HID_MOD_LGUI */
-	KC_RCTRL,         /* USB_HID_MOD_RCTRL */
-	KC_RSHIFT,        /* USB_HID_MOD_RSHIFT */
-	KC_RALT,          /* USB_HID_MOD_RALT */
-	0,                /* USB_HID_MOD_RGUI */
-};
-
-typedef enum usbhid_lock_code {
-	USB_KBD_LOCK_NUM = 0x53,
-	USB_KBD_LOCK_CAPS = 0x39,
-	USB_KBD_LOCK_SCROLL = 0x47,
-	USB_KBD_LOCK_COUNT = 3
-} usbhid_lock_code;
-
-static const usbhid_lock_code usbhid_lock_codes[USB_KBD_LOCK_COUNT] = {
-	USB_KBD_LOCK_NUM,
-	USB_KBD_LOCK_CAPS,
-	USB_KBD_LOCK_SCROLL
-};
-
-/*----------------------------------------------------------------------------*/
-/* IPC method handler                                                         */
-/*----------------------------------------------------------------------------*/
-
-static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
-ddf_dev_ops_t keyboard_ops = {
-	.default_handler = default_connection_handler
-};
-
-/** 
- * Default handler for IPC methods not handled by DDF.
- *
- * Currently recognizes only one method (IPC_M_CONNECT_TO_ME), in which case it
- * assumes the caller is the console and thus it stores IPC phone to it for 
- * later use by the driver to notify about key events.
- *
- * @param fun Device function handling the call.
- * @param icallid Call id.
- * @param icall Call data.
- */
-void default_connection_handler(ddf_fun_t *fun,
-    ipc_callid_t icallid, ipc_call_t *icall)
-{
-	sysarg_t method = IPC_GET_IMETHOD(*icall);
-	
-	usb_kbd_t *kbd_dev = (usb_kbd_t *)fun->driver_data;
-	assert(kbd_dev != NULL);
-
-	if (method == IPC_M_CONNECT_TO_ME) {
-		int callback = IPC_GET_ARG5(*icall);
-
-		if (kbd_dev->console_phone != -1) {
-			async_answer_0(icallid, ELIMIT);
-			return;
-		}
-
-		kbd_dev->console_phone = callback;
-		async_answer_0(icallid, EOK);
-		return;
-	}
-	
-	async_answer_0(icallid, EINVAL);
-}
-
-/*----------------------------------------------------------------------------*/
-/* Key processing functions                                                   */
-/*----------------------------------------------------------------------------*/
-/**
- * Handles turning of LED lights on and off.
- *
- * In case of USB keyboards, the LEDs are handled in the driver, not in the 
- * device. When there should be a change (lock key was pressed), the driver
- * uses a Set_Report request sent to the device to set the state of the LEDs.
- *
- * This functions sets the LED lights according to current settings of modifiers
- * kept in the keyboard device structure.
- *
- * @param kbd_dev Keyboard device structure.
- */
-static void usb_kbd_set_led(usb_kbd_t *kbd_dev) 
-{
-	if (kbd_dev->output_size == 0) {
-		return;
-	}
-
-	unsigned i = 0;
-	
-	/* Reset the LED data. */
-	memset(kbd_dev->led_data, 0, kbd_dev->led_output_size * sizeof(int32_t));
-	
-	if ((kbd_dev->mods & KM_NUM_LOCK) && (i < kbd_dev->led_output_size)) {
-		kbd_dev->led_data[i++] = USB_HID_LED_NUM_LOCK;
-	}
-	
-	if ((kbd_dev->mods & KM_CAPS_LOCK) && (i < kbd_dev->led_output_size)) {
-		kbd_dev->led_data[i++] = USB_HID_LED_CAPS_LOCK;
-	}
-	
-	if ((kbd_dev->mods & KM_SCROLL_LOCK) 
-	    && (i < kbd_dev->led_output_size)) {
-		kbd_dev->led_data[i++] = USB_HID_LED_SCROLL_LOCK;
-	}
-
-	// TODO: COMPOSE and KANA
-	
-	usb_log_debug("Creating output report.\n");
-
-	//usb_hid_report_output_set_data(kbd_dev->parser, kbd_dev->led_path, 
-	//                               USB_HID_PATH_COMPARE_END , kbd_dev->led_data, 
-	//                               kbd_dev->led_output_size);
-	int rc = usb_hid_report_output_translate(kbd_dev->parser, 0,
-	    kbd_dev->output_buffer, kbd_dev->output_size);
-	
-	if (rc != EOK) {
-		usb_log_warning("Error translating LED output to output report"
-		    ".\n");
-		return;
-	}
-	
-	usb_log_debug("Output report buffer: %s\n", 
-	    usb_debug_str_buffer(kbd_dev->output_buffer, kbd_dev->output_size, 
-	        0));
-	
-	usbhid_req_set_report(&kbd_dev->usb_dev->ctrl_pipe, 
-	    kbd_dev->usb_dev->interface_no, USB_HID_REPORT_TYPE_OUTPUT, 
-	    kbd_dev->output_buffer, kbd_dev->output_size);
-}
-
-/*----------------------------------------------------------------------------*/
-/**
- * Processes key events.
- *
- * @note This function was copied from AT keyboard driver and modified to suit
- *       USB keyboard.
- *
- * @note Lock keys are not sent to the console, as they are completely handled
- *       in the driver. It may, however, be required later that the driver
- *       sends also these keys to application (otherwise it cannot use those
- *       keys at all).
- * 
- * @param kbd_dev Keyboard device structure.
- * @param type Type of the event (press / release). Recognized values: 
- *             KEY_PRESS, KEY_RELEASE
- * @param key Key code of the key according to HID Usage Tables.
- */
-void usb_kbd_push_ev(usb_kbd_t *kbd_dev, int type, unsigned int key)
-{
-	console_event_t ev;
-	unsigned mod_mask;
-
-	/*
-	 * These parts are copy-pasted from the AT keyboard driver.
-	 *
-	 * They definitely require some refactoring, but will keep it for later
-	 * when the console and keyboard system is changed in HelenOS.
-	 */
-	switch (key) {
-	case KC_LCTRL: mod_mask = KM_LCTRL; break;
-	case KC_RCTRL: mod_mask = KM_RCTRL; break;
-	case KC_LSHIFT: mod_mask = KM_LSHIFT; break;
-	case KC_RSHIFT: mod_mask = KM_RSHIFT; break;
-	case KC_LALT: mod_mask = KM_LALT; break;
-	case KC_RALT: mod_mask = KM_RALT; break;
-	default: mod_mask = 0; break;
-	}
-
-	if (mod_mask != 0) {
-		if (type == KEY_PRESS)
-			kbd_dev->mods = kbd_dev->mods | mod_mask;
-		else
-			kbd_dev->mods = kbd_dev->mods & ~mod_mask;
-	}
-
-	switch (key) {
-	case KC_CAPS_LOCK: mod_mask = KM_CAPS_LOCK; break;
-	case KC_NUM_LOCK: mod_mask = KM_NUM_LOCK; break;
-	case KC_SCROLL_LOCK: mod_mask = KM_SCROLL_LOCK; break;
-	default: mod_mask = 0; break;
-	}
-
-	if (mod_mask != 0) {
-		if (type == KEY_PRESS) {
-			/*
-			 * Only change lock state on transition from released
-			 * to pressed. This prevents autorepeat from messing
-			 * up the lock state.
-			 */
-			unsigned int locks_old = kbd_dev->lock_keys;
-			
-			kbd_dev->mods = 
-			    kbd_dev->mods ^ (mod_mask & ~kbd_dev->lock_keys);
-			kbd_dev->lock_keys = kbd_dev->lock_keys | mod_mask;
-
-			/* Update keyboard lock indicator lights. */
-			if (kbd_dev->lock_keys != locks_old) {
-				usb_kbd_set_led(kbd_dev);
-			}
-		} else {
-			kbd_dev->lock_keys = kbd_dev->lock_keys & ~mod_mask;
-		}
-	}
-
-	if (key == KC_CAPS_LOCK || key == KC_NUM_LOCK || key == KC_SCROLL_LOCK) {
-		// do not send anything to the console, this is our business
-		return;
-	}
-	
-	if (type == KEY_PRESS && (kbd_dev->mods & KM_LCTRL) && key == KC_F1) {
-		active_layout = 0;
-		layout[active_layout]->reset();
-		return;
-	}
-
-	if (type == KEY_PRESS && (kbd_dev->mods & KM_LCTRL) && key == KC_F2) {
-		active_layout = 1;
-		layout[active_layout]->reset();
-		return;
-	}
-
-	if (type == KEY_PRESS && (kbd_dev->mods & KM_LCTRL) && key == KC_F3) {
-		active_layout = 2;
-		layout[active_layout]->reset();
-		return;
-	}
-	
-	ev.type = type;
-	ev.key = key;
-	ev.mods = kbd_dev->mods;
-
-	ev.c = layout[active_layout]->parse_ev(&ev);
-
-	usb_log_debug2("Sending key %d to the console\n", ev.key);
-	if (kbd_dev->console_phone < 0) {
-		usb_log_warning(
-		    "Connection to console not ready, key discarded.\n");
-		return;
-	}
-	
-	async_msg_4(kbd_dev->console_phone, KBD_EVENT, ev.type, ev.key, 
-	    ev.mods, ev.c);
-}
-
-/*----------------------------------------------------------------------------*/
-
-static inline int usb_kbd_is_lock(unsigned int key_code) 
-{
-	return (key_code == KC_NUM_LOCK
-	    || key_code == KC_SCROLL_LOCK
-	    || key_code == KC_CAPS_LOCK);
-}
-
-/*----------------------------------------------------------------------------*/
-/**
- * Checks if some keys were pressed or released and generates key events.
- *
- * An event is created only when key is pressed or released. Besides handling
- * the events (usb_kbd_push_ev()), the auto-repeat fibril is notified about
- * key presses and releases (see usb_kbd_repeat_start() and 
- * usb_kbd_repeat_stop()).
- *
- * @param kbd_dev Keyboard device structure.
- * @param key_codes Parsed keyboard report - codes of currently pressed keys 
- *                  according to HID Usage Tables.
- * @param count Number of key codes in report (size of the report).
- *
- * @sa usb_kbd_push_ev(), usb_kbd_repeat_start(), usb_kbd_repeat_stop()
- */
-static void usb_kbd_check_key_changes(usb_kbd_t *kbd_dev, 
-    const uint8_t *key_codes, size_t count)
-{
-	unsigned int key;
-	unsigned int i, j;
-	
-	/*
-	 * First of all, check if the kbd have reported phantom state.
-	 *
-	 * As there is no way to distinguish keys from modifiers, we do not have
-	 * a way to check that 'all keys report Error Rollover'. We thus check
-	 * if there is at least one such error and in such case we ignore the
-	 * whole input report.
-	 */
-	i = 0;
-	while (i < count && key_codes[i] != ERROR_ROLLOVER) {
-		++i;
-	}
-	if (i != count) {
-		usb_log_debug("Phantom state occured.\n");
-		// phantom state, do nothing
-		return;
-	}
-	
-	/* TODO: quite dummy right now, think of better implementation */
-	assert(count == kbd_dev->key_count);
-	
-	/*
-	 * 1) Key releases
-	 */
-	for (j = 0; j < count; ++j) {
-		// try to find the old key in the new key list
-		i = 0;
-		while (i < kbd_dev->key_count
-		    && key_codes[i] != kbd_dev->keys[j]) {
-			++i;
-		}
-		
-		if (i == count) {
-			// not found, i.e. the key was released
-			key = usbhid_parse_scancode(kbd_dev->keys[j]);
-			if (!usb_kbd_is_lock(key)) {
-				usb_kbd_repeat_stop(kbd_dev, key);
-			}
-			usb_kbd_push_ev(kbd_dev, KEY_RELEASE, key);
-			usb_log_debug2("Key released: %d\n", key);
-		} else {
-			// found, nothing happens
-		}
-	}
-	
-	/*
-	 * 1) Key presses
-	 */
-	for (i = 0; i < kbd_dev->key_count; ++i) {
-		// try to find the new key in the old key list
-		j = 0;
-		while (j < count && kbd_dev->keys[j] != key_codes[i]) { 
-			++j;
-		}
-		
-		if (j == count) {
-			// not found, i.e. new key pressed
-			key = usbhid_parse_scancode(key_codes[i]);
-			usb_log_debug2("Key pressed: %d (keycode: %d)\n", key,
-			    key_codes[i]);
-			usb_kbd_push_ev(kbd_dev, KEY_PRESS, key);
-			if (!usb_kbd_is_lock(key)) {
-				usb_kbd_repeat_start(kbd_dev, key);
-			}
-		} else {
-			// found, nothing happens
-		}
-	}
-	
-	memcpy(kbd_dev->keys, key_codes, count);
-
-	usb_log_debug("New stored keycodes: %s\n", 
-	    usb_debug_str_buffer(kbd_dev->keys, kbd_dev->key_count, 0));
-}
-
-/*----------------------------------------------------------------------------*/
-/* Callbacks for parser                                                       */
-/*----------------------------------------------------------------------------*/
-/**
- * Callback function for the HID report parser.
- *
- * This function is called by the HID report parser with the parsed report.
- * The parsed report is used to check if any events occured (key was pressed or
- * released, modifier was pressed or released).
- *
- * @param key_codes Parsed keyboard report - codes of currently pressed keys 
- *                  according to HID Usage Tables.
- * @param count Number of key codes in report (size of the report).
- * @param report_id
- * @param arg User-specified argument. Expects pointer to the keyboard device
- *            structure representing the keyboard.
- *
- * @sa usb_kbd_check_key_changes(), usb_kbd_check_modifier_changes()
- */
-static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count,
-    uint8_t report_id, void *arg)
-{
-	if (arg == NULL) {
-		usb_log_warning("Missing argument in callback "
-		    "usbhid_process_keycodes().\n");
-		return;
-	}
-	
-	usb_kbd_t *kbd_dev = (usb_kbd_t *)arg;
-	assert(kbd_dev != NULL);
-
-	usb_log_debug("Got keys from parser (report id: %d): %s\n", report_id, 
-	    usb_debug_str_buffer(key_codes, count, 0));
-	
-	if (count != kbd_dev->key_count) {
-		usb_log_warning("Number of received keycodes (%zu) differs from"
-		    " expected (%zu).\n", count, kbd_dev->key_count);
-		return;
-	}
-	
-	///usb_kbd_check_modifier_changes(kbd_dev, key_codes, count);
-	usb_kbd_check_key_changes(kbd_dev, key_codes, count);
-}
-
-/*----------------------------------------------------------------------------*/
-/* General kbd functions                                                      */
-/*----------------------------------------------------------------------------*/
-/**
- * Processes data received from the device in form of report.
- *
- * This function uses the HID report parser to translate the data received from
- * the device into generic USB HID key codes and into generic modifiers bitmap.
- * The parser then calls the given callback (usb_kbd_process_keycodes()).
- *
- * @note Currently, only the boot protocol is supported.
- *
- * @param kbd_dev Keyboard device structure (must be initialized).
- * @param buffer Data from the keyboard (i.e. the report).
- * @param actual_size Size of the data from keyboard (report size) in bytes.
- *
- * @sa usb_kbd_process_keycodes(), usb_hid_boot_keyboard_input_report(),
- *     usb_hid_parse_report().
- */
-static void usb_kbd_process_data(usb_kbd_t *kbd_dev,
-                                 uint8_t *buffer, size_t actual_size)
-{
-	assert(kbd_dev->initialized == USB_KBD_STATUS_INITIALIZED);
-	assert(kbd_dev->parser != NULL);
-	
-	usb_hid_report_in_callbacks_t *callbacks =
-	    (usb_hid_report_in_callbacks_t *)malloc(
-	        sizeof(usb_hid_report_in_callbacks_t));
-	
-	callbacks->keyboard = usb_kbd_process_keycodes;
-
-	usb_log_debug("Calling usb_hid_parse_report() with "
-	    "buffer %s\n", usb_debug_str_buffer(buffer, actual_size, 0));
-	
-//	int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size,
-//	    callbacks, kbd_dev);
-	usb_hid_report_path_t *path = usb_hid_report_path();
-	usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0);
-
-	uint8_t report_id;
-	int rc = usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, &report_id);
-	usb_hid_descriptor_print (kbd_dev->parser);
-
-	usb_hid_report_path_free (path);
-	
-	if (rc != EOK) {
-		usb_log_warning("Error in usb_hid_boot_keyboard_input_report():"
-		    "%s\n", str_error(rc));
-	}
-}
-
-/*----------------------------------------------------------------------------*/
-/* HID/KBD structure manipulation                                             */
-/*----------------------------------------------------------------------------*/
-
-static void usb_kbd_mark_unusable(usb_kbd_t *kbd_dev)
-{
-	kbd_dev->initialized = USB_KBD_STATUS_TO_DESTROY;
-}
-
-
-/*----------------------------------------------------------------------------*/
-/* API functions                                                              */
-/*----------------------------------------------------------------------------*/
-/**
- * Creates a new USB/HID keyboard structure.
- *
- * The structure returned by this function is not initialized. Use 
- * usb_kbd_init() to initialize it prior to polling.
- *
- * @return New uninitialized structure for representing a USB/HID keyboard or
- *         NULL if not successful (memory error).
- */
-usb_kbd_t *usb_kbd_new(void)
-{
-	usb_kbd_t *kbd_dev = 
-	    (usb_kbd_t *)malloc(sizeof(usb_kbd_t));
-
-	if (kbd_dev == NULL) {
-		usb_log_fatal("No memory!\n");
-		return NULL;
-	}
-	
-	memset(kbd_dev, 0, sizeof(usb_kbd_t));
-	
-	kbd_dev->parser = (usb_hid_report_t *)(malloc(sizeof(
-	    usb_hid_report_t)));
-	if (kbd_dev->parser == NULL) {
-		usb_log_fatal("No memory!\n");
-		free(kbd_dev);
-		return NULL;
-	}
-	
-	kbd_dev->console_phone = -1;
-	kbd_dev->initialized = USB_KBD_STATUS_UNINITIALIZED;
-	
-	return kbd_dev;
-}
-
-/*----------------------------------------------------------------------------*/
-/**
- * Initialization of the USB/HID keyboard structure.
- *
- * This functions initializes required structures from the device's descriptors.
- *
- * During initialization, the keyboard is switched into boot protocol, the idle
- * rate is set to 0 (infinity), resulting in the keyboard only reporting event
- * when a key is pressed or released. Finally, the LED lights are turned on 
- * according to the default setup of lock keys.
- *
- * @note By default, the keyboards is initialized with Num Lock turned on and 
- *       other locks turned off.
- *
- * @param kbd_dev Keyboard device structure to be initialized.
- * @param dev DDF device structure of the keyboard.
- *
- * @retval EOK if successful.
- * @retval EINVAL if some parameter is not given.
- * @return Other value inherited from function usbhid_dev_init().
- */
-int usb_kbd_init(usb_kbd_t *kbd_dev, usb_device_t *dev)
-{
-	int rc;
-	
-	usb_log_debug("Initializing HID/KBD structure...\n");
-	
-	if (kbd_dev == NULL) {
-		usb_log_error("Failed to init keyboard structure: no structure"
-		    " given.\n");
-		return EINVAL;
-	}
-	
-	if (dev == NULL) {
-		usb_log_error("Failed to init keyboard structure: no USB device"
-		    " given.\n");
-		return EINVAL;
-	}
-	
-	if (kbd_dev->initialized == USB_KBD_STATUS_INITIALIZED) {
-		usb_log_warning("Keyboard structure already initialized.\n");
-		return EINVAL;
-	}
-	
-	/* TODO: does not work! */
-	if (!dev->pipes[USB_KBD_POLL_EP_NO].present) {
-		usb_log_warning("Required endpoint not found - probably not "
-		    "a supported device.\n");
-		return ENOTSUP;
-	}
-	
-	/* The USB device should already be initialized, save it in structure */
-	kbd_dev->usb_dev = dev;
-	
-	/* Initialize the report parser. */
-	//rc = usb_hid_parser_init(kbd_dev->parser);
-	//if (rc != EOK) {
-	//	usb_log_error("Failed to initialize report parser.\n");
-	//	return rc;
-	//}
-	
-	/* Get the report descriptor and parse it. */
-	rc = usb_hid_process_report_descriptor(kbd_dev->usb_dev, 
-	    kbd_dev->parser);
-	if (rc != EOK) {
-		usb_log_warning("Could not process report descriptor, "
-		    "falling back to boot protocol.\n");
-		rc = usb_hid_parse_report_descriptor(kbd_dev->parser, 
-		    BOOT_REPORT_DESCRIPTOR, BOOT_REPORT_DESCRIPTOR_SIZE);
-		if (rc != EOK) {
-			usb_log_error("Failed to parse boot report descriptor:"
-			    " %s.\n", str_error(rc));
-			return rc;
-		}
-		
-		rc = usbhid_req_set_protocol(&kbd_dev->usb_dev->ctrl_pipe, 
-		    kbd_dev->usb_dev->interface_no, USB_HID_PROTOCOL_BOOT);
-		
-		if (rc != EOK) {
-			usb_log_warning("Failed to set boot protocol to the "
-			    "device: %s\n", str_error(rc));
-			return rc;
-		}
-	}
-	
-	/*
-	 * TODO: make more general
-	 */
-	usb_hid_report_path_t *path = usb_hid_report_path();
-	usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0);
-	
-	usb_hid_report_path_set_report_id(path, 0);
-	
-	kbd_dev->key_count = usb_hid_report_input_length(
-	    kbd_dev->parser, path, USB_HID_PATH_COMPARE_END);
-	usb_hid_report_path_free (path);
-	
-	usb_log_debug("Size of the input report: %zu\n", kbd_dev->key_count);
-	
-	kbd_dev->keys = (uint8_t *)calloc(kbd_dev->key_count, sizeof(uint8_t));
-	
-	if (kbd_dev->keys == NULL) {
-		usb_log_fatal("No memory!\n");
-		return ENOMEM;
-	}
-	
-	/*
-	 * Output report
-	 */
-	kbd_dev->output_size = 0;
-	kbd_dev->output_buffer = usb_hid_report_output(kbd_dev->parser, 
-	    &kbd_dev->output_size, 0x00);
-	if (kbd_dev->output_buffer == NULL) {
-		usb_log_warning("Error creating output report buffer.\n");
-		free(kbd_dev->keys);
-		return ENOMEM;  /* TODO: other error code */
-	}
-	
-	usb_log_debug("Output buffer size: %zu\n", kbd_dev->output_size);
-	
-	kbd_dev->led_path = usb_hid_report_path();
-	usb_hid_report_path_append_item(
-	    kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0);
-	usb_hid_report_path_set_report_id(kbd_dev->led_path, 0x00);
-	
-	kbd_dev->led_output_size = usb_hid_report_output_size(kbd_dev->parser, 
-	    kbd_dev->led_path, 
-	    USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY);
-	
-	usb_log_debug("Output report size (in items): %zu\n", 
-	    kbd_dev->led_output_size);
-	
-	kbd_dev->led_data = (int32_t *)calloc(
-	    kbd_dev->led_output_size, sizeof(int32_t));
-	
-	if (kbd_dev->led_data == NULL) {
-		usb_log_warning("Error creating buffer for LED output report."
-		    "\n");
-		free(kbd_dev->keys);
-		usb_hid_report_output_free(kbd_dev->output_buffer);
-		return ENOMEM;
-	}
-	
-	/*
-	 * Modifiers and locks
-	 */	
-	kbd_dev->modifiers = 0;
-	kbd_dev->mods = DEFAULT_ACTIVE_MODS;
-	kbd_dev->lock_keys = 0;
-	
-	/*
-	 * Autorepeat
-	 */	
-	kbd_dev->repeat.key_new = 0;
-	kbd_dev->repeat.key_repeated = 0;
-	kbd_dev->repeat.delay_before = DEFAULT_DELAY_BEFORE_FIRST_REPEAT;
-	kbd_dev->repeat.delay_between = DEFAULT_REPEAT_DELAY;
-	
-	kbd_dev->repeat_mtx = (fibril_mutex_t *)(
-	    malloc(sizeof(fibril_mutex_t)));
-	if (kbd_dev->repeat_mtx == NULL) {
-		usb_log_fatal("No memory!\n");
-		free(kbd_dev->keys);
-		return ENOMEM;
-	}
-	
-	fibril_mutex_initialize(kbd_dev->repeat_mtx);
-	
-	/*
-	 * Set LEDs according to initial setup.
-	 * Set Idle rate
-	 */
-	usb_kbd_set_led(kbd_dev);	
-	
-	usbhid_req_set_idle(&kbd_dev->usb_dev->ctrl_pipe, 
-	    kbd_dev->usb_dev->interface_no, IDLE_RATE);
-	
-	kbd_dev->initialized = USB_KBD_STATUS_INITIALIZED;
-	usb_log_debug("HID/KBD device structure initialized.\n");
-	
-	return EOK;
-}
-
-/*----------------------------------------------------------------------------*/
-
-bool usb_kbd_polling_callback(usb_device_t *dev, uint8_t *buffer,
-     size_t buffer_size, void *arg)
-{
-	if (dev == NULL || buffer == NULL || arg == NULL) {
-		// do not continue polling (???)
-		return false;
-	}
-	
-	usb_kbd_t *kbd_dev = (usb_kbd_t *)arg;
-	
-	// TODO: add return value from this function
-	usb_kbd_process_data(kbd_dev, buffer, buffer_size);
-	
-	return true;
-}
-
-/*----------------------------------------------------------------------------*/
-
-void usb_kbd_polling_ended_callback(usb_device_t *dev, bool reason, 
-     void *arg)
-{
-	if (dev == NULL || arg == NULL) {
-		return;
-	}
-	
-	usb_kbd_t *kbd = (usb_kbd_t *)arg;
-	
-	usb_kbd_mark_unusable(kbd);
-}
-
-/*----------------------------------------------------------------------------*/
-
-int usb_kbd_is_initialized(const usb_kbd_t *kbd_dev)
-{
-	return (kbd_dev->initialized == USB_KBD_STATUS_INITIALIZED);
-}
-
-/*----------------------------------------------------------------------------*/
-
-int usb_kbd_is_ready_to_destroy(const usb_kbd_t *kbd_dev)
-{
-	return (kbd_dev->initialized == USB_KBD_STATUS_TO_DESTROY);
-}
-
-/*----------------------------------------------------------------------------*/
-/**
- * Properly destroys the USB/HID keyboard structure.
- *
- * @param kbd_dev Pointer to the structure to be destroyed.
- */
-void usb_kbd_free(usb_kbd_t **kbd_dev)
-{
-	if (kbd_dev == NULL || *kbd_dev == NULL) {
-		return;
-	}
-	
-	// hangup phone to the console
-	async_hangup((*kbd_dev)->console_phone);
-	
-//	if ((*kbd_dev)->hid_dev != NULL) {
-//		usbhid_dev_free(&(*kbd_dev)->hid_dev);
-//		assert((*kbd_dev)->hid_dev == NULL);
-//	}
-	
-	if ((*kbd_dev)->repeat_mtx != NULL) {
-		/* TODO: replace by some check and wait */
-		assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx));
-		free((*kbd_dev)->repeat_mtx);
-	}
-	
-	// destroy the parser
-	if ((*kbd_dev)->parser != NULL) {
-		usb_hid_free_report((*kbd_dev)->parser);
-	}
-	
-	// free the output buffer
-	usb_hid_report_output_free((*kbd_dev)->output_buffer);
-	
-	/* TODO: what about the USB device structure?? */
-
-	free(*kbd_dev);
-	*kbd_dev = NULL;
-}
-
-/**
- * @}
- */
Index: pace/drv/usbkbd/kbddev.h
===================================================================
--- uspace/drv/usbkbd/kbddev.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,154 +1,0 @@
-/*
- * Copyright (c) 2011 Lubos Slovak
- * 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 drvusbhid
- * @{
- */
-/** @file
- * USB HID keyboard device structure and API.
- */
-
-#ifndef USB_KBDDEV_H_
-#define USB_KBDDEV_H_
-
-#include <stdint.h>
-
-#include <fibril_synch.h>
-
-#include <usb/classes/hid.h>
-#include <usb/classes/hidparser.h>
-#include <ddf/driver.h>
-#include <usb/pipes.h>
-#include <usb/devdrv.h>
-
-#include "kbdrepeat.h"
-
-/*----------------------------------------------------------------------------*/
-/**
- * USB/HID keyboard device type.
- *
- * Holds a reference to generic USB/HID device structure and keyboard-specific
- * data, such as currently pressed keys, modifiers and lock keys.
- *
- * Also holds a IPC phone to the console (since there is now no other way to 
- * communicate with it).
- *
- * @note Storing active lock keys in this structure results in their setting
- *       being device-specific.
- */
-typedef struct usb_kbd_t {
-	/** Structure holding generic USB device information. */
-	//usbhid_dev_t *hid_dev;
-	usb_device_t *usb_dev;
-	
-	/** Currently pressed keys (not translated to key codes). */
-	uint8_t *keys;
-	/** Count of stored keys (i.e. number of keys in the report). */
-	size_t key_count;
-	/** Currently pressed modifiers (bitmap). */
-	uint8_t modifiers;
-	
-	/** Currently active modifiers including locks. Sent to the console. */
-	unsigned mods;
-	
-	/** Currently active lock keys. */
-	unsigned lock_keys;
-	
-	/** IPC phone to the console device (for sending key events). */
-	int console_phone;
-	
-	/** Information for auto-repeat of keys. */
-	usb_kbd_repeat_t repeat;
-	
-	/** Mutex for accessing the information about auto-repeat. */
-	fibril_mutex_t *repeat_mtx;
-	
-	/** Report descriptor. */
-	uint8_t *report_desc;
-
-	/** Report descriptor size. */
-	size_t report_desc_size;
-	
-	uint8_t *output_buffer;
-	
-	size_t output_size;
-	
-	size_t led_output_size;
-	
-	usb_hid_report_path_t *led_path;
-	
-	int32_t *led_data;
-
-	/** HID Report parser. */
-	usb_hid_report_t *parser;
-	
-	/** State of the structure (for checking before use). 
-	 * 
-	 * 0 - not initialized
-	 * 1 - initialized
-	 * -1 - ready for destroying
-	 */
-	int initialized;
-} usb_kbd_t;
-
-/*----------------------------------------------------------------------------*/
-
-enum {
-	USB_KBD_POLL_EP_NO = 0,
-	USB_KBD_POLL_EP_COUNT = 1
-};
-
-usb_endpoint_description_t *usb_kbd_endpoints[USB_KBD_POLL_EP_COUNT + 1];
-
-ddf_dev_ops_t keyboard_ops;
-
-/*----------------------------------------------------------------------------*/
-
-usb_kbd_t *usb_kbd_new(void);
-
-int usb_kbd_init(usb_kbd_t *kbd_dev, usb_device_t *dev);
-
-bool usb_kbd_polling_callback(usb_device_t *dev, uint8_t *buffer,
-     size_t buffer_size, void *arg);
-
-void usb_kbd_polling_ended_callback(usb_device_t *dev, bool reason, 
-     void *arg);
-
-int usb_kbd_is_initialized(const usb_kbd_t *kbd_dev);
-
-int usb_kbd_is_ready_to_destroy(const usb_kbd_t *kbd_dev);
-
-void usb_kbd_free(usb_kbd_t **kbd_dev);
-
-void usb_kbd_push_ev(usb_kbd_t *kbd_dev, int type, unsigned int key);
-
-#endif /* USB_KBDDEV_H_ */
-
-/**
- * @}
- */
Index: pace/drv/usbkbd/kbdrepeat.c
===================================================================
--- uspace/drv/usbkbd/kbdrepeat.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,185 +1,0 @@
-/*
- * Copyright (c) 2011 Lubos Slovak
- * 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 drvusbhid
- * @{
- */
-/**
- * @file
- * USB HID keyboard autorepeat facilities
- */
-
-#include <fibril_synch.h>
-#include <io/keycode.h>
-#include <io/console.h>
-#include <errno.h>
-
-#include <usb/debug.h>
-
-#include "kbdrepeat.h"
-#include "kbddev.h"
-
-
-/** Delay between auto-repeat state checks when no key is being repeated. */
-static unsigned int CHECK_DELAY = 10000;
-
-/*----------------------------------------------------------------------------*/
-/**
- * Main loop handling the auto-repeat of keys.
- *
- * This functions periodically checks if there is some key to be auto-repeated.
- *
- * If a new key is to be repeated, it uses the delay before first repeat stored
- * in the keyboard structure to wait until the key has to start repeating.
- *
- * If the same key is still pressed, it uses the delay between repeats stored
- * in the keyboard structure to wait until the key should be repeated.
- * 
- * If the currently repeated key is not pressed any more (
- * usb_kbd_repeat_stop() was called), it stops repeating it and starts 
- * checking again.
- *
- * @note For accessing the keyboard device auto-repeat information a fibril
- *       mutex (repeat_mtx) from the @a kbd structure is used.
- * 
- * @param kbd Keyboard device structure.
- */
-static void usb_kbd_repeat_loop(usb_kbd_t *kbd)
-{
-	unsigned int delay = 0;
-	
-	usb_log_debug("Starting autorepeat loop.\n");
-
-	while (true) {
-		// check if the kbd structure is usable
-		if (!usb_kbd_is_initialized(kbd)) {
-			if (usb_kbd_is_ready_to_destroy(kbd)) {
-				usb_kbd_free(&kbd);
-				assert(kbd == NULL);
-			}
-			return;
-		}
-		
-		fibril_mutex_lock(kbd->repeat_mtx);
-
-		if (kbd->repeat.key_new > 0) {
-			if (kbd->repeat.key_new == kbd->repeat.key_repeated) {
-				usb_log_debug2("Repeating key: %u.\n", 
-				    kbd->repeat.key_repeated);
-				usb_kbd_push_ev(kbd, KEY_PRESS, 
-				    kbd->repeat.key_repeated);
-				delay = kbd->repeat.delay_between;
-			} else {
-				usb_log_debug("New key to repeat: %u.\n", 
-				    kbd->repeat.key_new);
-				kbd->repeat.key_repeated = kbd->repeat.key_new;
-				delay = kbd->repeat.delay_before;
-			}
-		} else {
-			if (kbd->repeat.key_repeated > 0) {
-				usb_log_debug("Stopping to repeat key: %u.\n", 
-				    kbd->repeat.key_repeated);
-				kbd->repeat.key_repeated = 0;
-			}
-			delay = CHECK_DELAY;
-		}
-		fibril_mutex_unlock(kbd->repeat_mtx);
-		
-		async_usleep(delay);
-	}
-}
-
-/*----------------------------------------------------------------------------*/
-/**
- * Main routine to be executed by a fibril for handling auto-repeat.
- *
- * Starts the loop for checking changes in auto-repeat.
- * 
- * @param arg User-specified argument. Expects pointer to the keyboard device
- *            structure representing the keyboard.
- *
- * @retval EOK if the routine has finished.
- * @retval EINVAL if no argument is supplied.
- */
-int usb_kbd_repeat_fibril(void *arg)
-{
-	usb_log_debug("Autorepeat fibril spawned.\n");
-	
-	if (arg == NULL) {
-		usb_log_error("No device!\n");
-		return EINVAL;
-	}
-	
-	usb_kbd_t *kbd = (usb_kbd_t *)arg;
-	
-	usb_kbd_repeat_loop(kbd);
-	
-	return EOK;
-}
-
-/*----------------------------------------------------------------------------*/
-/**
- * Start repeating particular key.
- *
- * @note Only one key is repeated at any time, so calling this function 
- *       effectively cancels auto-repeat of the current repeated key (if any)
- *       and 'schedules' another key for auto-repeat.
- *
- * @param kbd Keyboard device structure.
- * @param key Key to start repeating.
- */
-void usb_kbd_repeat_start(usb_kbd_t *kbd, unsigned int key)
-{
-	fibril_mutex_lock(kbd->repeat_mtx);
-	kbd->repeat.key_new = key;
-	fibril_mutex_unlock(kbd->repeat_mtx);
-}
-
-/*----------------------------------------------------------------------------*/
-/**
- * Stop repeating particular key.
- *
- * @note Only one key is repeated at any time, but this function may be called
- *       even with key that is not currently repeated (in that case nothing 
- *       happens).
- *
- * @param kbd Keyboard device structure.
- * @param key Key to stop repeating.
- */
-void usb_kbd_repeat_stop(usb_kbd_t *kbd, unsigned int key)
-{
-	fibril_mutex_lock(kbd->repeat_mtx);
-	if (key == kbd->repeat.key_new) {
-		kbd->repeat.key_new = 0;
-	}
-	fibril_mutex_unlock(kbd->repeat_mtx);
-}
-
-/**
- * @}
- */
Index: pace/drv/usbkbd/kbdrepeat.h
===================================================================
--- uspace/drv/usbkbd/kbdrepeat.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,68 +1,0 @@
-/*
- * Copyright (c) 2011 Lubos Slovak
- * 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 drvusbhid
- * @{
- */
-/** @file
- * USB HID keyboard autorepeat facilities
- */
-
-#ifndef USB_KBDREPEAT_H_
-#define USB_KBDREPEAT_H_
-
-struct usb_kbd_t;
-
-/*----------------------------------------------------------------------------*/
-/**
- * Structure for keeping information needed for auto-repeat of keys.
- */
-typedef struct {
-	/** Last pressed key. */
-	unsigned int key_new;
-	/** Key to be repeated. */
-	unsigned int key_repeated;
-	/** Delay before first repeat in microseconds. */
-	unsigned int delay_before;
-	/** Delay between repeats in microseconds. */
-	unsigned int delay_between;
-} usb_kbd_repeat_t;
-
-/*----------------------------------------------------------------------------*/
-
-int usb_kbd_repeat_fibril(void *arg);
-
-void usb_kbd_repeat_start(struct usb_kbd_t *kbd, unsigned int key);
-
-void usb_kbd_repeat_stop(struct usb_kbd_t *kbd, unsigned int key);
-
-#endif /* USB_KBDREPEAT_H_ */
-
-/**
- * @}
- */
Index: pace/drv/usbkbd/layout.h
===================================================================
--- uspace/drv/usbkbd/layout.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,57 +1,0 @@
-/*
- * Copyright (c) 2009 Jiri Svoboda
- * Copyright (c) 2011 Lubos Slovak 
- * (copied from /uspace/srv/hid/kbd/include/layout.h)
- * 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 drvusbhid
- * @{
- */
-/** @file
- * Keyboard layout.
- */
-
-#ifndef USB_KBD_LAYOUT_H_
-#define USB_KBD_LAYOUT_H_
-
-#include <sys/types.h>
-#include <io/console.h>
-
-typedef struct {
-	void (*reset)(void);
-	wchar_t (*parse_ev)(console_event_t *);
-} layout_op_t;
-
-extern layout_op_t us_qwerty_op;
-extern layout_op_t us_dvorak_op;
-extern layout_op_t cz_op;
-
-#endif
-
-/**
- * @}
- */
Index: pace/drv/usbkbd/main.c
===================================================================
--- uspace/drv/usbkbd/main.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,252 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * Copyright (c) 2011 Lubos Slovak
- * 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 drvusbhid
- * @{
- */
-/**
- * @file
- * Main routines of USB KBD driver.
- */
-
-#include <ddf/driver.h>
-#include <usb/debug.h>
-#include <errno.h>
-#include <str_error.h>
-
-#include <usb/devdrv.h>
-#include <usb/devpoll.h>
-
-#include "kbddev.h"
-#include "kbdrepeat.h"
-
-/*----------------------------------------------------------------------------*/
-
-#define NAME "usbkbd"
-
-/**
- * Function for adding a new device of type USB/HID/keyboard.
- *
- * This functions initializes required structures from the device's descriptors
- * and starts new fibril for polling the keyboard for events and another one for
- * handling auto-repeat of keys.
- *
- * During initialization, the keyboard is switched into boot protocol, the idle
- * rate is set to 0 (infinity), resulting in the keyboard only reporting event
- * when a key is pressed or released. Finally, the LED lights are turned on 
- * according to the default setup of lock keys.
- *
- * @note By default, the keyboards is initialized with Num Lock turned on and 
- *       other locks turned off.
- * @note Currently supports only boot-protocol keyboards.
- *
- * @param dev Device to add.
- *
- * @retval EOK if successful.
- * @retval ENOMEM if there
- * @return Other error code inherited from one of functions usb_kbd_init(),
- *         ddf_fun_bind() and ddf_fun_add_to_class().
- *
- * @sa usb_kbd_fibril(), usb_kbd_repeat_fibril()
- */
-static int usb_kbd_try_add_device(usb_device_t *dev)
-{
-	/* Create the function exposed under /dev/devices. */
-	ddf_fun_t *kbd_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, 
-	    "keyboard");
-	if (kbd_fun == NULL) {
-		usb_log_error("Could not create DDF function node.\n");
-		return ENOMEM;
-	}
-	
-	/* 
-	 * Initialize device (get and process descriptors, get address, etc.)
-	 */
-	usb_log_debug("Initializing USB/HID KBD device...\n");
-	
-	usb_kbd_t *kbd_dev = usb_kbd_new();
-	if (kbd_dev == NULL) {
-		usb_log_error("Error while creating USB/HID KBD device "
-		    "structure.\n");
-		ddf_fun_destroy(kbd_fun);
-		return ENOMEM;  // TODO: some other code??
-	}
-	
-	int rc = usb_kbd_init(kbd_dev, dev);
-	
-	if (rc != EOK) {
-		usb_log_error("Failed to initialize USB/HID KBD device.\n");
-		ddf_fun_destroy(kbd_fun);
-		usb_kbd_free(&kbd_dev);
-		return rc;
-	}
-	
-	usb_log_debug("USB/HID KBD device structure initialized.\n");
-	
-	/*
-	 * Store the initialized keyboard device and keyboard ops
-	 * to the DDF function.
-	 */
-	kbd_fun->driver_data = kbd_dev;
-	kbd_fun->ops = &keyboard_ops;
-
-	rc = ddf_fun_bind(kbd_fun);
-	if (rc != EOK) {
-		usb_log_error("Could not bind DDF function: %s.\n",
-		    str_error(rc));
-		// TODO: Can / should I destroy the DDF function?
-		ddf_fun_destroy(kbd_fun);
-		usb_kbd_free(&kbd_dev);
-		return rc;
-	}
-	
-	rc = ddf_fun_add_to_class(kbd_fun, "keyboard");
-	if (rc != EOK) {
-		usb_log_error(
-		    "Could not add DDF function to class 'keyboard': %s.\n",
-		    str_error(rc));
-		// TODO: Can / should I destroy the DDF function?
-		ddf_fun_destroy(kbd_fun);
-		usb_kbd_free(&kbd_dev);
-		return rc;
-	}
-	
-	/*
-	 * Create new fibril for handling this keyboard
-	 */
-	//fid_t fid = fibril_create(usb_kbd_fibril, kbd_dev);
-	
-	/* Start automated polling function.
-	 * This will create a separate fibril that will query the device
-	 * for the data continuously 
-	 */
-       rc = usb_device_auto_poll(dev,
-	   /* Index of the polling pipe. */
-	   USB_KBD_POLL_EP_NO,
-	   /* Callback when data arrives. */
-	   usb_kbd_polling_callback,
-	   /* How much data to request. */
-	   dev->pipes[USB_KBD_POLL_EP_NO].pipe->max_packet_size,
-	   /* Callback when the polling ends. */
-	   usb_kbd_polling_ended_callback,
-	   /* Custom argument. */
-	   kbd_dev);
-	
-	
-	if (rc != EOK) {
-		usb_log_error("Failed to start polling fibril for `%s'.\n",
-		    dev->ddf_dev->name);
-		return rc;
-	}
-	//fibril_add_ready(fid);
-	
-	/*
-	 * Create new fibril for auto-repeat
-	 */
-	fid_t fid = fibril_create(usb_kbd_repeat_fibril, kbd_dev);
-	if (fid == 0) {
-		usb_log_error("Failed to start fibril for KBD auto-repeat");
-		return ENOMEM;
-	}
-	fibril_add_ready(fid);
-
-	(void)keyboard_ops;
-
-	/*
-	 * Hurrah, device is initialized.
-	 */
-	return EOK;
-}
-
-/*----------------------------------------------------------------------------*/
-/**
- * Callback for passing a new device to the driver.
- *
- * @note Currently, only boot-protocol keyboards are supported by this driver.
- *
- * @param dev Structure representing the new device.
- *
- * @retval EOK if successful. 
- * @retval EREFUSED if the device is not supported.
- */
-static int usb_kbd_add_device(usb_device_t *dev)
-{
-	usb_log_debug("usb_kbd_add_device()\n");
-	
-	if (dev->interface_no < 0) {
-		usb_log_warning("Device is not a supported keyboard.\n");
-		usb_log_error("Failed to add USB KBD device: endpoint not "
-		    "found.\n");
-		return ENOTSUP;
-	}
-	
-	int rc = usb_kbd_try_add_device(dev);
-	
-	if (rc != EOK) {
-		usb_log_warning("Device is not a supported keyboard.\n");
-		usb_log_error("Failed to add KBD device: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
-	
-	usb_log_info("Keyboard `%s' ready to use.\n", dev->ddf_dev->name);
-
-	return EOK;
-}
-
-/*----------------------------------------------------------------------------*/
-
-/* Currently, the framework supports only device adding. Once the framework
- * supports unplug, more callbacks will be added. */
-static usb_driver_ops_t usb_kbd_driver_ops = {
-        .add_device = usb_kbd_add_device,
-};
-
-
-/* The driver itself. */
-static usb_driver_t usb_kbd_driver = {
-        .name = NAME,
-        .ops = &usb_kbd_driver_ops,
-        .endpoints = usb_kbd_endpoints
-};
-
-/*----------------------------------------------------------------------------*/
-
-int main(int argc, char *argv[])
-{
-	printf(NAME ": HelenOS USB KBD driver.\n");
-
-	usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
-
-	return usb_driver_main(&usb_kbd_driver);
-}
-
-/**
- * @}
- */
Index: pace/drv/usbkbd/usbkbd.ma
===================================================================
--- uspace/drv/usbkbd/usbkbd.ma	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,1 +1,0 @@
-10 usb&interface&class=HID&subclass=0x01&protocol=0x01
Index: uspace/drv/usbmast/inquiry.c
===================================================================
--- uspace/drv/usbmast/inquiry.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbmast/inquiry.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -34,5 +34,5 @@
  * Main routines of USB mass storage driver.
  */
-#include <usb/devdrv.h>
+#include <usb/dev/driver.h>
 #include <usb/debug.h>
 #include <usb/classes/classes.h>
Index: uspace/drv/usbmast/main.c
===================================================================
--- uspace/drv/usbmast/main.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbmast/main.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -34,5 +34,5 @@
  * Main routines of USB mass storage driver.
  */
-#include <usb/devdrv.h>
+#include <usb/dev/driver.h>
 #include <usb/debug.h>
 #include <usb/classes/classes.h>
Index: uspace/drv/usbmast/mast.c
===================================================================
--- uspace/drv/usbmast/mast.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbmast/mast.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -40,5 +40,5 @@
 #include <str_error.h>
 #include <usb/debug.h>
-#include <usb/request.h>
+#include <usb/dev/request.h>
 
 bool usb_mast_verbose = true;
Index: uspace/drv/usbmast/mast.h
===================================================================
--- uspace/drv/usbmast/mast.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbmast/mast.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -39,6 +39,6 @@
 #include <sys/types.h>
 #include <usb/usb.h>
-#include <usb/pipes.h>
-#include <usb/devdrv.h>
+#include <usb/dev/pipes.h>
+#include <usb/dev/driver.h>
 
 /** Result of SCSI INQUIRY command.
Index: uspace/drv/usbmid/dump.c
===================================================================
--- uspace/drv/usbmid/dump.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbmid/dump.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -37,6 +37,6 @@
 #include <str_error.h>
 #include <stdlib.h>
-#include <usb/pipes.h>
-#include <usb/dp.h>
+#include <usb/dev/pipes.h>
+#include <usb/dev/dp.h>
 #include <usb/classes/classes.h>
 #include "usbmid.h"
Index: uspace/drv/usbmid/explore.c
===================================================================
--- uspace/drv/usbmid/explore.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbmid/explore.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -38,6 +38,6 @@
 #include <stdlib.h>
 #include <usb/classes/classes.h>
-#include <usb/request.h>
-#include <usb/dp.h>
+#include <usb/dev/request.h>
+#include <usb/dev/dp.h>
 #include <usb/ddfiface.h>
 #include "usbmid.h"
Index: uspace/drv/usbmid/main.c
===================================================================
--- uspace/drv/usbmid/main.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbmid/main.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -38,7 +38,7 @@
 #include <usb/debug.h>
 #include <usb/classes/classes.h>
-#include <usb/request.h>
+#include <usb/dev/request.h>
 #include <usb/descriptor.h>
-#include <usb/pipes.h>
+#include <usb/dev/pipes.h>
 
 #include "usbmid.h"
Index: uspace/drv/usbmid/usbmid.c
===================================================================
--- uspace/drv/usbmid/usbmid.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbmid/usbmid.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -39,7 +39,7 @@
 #include <usb_iface.h>
 #include <usb/ddfiface.h>
-#include <usb/pipes.h>
+#include <usb/dev/pipes.h>
 #include <usb/classes/classes.h>
-#include <usb/recognise.h>
+#include <usb/dev/recognise.h>
 #include "usbmid.h"
 
Index: uspace/drv/usbmid/usbmid.h
===================================================================
--- uspace/drv/usbmid/usbmid.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbmid/usbmid.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -40,7 +40,7 @@
 #include <ddf/driver.h>
 #include <usb/usb.h>
-#include <usb/pipes.h>
+#include <usb/dev/pipes.h>
 #include <usb/debug.h>
-#include <usb/devdrv.h>
+#include <usb/dev/driver.h>
 
 #define NAME "usbmid"
Index: uspace/drv/usbmouse/init.c
===================================================================
--- uspace/drv/usbmouse/init.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbmouse/init.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -37,6 +37,6 @@
 #include <usb/debug.h>
 #include <usb/classes/classes.h>
-#include <usb/classes/hid.h>
-#include <usb/request.h>
+#include <usb/hid/hid.h>
+#include <usb/dev/request.h>
 #include <errno.h>
 
Index: uspace/drv/usbmouse/main.c
===================================================================
--- uspace/drv/usbmouse/main.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbmouse/main.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -36,5 +36,5 @@
 #include "mouse.h"
 #include <usb/debug.h>
-#include <usb/devpoll.h>
+#include <usb/dev/poll.h>
 #include <errno.h>
 #include <str_error.h>
Index: uspace/drv/usbmouse/mouse.h
===================================================================
--- uspace/drv/usbmouse/mouse.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/usbmouse/mouse.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -37,6 +37,6 @@
 #define USBMOUSE_MOUSE_H_
 
-#include <usb/devdrv.h>
-#include <usb/pipes.h>
+#include <usb/dev/driver.h>
+#include <usb/dev/pipes.h>
 #include <time.h>
 
Index: uspace/drv/vhc/connhost.c
===================================================================
--- uspace/drv/vhc/connhost.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/vhc/connhost.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -36,5 +36,4 @@
 #include <errno.h>
 #include <usb/usb.h>
-#include <usb/addrkeep.h>
 #include <usb/ddfiface.h>
 #include <usb/debug.h>
Index: uspace/drv/vhc/hub.c
===================================================================
--- uspace/drv/vhc/hub.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/drv/vhc/hub.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -40,6 +40,6 @@
 #include <ddf/driver.h>
 #include <devman.h>
-#include <usb/hub.h>
-#include <usb/recognise.h>
+#include <usb/dev/hub.h>
+#include <usb/dev/recognise.h>
 
 #include "hub.h"
Index: uspace/lib/usbdev/include/usb/dev/dp.h
===================================================================
--- uspace/lib/usbdev/include/usb/dev/dp.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbdev/include/usb/dev/dp.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * 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 libusbdev
+ * @{
+ */
+/** @file
+ * USB descriptor parser.
+ */
+#ifndef LIBUSBDEV_DP_H_
+#define LIBUSBDEV_DP_H_
+
+#include <sys/types.h>
+#include <usb/usb.h>
+#include <usb/descriptor.h>
+
+/** USB descriptors nesting.
+ * The nesting describes the logical tree USB descriptors form
+ * (e.g. that endpoint descriptor belongs to interface or that
+ * interface belongs to configuration).
+ *
+ * See usb_descriptor_type_t for descriptor constants.
+ */
+typedef struct {
+	/** Child descriptor id. */
+	int child;
+	/** Parent descriptor id. */
+	int parent;
+} usb_dp_descriptor_nesting_t;
+
+extern usb_dp_descriptor_nesting_t usb_dp_standard_descriptor_nesting[];
+
+/** Descriptor parser structure. */
+typedef struct {
+	/** Used descriptor nesting. */
+	usb_dp_descriptor_nesting_t *nesting;
+} usb_dp_parser_t;
+
+/** Descriptor parser data. */
+typedef struct {
+	/** Data to be parsed. */
+	uint8_t *data;
+	/** Size of input data in bytes. */
+	size_t size;
+	/** Custom argument. */
+	void *arg;
+} usb_dp_parser_data_t;
+
+uint8_t *usb_dp_get_nested_descriptor(usb_dp_parser_t *,
+    usb_dp_parser_data_t *, uint8_t *);
+uint8_t *usb_dp_get_sibling_descriptor(usb_dp_parser_t *,
+    usb_dp_parser_data_t *, uint8_t *, uint8_t *);
+
+void usb_dp_walk_simple(uint8_t *, size_t, usb_dp_descriptor_nesting_t *,
+    void (*)(uint8_t *, size_t, void *), void *);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usbdev/include/usb/dev/driver.h
===================================================================
--- uspace/lib/usbdev/include/usb/dev/driver.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbdev/include/usb/dev/driver.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * 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 libusbdev
+ * @{
+ */
+/** @file
+ * USB device driver framework.
+ */
+#ifndef LIBUSBDEV_DRIVER_H_
+#define LIBUSBDEV_DRIVER_H_
+
+#include <usb/dev/pipes.h>
+
+/** Descriptors for USB device. */
+typedef struct {
+	/** Standard device descriptor. */
+	usb_standard_device_descriptor_t device;
+	/** Full configuration descriptor of current configuration. */
+	uint8_t *configuration;
+	size_t configuration_size;
+} usb_device_descriptors_t;
+
+/** Wrapper for data related to alternate interface setting.
+ * The pointers will typically point inside configuration descriptor and
+ * thus you shall not deallocate them.
+ */
+typedef struct {
+	/** Interface descriptor. */
+	usb_standard_interface_descriptor_t *interface;
+	/** Pointer to start of descriptor tree bound with this interface. */
+	uint8_t *nested_descriptors;
+	/** Size of data pointed by nested_descriptors in bytes. */
+	size_t nested_descriptors_size;
+} usb_alternate_interface_descriptors_t;
+
+/** Alternate interface settings. */
+typedef struct {
+	/** Array of alternate interfaces descriptions. */
+	usb_alternate_interface_descriptors_t *alternatives;
+	/** Size of @c alternatives array. */
+	size_t alternative_count;
+	/** Index of currently selected one. */
+	size_t current;
+} usb_alternate_interfaces_t;
+
+/** USB device structure. */
+typedef struct {
+	/** The default control pipe. */
+	usb_pipe_t ctrl_pipe;
+	/** Other endpoint pipes.
+	 * This is an array of other endpoint pipes in the same order as
+	 * in usb_driver_t.
+	 */
+	usb_endpoint_mapping_t *pipes;
+	/** Number of other endpoint pipes. */
+	size_t pipes_count;
+	/** Current interface.
+	 * Usually, drivers operate on single interface only.
+	 * This item contains the value of the interface or -1 for any.
+	 */
+	int interface_no;
+
+	/** Alternative interfaces.
+	 * Set to NULL when the driver controls whole device
+	 * (i.e. more (or any) interfaces).
+	 */
+	usb_alternate_interfaces_t *alternate_interfaces;
+
+	/** Some useful descriptors. */
+	usb_device_descriptors_t descriptors;
+
+	/** Generic DDF device backing this one. */
+	ddf_dev_t *ddf_dev;
+	/** Custom driver data.
+	 * Do not use the entry in generic device, that is already used
+	 * by the framework.
+	 */
+	void *driver_data;
+
+	/** Connection backing the pipes.
+	 * Typically, you will not need to use this attribute at all.
+	 */
+	usb_device_connection_t wire;
+} usb_device_t;
+
+/** USB driver ops. */
+typedef struct {
+	/** Callback when new device is about to be controlled by the driver. */
+	int (*add_device)(usb_device_t *);
+} usb_driver_ops_t;
+
+/** USB driver structure. */
+typedef struct {
+	/** Driver name.
+	 * This name is copied to the generic driver name and must be exactly
+	 * the same as the directory name where the driver executable resides.
+	 */
+	const char *name;
+	/** Expected endpoints description.
+	 * This description shall exclude default control endpoint (pipe zero)
+	 * and must be NULL terminated.
+	 * When only control endpoint is expected, you may set NULL directly
+	 * without creating one item array containing NULL.
+	 *
+	 * When the driver expect single interrupt in endpoint,
+	 * the initialization may look like this:
+\code
+static usb_endpoint_description_t poll_endpoint_description = {
+	.transfer_type = USB_TRANSFER_INTERRUPT,
+	.direction = USB_DIRECTION_IN,
+	.interface_class = USB_CLASS_HUB,
+	.interface_subclass = 0,
+	.interface_protocol = 0,
+	.flags = 0
+};
+
+static usb_endpoint_description_t *hub_endpoints[] = {
+	&poll_endpoint_description,
+	NULL
+};
+
+static usb_driver_t hub_driver = {
+	.endpoints = hub_endpoints,
+	...
+};
+\endcode
+	 */
+	usb_endpoint_description_t **endpoints;
+	/** Driver ops. */
+	usb_driver_ops_t *ops;
+} usb_driver_t;
+
+int usb_driver_main(usb_driver_t *);
+
+int usb_device_select_interface(usb_device_t *, uint8_t,
+    usb_endpoint_description_t **);
+
+int usb_device_retrieve_descriptors(usb_pipe_t *, usb_device_descriptors_t *);
+int usb_device_create_pipes(ddf_dev_t *, usb_device_connection_t *,
+    usb_endpoint_description_t **, uint8_t *, size_t, int, int,
+    usb_endpoint_mapping_t **, size_t *);
+int usb_device_destroy_pipes(ddf_dev_t *, usb_endpoint_mapping_t *, size_t);
+int usb_device_create(ddf_dev_t *, usb_endpoint_description_t **, usb_device_t **, const char **);
+
+size_t usb_interface_count_alternates(uint8_t *, size_t, uint8_t);
+int usb_alternate_interfaces_create(uint8_t *, size_t, int,
+    usb_alternate_interfaces_t **);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usbdev/include/usb/dev/hc.h
===================================================================
--- uspace/lib/usbdev/include/usb/dev/hc.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbdev/include/usb/dev/hc.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * 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 libusbdev
+ * @{
+ */
+/** @file
+ * General communication between device drivers and host controller driver.
+ */
+#ifndef LIBUSBDEV_HC_H_
+#define LIBUSBDEV_HC_H_
+
+#include <sys/types.h>
+#include <ipc/devman.h>
+#include <ddf/driver.h>
+#include <bool.h>
+#include <usb/usb.h>
+
+/** Connection to the host controller driver. */
+typedef struct {
+	/** Devman handle of the host controller. */
+	devman_handle_t hc_handle;
+	/** Phone to the host controller. */
+	int hc_phone;
+} usb_hc_connection_t;
+
+int usb_hc_connection_initialize_from_device(usb_hc_connection_t *,
+    ddf_dev_t *);
+int usb_hc_connection_initialize(usb_hc_connection_t *, devman_handle_t);
+
+int usb_hc_connection_open(usb_hc_connection_t *);
+bool usb_hc_connection_is_opened(const usb_hc_connection_t *);
+int usb_hc_connection_close(usb_hc_connection_t *);
+
+
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usbdev/include/usb/dev/hub.h
===================================================================
--- uspace/lib/usbdev/include/usb/dev/hub.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbdev/include/usb/dev/hub.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * 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 libusbdev
+ * @{
+ */
+/** @file
+ * Functions needed by hub drivers.
+ *
+ * For class specific requests, see usb/classes/hub.h.
+ */
+#ifndef LIBUSBDEV_HUB_H_
+#define LIBUSBDEV_HUB_H_
+
+#include <sys/types.h>
+#include <usb/dev/hc.h>
+
+int usb_hc_new_device_wrapper(ddf_dev_t *, usb_hc_connection_t *, usb_speed_t,
+    int (*)(int, void *), int, void *,
+    usb_address_t *, devman_handle_t *,
+    ddf_dev_ops_t *, void *, ddf_fun_t **);
+
+/** Info about device attached to host controller.
+ *
+ * This structure exists only to keep the same signature of
+ * usb_hc_register_device() when more properties of the device
+ * would have to be passed to the host controller.
+ */
+typedef struct {
+	/** Device address. */
+	usb_address_t address;
+	/** Devman handle of the device. */
+	devman_handle_t handle;
+} usb_hc_attached_device_t;
+
+usb_address_t usb_hc_request_address(usb_hc_connection_t *, usb_speed_t);
+int usb_hc_register_device(usb_hc_connection_t *,
+    const usb_hc_attached_device_t *);
+int usb_hc_unregister_device(usb_hc_connection_t *, usb_address_t);
+int usb_hc_get_handle_by_address(usb_hc_connection_t *, usb_address_t,
+    devman_handle_t *);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usbdev/include/usb/dev/pipes.h
===================================================================
--- uspace/lib/usbdev/include/usb/dev/pipes.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbdev/include/usb/dev/pipes.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * 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 libusbdev
+ * @{
+ */
+/** @file
+ * USB pipes representation.
+ */
+#ifndef LIBUSBDEV_PIPES_H_
+#define LIBUSBDEV_PIPES_H_
+
+#include <sys/types.h>
+#include <usb/usb.h>
+#include <usb/dev/hc.h>
+#include <usb/descriptor.h>
+#include <ipc/devman.h>
+#include <ddf/driver.h>
+#include <fibril_synch.h>
+
+/** Abstraction of a physical connection to the device.
+ * This type is an abstraction of the USB wire that connects the host and
+ * the function (device).
+ */
+typedef struct {
+	/** Handle of the host controller device is connected to. */
+	devman_handle_t hc_handle;
+	/** Address of the device. */
+	usb_address_t address;
+} usb_device_connection_t;
+
+/** Abstraction of a logical connection to USB device endpoint.
+ * It encapsulates endpoint attributes (transfer type etc.) as well
+ * as information about currently running sessions.
+ * This endpoint must be bound with existing usb_device_connection_t
+ * (i.e. the wire to send data over).
+ *
+ * Locking order: if you want to lock both mutexes
+ * (@c guard and @c hc_phone_mutex), lock @c guard first.
+ * It is not necessary to lock @c guard if you want to lock @c hc_phone_mutex
+ * only.
+ */
+typedef struct {
+	/** Guard of the whole pipe. */
+	fibril_mutex_t guard;
+
+	/** The connection used for sending the data. */
+	usb_device_connection_t *wire;
+
+	/** Endpoint number. */
+	usb_endpoint_t endpoint_no;
+
+	/** Endpoint transfer type. */
+	usb_transfer_type_t transfer_type;
+
+	/** Endpoint direction. */
+	usb_direction_t direction;
+
+	/** Maximum packet size for the endpoint. */
+	size_t max_packet_size;
+
+	/** Phone to the host controller.
+	 * Negative when no session is active.
+	 * It is an error to access this member without @c hc_phone_mutex
+	 * being locked.
+	 * If call over the phone is to be made, it must be preceeded by
+	 * call to pipe_add_ref() [internal libusb function].
+	 */
+	int hc_phone;
+
+	/** Guard for serialization of requests over the phone. */
+	fibril_mutex_t hc_phone_mutex;
+
+	/** Number of active transfers over the pipe. */
+	int refcount;
+	/** Number of failed attempts to open the HC phone.
+	 * When user requests usb_pipe_start_long_transfer() and the operation
+	 * fails, there is no way to report this to the user.
+	 * That the soft reference counter is increased to record the attempt.
+	 * When the user then request e.g. usb_pipe_read(), it will try to
+	 * add reference as well.
+	 * If that fails, it is reported to the user. If it is okay, the
+	 * real reference counter is incremented.
+	 * The problem might arise when ending the long transfer (since
+	 * the number of references would be only 1, but logically it shall be
+	 * two).
+	 * Decrementing the soft counter first shall solve this.
+	 */
+	int refcount_soft;
+
+	/** Whether to automatically reset halt on the endpoint.
+	 * Valid only for control endpoint zero.
+	 */
+	bool auto_reset_halt;
+} usb_pipe_t;
+
+
+/** Description of endpoint characteristics. */
+typedef struct {
+	/** Transfer type (e.g. control or interrupt). */
+	usb_transfer_type_t transfer_type;
+	/** Transfer direction (to or from a device). */
+	usb_direction_t direction;
+	/** Interface class this endpoint belongs to (-1 for any). */
+	int interface_class;
+	/** Interface subclass this endpoint belongs to (-1 for any). */
+	int interface_subclass;
+	/** Interface protocol this endpoint belongs to (-1 for any). */
+	int interface_protocol;
+	/** Extra endpoint flags. */
+	unsigned int flags;
+} usb_endpoint_description_t;
+
+/** Mapping of endpoint pipes and endpoint descriptions. */
+typedef struct {
+	/** Endpoint pipe. */
+	usb_pipe_t *pipe;
+	/** Endpoint description. */
+	const usb_endpoint_description_t *description;
+	/** Interface number the endpoint must belong to (-1 for any). */
+	int interface_no;
+	/** Alternate interface setting to choose. */
+	int interface_setting;
+	/** Found descriptor fitting the description. */
+	usb_standard_endpoint_descriptor_t *descriptor;
+	/** Interface descriptor the endpoint belongs to. */
+	usb_standard_interface_descriptor_t *interface;
+	/** Whether the endpoint was actually found. */
+	bool present;
+} usb_endpoint_mapping_t;
+
+int usb_device_connection_initialize_on_default_address(
+    usb_device_connection_t *, usb_hc_connection_t *);
+int usb_device_connection_initialize_from_device(usb_device_connection_t *,
+    ddf_dev_t *);
+int usb_device_connection_initialize(usb_device_connection_t *,
+    devman_handle_t, usb_address_t);
+
+int usb_device_get_assigned_interface(ddf_dev_t *);
+usb_address_t usb_device_get_assigned_address(devman_handle_t);
+
+int usb_pipe_initialize(usb_pipe_t *, usb_device_connection_t *,
+    usb_endpoint_t, usb_transfer_type_t, size_t, usb_direction_t);
+int usb_pipe_initialize_default_control(usb_pipe_t *,
+    usb_device_connection_t *);
+int usb_pipe_probe_default_control(usb_pipe_t *);
+int usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
+    size_t, uint8_t *, size_t, usb_device_connection_t *);
+int usb_pipe_register_with_speed(usb_pipe_t *, usb_speed_t,
+    unsigned int, usb_hc_connection_t *);
+int usb_pipe_register(usb_pipe_t *, unsigned int, usb_hc_connection_t *);
+int usb_pipe_unregister(usb_pipe_t *, usb_hc_connection_t *);
+
+void usb_pipe_start_long_transfer(usb_pipe_t *);
+void usb_pipe_end_long_transfer(usb_pipe_t *);
+
+int usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *);
+int usb_pipe_write(usb_pipe_t *, void *, size_t);
+
+int usb_pipe_control_read(usb_pipe_t *, void *, size_t,
+    void *, size_t, size_t *);
+int usb_pipe_control_write(usb_pipe_t *, void *, size_t,
+    void *, size_t);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usbdev/include/usb/dev/poll.h
===================================================================
--- uspace/lib/usbdev/include/usb/dev/poll.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbdev/include/usb/dev/poll.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * 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 libusbdev
+ * @{
+ */
+/** @file
+ * USB device polling functions.
+ */
+#ifndef LIBUSBDEV_POLL_H_
+#define LIBUSBDEV_POLL_H_
+
+#include <usb/dev/driver.h>
+#include <time.h>
+
+typedef struct {
+	/** Level of debugging messages from auto polling.
+	 * 0 - nothing
+	 * 1 - inform about errors and polling start/end
+	 * 2 - also dump every retrieved buffer
+	 */
+	int debug;
+	/** Maximum number of consecutive errors before polling termination. */
+	size_t max_failures;
+	/** Delay between poll requests in milliseconds.
+	 * Set to negative value to use value from endpoint descriptor.
+	 */
+	int delay;
+	/** Whether to automatically try to clear the HALT feature after
+	 * the endpoint stalls.
+	 */
+	bool auto_clear_halt;
+	/** Callback when data arrives.
+	 *
+	 * @param dev Device that was polled.
+	 * @param data Data buffer (in USB endianness).
+	 * @param data_size Size of the @p data buffer in bytes.
+	 * @param arg Custom argument.
+	 * @return Whether to continue in polling.
+	 */
+	bool (*on_data)(usb_device_t *dev, uint8_t *data, size_t data_size,
+	    void *arg);
+	/** Callback when polling is terminated.
+	 *
+	 * @param dev Device where the polling was terminated.
+	 * @param due_to_errors Whether polling stopped due to several failures.
+	 * @param arg Custom argument.
+	 */
+	void (*on_polling_end)(usb_device_t *dev, bool due_to_errors,
+	    void *arg);
+	/** Callback when error occurs.
+	 *
+	 * @param dev Device where error occurred.
+	 * @param err_code Error code (as returned from usb_pipe_read).
+	 * @param arg Custom argument.
+	 * @return Whether to continue in polling.
+	 */
+	bool (*on_error)(usb_device_t *dev, int err_code, void *arg);
+} usb_device_auto_polling_t;
+
+int usb_device_auto_polling(usb_device_t *, size_t, usb_device_auto_polling_t *,
+    size_t, void *);
+
+typedef bool (*usb_polling_callback_t)(usb_device_t *,
+    uint8_t *, size_t, void *);
+typedef void (*usb_polling_terminted_callback_t)(usb_device_t *, bool, void *);
+
+int usb_device_auto_poll(usb_device_t *, size_t,
+    usb_polling_callback_t, size_t, usb_polling_terminted_callback_t, void *);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usbdev/include/usb/dev/recognise.h
===================================================================
--- uspace/lib/usbdev/include/usb/dev/recognise.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbdev/include/usb/dev/recognise.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * 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 libusbdev
+ * @{
+ */
+/** @file
+ * USB device recognition.
+ */
+#ifndef LIBUSBDEV_RECOGNISE_H_
+#define LIBUSBDEV_RECOGNISE_H_
+
+#include <sys/types.h>
+#include <usb/usb.h>
+#include <usb/dev/pipes.h>
+#include <ipc/devman.h>
+
+int usb_device_create_match_ids_from_device_descriptor(
+    const usb_standard_device_descriptor_t *, match_id_list_t *);
+
+int usb_device_create_match_ids_from_interface(
+    const usb_standard_device_descriptor_t *,
+    const usb_standard_interface_descriptor_t *, match_id_list_t *);
+
+int usb_device_create_match_ids(usb_pipe_t *, match_id_list_t *);
+
+int usb_device_register_child_in_devman(usb_address_t, devman_handle_t,
+    ddf_dev_t *, devman_handle_t *, ddf_dev_ops_t *, void *, ddf_fun_t **);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usbdev/include/usb/dev/request.h
===================================================================
--- uspace/lib/usbdev/include/usb/dev/request.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbdev/include/usb/dev/request.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * 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 libusbdev
+ * @{
+ */
+/** @file
+ * Standard USB requests.
+ */
+#ifndef LIBUSBDEV_REQUEST_H_
+#define LIBUSBDEV_REQUEST_H_
+
+#include <sys/types.h>
+#include <l18n/langs.h>
+#include <usb/usb.h>
+#include <usb/dev/pipes.h>
+#include <usb/descriptor.h>
+
+/** USB device status - device is self powered (opposed to bus powered). */
+#define USB_DEVICE_STATUS_SELF_POWERED ((uint16_t)(1 << 0))
+
+/** USB device status - remote wake-up signaling is enabled. */
+#define USB_DEVICE_STATUS_REMOTE_WAKEUP ((uint16_t)(1 << 1))
+
+/** USB endpoint status - endpoint is halted (stalled). */
+#define USB_ENDPOINT_STATUS_HALTED ((uint16_t)(1 << 0))
+
+/** USB feature selector - endpoint halt (stall). */
+#define USB_FEATURE_SELECTOR_ENDPOINT_HALT (0)
+
+/** USB feature selector - device remote wake-up. */
+#define USB_FEATURE_SELECTOR_REMOTE_WAKEUP (1)
+
+/** Standard device request. */
+typedef enum {
+	USB_DEVREQ_GET_STATUS = 0,
+	USB_DEVREQ_CLEAR_FEATURE = 1,
+	USB_DEVREQ_SET_FEATURE = 3,
+	USB_DEVREQ_SET_ADDRESS = 5,
+	USB_DEVREQ_GET_DESCRIPTOR = 6,
+	USB_DEVREQ_SET_DESCRIPTOR = 7,
+	USB_DEVREQ_GET_CONFIGURATION = 8,
+	USB_DEVREQ_SET_CONFIGURATION = 9,
+	USB_DEVREQ_GET_INTERFACE = 10,
+	USB_DEVREQ_SET_INTERFACE = 11,
+	USB_DEVREQ_SYNCH_FRAME = 12,
+	USB_DEVREQ_LAST_STD
+} usb_stddevreq_t;
+
+/** Device request setup packet.
+ * The setup packet describes the request.
+ */
+typedef struct {
+	/** Request type.
+	 * The type combines transfer direction, request type and
+	 * intended recipient.
+	 */
+	uint8_t request_type;
+	/** Request identification. */
+	uint8_t request;
+	/** Main parameter to the request. */
+	union {
+		uint16_t value;
+		/* FIXME: add #ifdefs according to host endianness */
+		struct {
+			uint8_t value_low;
+			uint8_t value_high;
+		};
+	};
+	/** Auxiliary parameter to the request.
+	 * Typically, it is offset to something.
+	 */
+	uint16_t index;
+	/** Length of extra data. */
+	uint16_t length;
+} __attribute__ ((packed)) usb_device_request_setup_packet_t;
+
+int usb_control_request_set(usb_pipe_t *,
+    usb_request_type_t, usb_request_recipient_t, uint8_t,
+    uint16_t, uint16_t, void *, size_t);
+
+int usb_control_request_get(usb_pipe_t *,
+    usb_request_type_t, usb_request_recipient_t, uint8_t,
+    uint16_t, uint16_t, void *, size_t, size_t *);
+
+int usb_request_get_status(usb_pipe_t *, usb_request_recipient_t,
+    uint16_t, uint16_t *);
+int usb_request_clear_feature(usb_pipe_t *, usb_request_type_t,
+    usb_request_recipient_t, uint16_t, uint16_t);
+int usb_request_set_feature(usb_pipe_t *, usb_request_type_t,
+    usb_request_recipient_t, uint16_t, uint16_t);
+int usb_request_set_address(usb_pipe_t *, usb_address_t);
+int usb_request_get_descriptor(usb_pipe_t *, usb_request_type_t,
+    usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void *, size_t, 
+    size_t *);
+int usb_request_get_descriptor_alloc(usb_pipe_t *, usb_request_type_t,
+    usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void **, size_t *);
+int usb_request_get_device_descriptor(usb_pipe_t *,
+    usb_standard_device_descriptor_t *);
+int usb_request_get_bare_configuration_descriptor(usb_pipe_t *, int,
+    usb_standard_configuration_descriptor_t *);
+int usb_request_get_full_configuration_descriptor(usb_pipe_t *, int,
+    void *, size_t, size_t *);
+int usb_request_get_full_configuration_descriptor_alloc(usb_pipe_t *,
+    int, void **, size_t *);
+int usb_request_set_descriptor(usb_pipe_t *, usb_request_type_t,
+    usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void *, size_t);
+int usb_request_get_configuration(usb_pipe_t *, uint8_t *);
+int usb_request_set_configuration(usb_pipe_t *, uint8_t);
+int usb_request_get_interface(usb_pipe_t *, uint8_t, uint8_t *);
+int usb_request_set_interface(usb_pipe_t *, uint8_t, uint8_t);
+
+int usb_request_get_supported_languages(usb_pipe_t *,
+    l18_win_locales_t **, size_t *);
+int usb_request_get_string(usb_pipe_t *, size_t, l18_win_locales_t,
+    char **);
+
+int usb_request_clear_endpoint_halt(usb_pipe_t *, uint16_t);
+int usb_pipe_clear_halt(usb_pipe_t *, usb_pipe_t *);
+int usb_request_get_endpoint_status(usb_pipe_t *, usb_pipe_t *, uint16_t *);
+
+#endif
+/**
+ * @}
+ */
Index: pace/lib/usbdev/include/usb/devdrv.h
===================================================================
--- uspace/lib/usbdev/include/usb/devdrv.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,178 +1,0 @@
-/*
- * Copyright (c) 2011 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * USB device driver framework.
- */
-#ifndef LIBUSB_DEVDRV_H_
-#define LIBUSB_DEVDRV_H_
-
-#include <usb/pipes.h>
-
-/** Descriptors for USB device. */
-typedef struct {
-	/** Standard device descriptor. */
-	usb_standard_device_descriptor_t device;
-	/** Full configuration descriptor of current configuration. */
-	uint8_t *configuration;
-	size_t configuration_size;
-} usb_device_descriptors_t;
-
-/** Wrapper for data related to alternate interface setting.
- * The pointers will typically point inside configuration descriptor and
- * thus you shall not deallocate them.
- */
-typedef struct {
-	/** Interface descriptor. */
-	usb_standard_interface_descriptor_t *interface;
-	/** Pointer to start of descriptor tree bound with this interface. */
-	uint8_t *nested_descriptors;
-	/** Size of data pointed by nested_descriptors in bytes. */
-	size_t nested_descriptors_size;
-} usb_alternate_interface_descriptors_t;
-
-/** Alternate interface settings. */
-typedef struct {
-	/** Array of alternate interfaces descriptions. */
-	usb_alternate_interface_descriptors_t *alternatives;
-	/** Size of @c alternatives array. */
-	size_t alternative_count;
-	/** Index of currently selected one. */
-	size_t current;
-} usb_alternate_interfaces_t;
-
-/** USB device structure. */
-typedef struct {
-	/** The default control pipe. */
-	usb_pipe_t ctrl_pipe;
-	/** Other endpoint pipes.
-	 * This is an array of other endpoint pipes in the same order as
-	 * in usb_driver_t.
-	 */
-	usb_endpoint_mapping_t *pipes;
-	/** Number of other endpoint pipes. */
-	size_t pipes_count;
-	/** Current interface.
-	 * Usually, drivers operate on single interface only.
-	 * This item contains the value of the interface or -1 for any.
-	 */
-	int interface_no;
-
-	/** Alternative interfaces.
-	 * Set to NULL when the driver controls whole device
-	 * (i.e. more (or any) interfaces).
-	 */
-	usb_alternate_interfaces_t *alternate_interfaces;
-
-	/** Some useful descriptors. */
-	usb_device_descriptors_t descriptors;
-
-	/** Generic DDF device backing this one. */
-	ddf_dev_t *ddf_dev;
-	/** Custom driver data.
-	 * Do not use the entry in generic device, that is already used
-	 * by the framework.
-	 */
-	void *driver_data;
-
-	/** Connection backing the pipes.
-	 * Typically, you will not need to use this attribute at all.
-	 */
-	usb_device_connection_t wire;
-} usb_device_t;
-
-/** USB driver ops. */
-typedef struct {
-	/** Callback when new device is about to be controlled by the driver. */
-	int (*add_device)(usb_device_t *);
-} usb_driver_ops_t;
-
-/** USB driver structure. */
-typedef struct {
-	/** Driver name.
-	 * This name is copied to the generic driver name and must be exactly
-	 * the same as the directory name where the driver executable resides.
-	 */
-	const char *name;
-	/** Expected endpoints description.
-	 * This description shall exclude default control endpoint (pipe zero)
-	 * and must be NULL terminated.
-	 * When only control endpoint is expected, you may set NULL directly
-	 * without creating one item array containing NULL.
-	 *
-	 * When the driver expect single interrupt in endpoint,
-	 * the initialization may look like this:
-\code
-static usb_endpoint_description_t poll_endpoint_description = {
-	.transfer_type = USB_TRANSFER_INTERRUPT,
-	.direction = USB_DIRECTION_IN,
-	.interface_class = USB_CLASS_HUB,
-	.interface_subclass = 0,
-	.interface_protocol = 0,
-	.flags = 0
-};
-
-static usb_endpoint_description_t *hub_endpoints[] = {
-	&poll_endpoint_description,
-	NULL
-};
-
-static usb_driver_t hub_driver = {
-	.endpoints = hub_endpoints,
-	...
-};
-\endcode
-	 */
-	usb_endpoint_description_t **endpoints;
-	/** Driver ops. */
-	usb_driver_ops_t *ops;
-} usb_driver_t;
-
-int usb_driver_main(usb_driver_t *);
-
-int usb_device_select_interface(usb_device_t *, uint8_t,
-    usb_endpoint_description_t **);
-
-int usb_device_retrieve_descriptors(usb_pipe_t *, usb_device_descriptors_t *);
-int usb_device_create_pipes(ddf_dev_t *, usb_device_connection_t *,
-    usb_endpoint_description_t **, uint8_t *, size_t, int, int,
-    usb_endpoint_mapping_t **, size_t *);
-int usb_device_destroy_pipes(ddf_dev_t *, usb_endpoint_mapping_t *, size_t);
-int usb_device_create(ddf_dev_t *, usb_endpoint_description_t **, usb_device_t **, const char **);
-
-size_t usb_interface_count_alternates(uint8_t *, size_t, uint8_t);
-int usb_alternate_interfaces_create(uint8_t *, size_t, int,
-    usb_alternate_interfaces_t **);
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usbdev/include/usb/devpoll.h
===================================================================
--- uspace/lib/usbdev/include/usb/devpoll.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,99 +1,0 @@
-/*
- * Copyright (c) 2011 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * USB device polling functions.
- */
-#ifndef LIBUSB_DEVPOLL_H_
-#define LIBUSB_DEVPOLL_H_
-
-#include <usb/devdrv.h>
-#include <time.h>
-
-typedef struct {
-	/** Level of debugging messages from auto polling.
-	 * 0 - nothing
-	 * 1 - inform about errors and polling start/end
-	 * 2 - also dump every retrieved buffer
-	 */
-	int debug;
-	/** Maximum number of consecutive errors before polling termination. */
-	size_t max_failures;
-	/** Delay between poll requests in milliseconds.
-	 * Set to negative value to use value from endpoint descriptor.
-	 */
-	int delay;
-	/** Whether to automatically try to clear the HALT feature after
-	 * the endpoint stalls.
-	 */
-	bool auto_clear_halt;
-	/** Callback when data arrives.
-	 *
-	 * @param dev Device that was polled.
-	 * @param data Data buffer (in USB endianness).
-	 * @param data_size Size of the @p data buffer in bytes.
-	 * @param arg Custom argument.
-	 * @return Whether to continue in polling.
-	 */
-	bool (*on_data)(usb_device_t *dev, uint8_t *data, size_t data_size,
-	    void *arg);
-	/** Callback when polling is terminated.
-	 *
-	 * @param dev Device where the polling was terminated.
-	 * @param due_to_errors Whether polling stopped due to several failures.
-	 * @param arg Custom argument.
-	 */
-	void (*on_polling_end)(usb_device_t *dev, bool due_to_errors,
-	    void *arg);
-	/** Callback when error occurs.
-	 *
-	 * @param dev Device where error occurred.
-	 * @param err_code Error code (as returned from usb_pipe_read).
-	 * @param arg Custom argument.
-	 * @return Whether to continue in polling.
-	 */
-	bool (*on_error)(usb_device_t *dev, int err_code, void *arg);
-} usb_device_auto_polling_t;
-
-int usb_device_auto_polling(usb_device_t *, size_t, usb_device_auto_polling_t *,
-    size_t, void *);
-
-typedef bool (*usb_polling_callback_t)(usb_device_t *,
-    uint8_t *, size_t, void *);
-typedef void (*usb_polling_terminted_callback_t)(usb_device_t *, bool, void *);
-
-int usb_device_auto_poll(usb_device_t *, size_t,
-    usb_polling_callback_t, size_t, usb_polling_terminted_callback_t, void *);
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usbdev/include/usb/dp.h
===================================================================
--- uspace/lib/usbdev/include/usb/dp.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,85 +1,0 @@
-/*
- * Copyright (c) 2011 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * USB descriptor parser.
- */
-#ifndef LIBUSB_DP_H_
-#define LIBUSB_DP_H_
-
-#include <sys/types.h>
-#include <usb/usb.h>
-#include <usb/descriptor.h>
-
-/** USB descriptors nesting.
- * The nesting describes the logical tree USB descriptors form
- * (e.g. that endpoint descriptor belongs to interface or that
- * interface belongs to configuration).
- *
- * See usb_descriptor_type_t for descriptor constants.
- */
-typedef struct {
-	/** Child descriptor id. */
-	int child;
-	/** Parent descriptor id. */
-	int parent;
-} usb_dp_descriptor_nesting_t;
-
-extern usb_dp_descriptor_nesting_t usb_dp_standard_descriptor_nesting[];
-
-/** Descriptor parser structure. */
-typedef struct {
-	/** Used descriptor nesting. */
-	usb_dp_descriptor_nesting_t *nesting;
-} usb_dp_parser_t;
-
-/** Descriptor parser data. */
-typedef struct {
-	/** Data to be parsed. */
-	uint8_t *data;
-	/** Size of input data in bytes. */
-	size_t size;
-	/** Custom argument. */
-	void *arg;
-} usb_dp_parser_data_t;
-
-uint8_t *usb_dp_get_nested_descriptor(usb_dp_parser_t *,
-    usb_dp_parser_data_t *, uint8_t *);
-uint8_t *usb_dp_get_sibling_descriptor(usb_dp_parser_t *,
-    usb_dp_parser_data_t *, uint8_t *, uint8_t *);
-
-void usb_dp_walk_simple(uint8_t *, size_t, usb_dp_descriptor_nesting_t *,
-    void (*)(uint8_t *, size_t, void *), void *);
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usbdev/include/usb/hub.h
===================================================================
--- uspace/lib/usbdev/include/usb/hub.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,71 +1,0 @@
-/*
- * Copyright (c) 2011 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * Functions needed by hub drivers.
- *
- * For class specific requests, see usb/classes/hub.h.
- */
-#ifndef LIBUSB_HUB_H_
-#define LIBUSB_HUB_H_
-
-#include <sys/types.h>
-#include <usb/usbdevice.h>
-
-int usb_hc_new_device_wrapper(ddf_dev_t *, usb_hc_connection_t *, usb_speed_t,
-    int (*)(int, void *), int, void *,
-    usb_address_t *, devman_handle_t *,
-    ddf_dev_ops_t *, void *, ddf_fun_t **);
-
-/** Info about device attached to host controller.
- *
- * This structure exists only to keep the same signature of
- * usb_hc_register_device() when more properties of the device
- * would have to be passed to the host controller.
- */
-typedef struct {
-	/** Device address. */
-	usb_address_t address;
-	/** Devman handle of the device. */
-	devman_handle_t handle;
-} usb_hc_attached_device_t;
-
-usb_address_t usb_hc_request_address(usb_hc_connection_t *, usb_speed_t);
-int usb_hc_register_device(usb_hc_connection_t *,
-    const usb_hc_attached_device_t *);
-int usb_hc_unregister_device(usb_hc_connection_t *, usb_address_t);
-int usb_hc_get_handle_by_address(usb_hc_connection_t *, usb_address_t,
-    devman_handle_t *);
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usbdev/include/usb/pipes.h
===================================================================
--- uspace/lib/usbdev/include/usb/pipes.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,193 +1,0 @@
-/*
- * Copyright (c) 2011 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * USB pipes representation.
- */
-#ifndef LIBUSB_PIPES_H_
-#define LIBUSB_PIPES_H_
-
-#include <sys/types.h>
-#include <usb/usb.h>
-#include <usb/usbdevice.h>
-#include <usb/descriptor.h>
-#include <ipc/devman.h>
-#include <ddf/driver.h>
-#include <fibril_synch.h>
-
-/** Abstraction of a physical connection to the device.
- * This type is an abstraction of the USB wire that connects the host and
- * the function (device).
- */
-typedef struct {
-	/** Handle of the host controller device is connected to. */
-	devman_handle_t hc_handle;
-	/** Address of the device. */
-	usb_address_t address;
-} usb_device_connection_t;
-
-/** Abstraction of a logical connection to USB device endpoint.
- * It encapsulates endpoint attributes (transfer type etc.) as well
- * as information about currently running sessions.
- * This endpoint must be bound with existing usb_device_connection_t
- * (i.e. the wire to send data over).
- *
- * Locking order: if you want to lock both mutexes
- * (@c guard and @c hc_phone_mutex), lock @c guard first.
- * It is not necessary to lock @c guard if you want to lock @c hc_phone_mutex
- * only.
- */
-typedef struct {
-	/** Guard of the whole pipe. */
-	fibril_mutex_t guard;
-
-	/** The connection used for sending the data. */
-	usb_device_connection_t *wire;
-
-	/** Endpoint number. */
-	usb_endpoint_t endpoint_no;
-
-	/** Endpoint transfer type. */
-	usb_transfer_type_t transfer_type;
-
-	/** Endpoint direction. */
-	usb_direction_t direction;
-
-	/** Maximum packet size for the endpoint. */
-	size_t max_packet_size;
-
-	/** Phone to the host controller.
-	 * Negative when no session is active.
-	 * It is an error to access this member without @c hc_phone_mutex
-	 * being locked.
-	 * If call over the phone is to be made, it must be preceeded by
-	 * call to pipe_add_ref() [internal libusb function].
-	 */
-	int hc_phone;
-
-	/** Guard for serialization of requests over the phone. */
-	fibril_mutex_t hc_phone_mutex;
-
-	/** Number of active transfers over the pipe. */
-	int refcount;
-	/** Number of failed attempts to open the HC phone.
-	 * When user requests usb_pipe_start_long_transfer() and the operation
-	 * fails, there is no way to report this to the user.
-	 * That the soft reference counter is increased to record the attempt.
-	 * When the user then request e.g. usb_pipe_read(), it will try to
-	 * add reference as well.
-	 * If that fails, it is reported to the user. If it is okay, the
-	 * real reference counter is incremented.
-	 * The problem might arise when ending the long transfer (since
-	 * the number of references would be only 1, but logically it shall be
-	 * two).
-	 * Decrementing the soft counter first shall solve this.
-	 */
-	int refcount_soft;
-
-	/** Whether to automatically reset halt on the endpoint.
-	 * Valid only for control endpoint zero.
-	 */
-	bool auto_reset_halt;
-} usb_pipe_t;
-
-
-/** Description of endpoint characteristics. */
-typedef struct {
-	/** Transfer type (e.g. control or interrupt). */
-	usb_transfer_type_t transfer_type;
-	/** Transfer direction (to or from a device). */
-	usb_direction_t direction;
-	/** Interface class this endpoint belongs to (-1 for any). */
-	int interface_class;
-	/** Interface subclass this endpoint belongs to (-1 for any). */
-	int interface_subclass;
-	/** Interface protocol this endpoint belongs to (-1 for any). */
-	int interface_protocol;
-	/** Extra endpoint flags. */
-	unsigned int flags;
-} usb_endpoint_description_t;
-
-/** Mapping of endpoint pipes and endpoint descriptions. */
-typedef struct {
-	/** Endpoint pipe. */
-	usb_pipe_t *pipe;
-	/** Endpoint description. */
-	const usb_endpoint_description_t *description;
-	/** Interface number the endpoint must belong to (-1 for any). */
-	int interface_no;
-	/** Alternate interface setting to choose. */
-	int interface_setting;
-	/** Found descriptor fitting the description. */
-	usb_standard_endpoint_descriptor_t *descriptor;
-	/** Interface descriptor the endpoint belongs to. */
-	usb_standard_interface_descriptor_t *interface;
-	/** Whether the endpoint was actually found. */
-	bool present;
-} usb_endpoint_mapping_t;
-
-int usb_device_connection_initialize_on_default_address(
-    usb_device_connection_t *, usb_hc_connection_t *);
-int usb_device_connection_initialize_from_device(usb_device_connection_t *,
-    ddf_dev_t *);
-int usb_device_connection_initialize(usb_device_connection_t *,
-    devman_handle_t, usb_address_t);
-
-int usb_device_get_assigned_interface(ddf_dev_t *);
-usb_address_t usb_device_get_assigned_address(devman_handle_t);
-
-int usb_pipe_initialize(usb_pipe_t *, usb_device_connection_t *,
-    usb_endpoint_t, usb_transfer_type_t, size_t, usb_direction_t);
-int usb_pipe_initialize_default_control(usb_pipe_t *,
-    usb_device_connection_t *);
-int usb_pipe_probe_default_control(usb_pipe_t *);
-int usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
-    size_t, uint8_t *, size_t, usb_device_connection_t *);
-int usb_pipe_register_with_speed(usb_pipe_t *, usb_speed_t,
-    unsigned int, usb_hc_connection_t *);
-int usb_pipe_register(usb_pipe_t *, unsigned int, usb_hc_connection_t *);
-int usb_pipe_unregister(usb_pipe_t *, usb_hc_connection_t *);
-
-void usb_pipe_start_long_transfer(usb_pipe_t *);
-void usb_pipe_end_long_transfer(usb_pipe_t *);
-
-int usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *);
-int usb_pipe_write(usb_pipe_t *, void *, size_t);
-
-int usb_pipe_control_read(usb_pipe_t *, void *, size_t,
-    void *, size_t, size_t *);
-int usb_pipe_control_write(usb_pipe_t *, void *, size_t,
-    void *, size_t);
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usbdev/include/usb/recognise.h
===================================================================
--- uspace/lib/usbdev/include/usb/recognise.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,58 +1,0 @@
-/*
- * Copyright (c) 2011 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * USB device recognition.
- */
-#ifndef LIBUSB_RECOGNISE_H_
-#define LIBUSB_RECOGNISE_H_
-
-#include <sys/types.h>
-#include <usb/usb.h>
-#include <usb/pipes.h>
-#include <ipc/devman.h>
-
-int usb_device_create_match_ids_from_device_descriptor(
-    const usb_standard_device_descriptor_t *, match_id_list_t *);
-
-int usb_device_create_match_ids_from_interface(
-    const usb_standard_device_descriptor_t *,
-    const usb_standard_interface_descriptor_t *, match_id_list_t *);
-
-int usb_device_create_match_ids(usb_pipe_t *, match_id_list_t *);
-
-int usb_device_register_child_in_devman(usb_address_t, devman_handle_t,
-    ddf_dev_t *, devman_handle_t *, ddf_dev_ops_t *, void *, ddf_fun_t **);
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usbdev/include/usb/request.h
===================================================================
--- uspace/lib/usbdev/include/usb/request.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,150 +1,0 @@
-/*
- * Copyright (c) 2011 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * Standard USB requests.
- */
-#ifndef LIBUSB_REQUEST_H_
-#define LIBUSB_REQUEST_H_
-
-#include <sys/types.h>
-#include <l18n/langs.h>
-#include <usb/usb.h>
-#include <usb/pipes.h>
-#include <usb/descriptor.h>
-
-/** USB device status - device is self powered (opposed to bus powered). */
-#define USB_DEVICE_STATUS_SELF_POWERED ((uint16_t)(1 << 0))
-
-/** USB device status - remote wake-up signaling is enabled. */
-#define USB_DEVICE_STATUS_REMOTE_WAKEUP ((uint16_t)(1 << 1))
-
-/** USB endpoint status - endpoint is halted (stalled). */
-#define USB_ENDPOINT_STATUS_HALTED ((uint16_t)(1 << 0))
-
-/** USB feature selector - endpoint halt (stall). */
-#define USB_FEATURE_SELECTOR_ENDPOINT_HALT (0)
-
-/** USB feature selector - device remote wake-up. */
-#define USB_FEATURE_SELECTOR_REMOTE_WAKEUP (1)
-
-/** Standard device request. */
-typedef enum {
-	USB_DEVREQ_GET_STATUS = 0,
-	USB_DEVREQ_CLEAR_FEATURE = 1,
-	USB_DEVREQ_SET_FEATURE = 3,
-	USB_DEVREQ_SET_ADDRESS = 5,
-	USB_DEVREQ_GET_DESCRIPTOR = 6,
-	USB_DEVREQ_SET_DESCRIPTOR = 7,
-	USB_DEVREQ_GET_CONFIGURATION = 8,
-	USB_DEVREQ_SET_CONFIGURATION = 9,
-	USB_DEVREQ_GET_INTERFACE = 10,
-	USB_DEVREQ_SET_INTERFACE = 11,
-	USB_DEVREQ_SYNCH_FRAME = 12,
-	USB_DEVREQ_LAST_STD
-} usb_stddevreq_t;
-
-/** Device request setup packet.
- * The setup packet describes the request.
- */
-typedef struct {
-	/** Request type.
-	 * The type combines transfer direction, request type and
-	 * intended recipient.
-	 */
-	uint8_t request_type;
-	/** Request identification. */
-	uint8_t request;
-	/** Main parameter to the request. */
-	union {
-		uint16_t value;
-		/* FIXME: add #ifdefs according to host endianness */
-		struct {
-			uint8_t value_low;
-			uint8_t value_high;
-		};
-	};
-	/** Auxiliary parameter to the request.
-	 * Typically, it is offset to something.
-	 */
-	uint16_t index;
-	/** Length of extra data. */
-	uint16_t length;
-} __attribute__ ((packed)) usb_device_request_setup_packet_t;
-
-int usb_control_request_set(usb_pipe_t *,
-    usb_request_type_t, usb_request_recipient_t, uint8_t,
-    uint16_t, uint16_t, void *, size_t);
-
-int usb_control_request_get(usb_pipe_t *,
-    usb_request_type_t, usb_request_recipient_t, uint8_t,
-    uint16_t, uint16_t, void *, size_t, size_t *);
-
-int usb_request_get_status(usb_pipe_t *, usb_request_recipient_t,
-    uint16_t, uint16_t *);
-int usb_request_clear_feature(usb_pipe_t *, usb_request_type_t,
-    usb_request_recipient_t, uint16_t, uint16_t);
-int usb_request_set_feature(usb_pipe_t *, usb_request_type_t,
-    usb_request_recipient_t, uint16_t, uint16_t);
-int usb_request_set_address(usb_pipe_t *, usb_address_t);
-int usb_request_get_descriptor(usb_pipe_t *, usb_request_type_t,
-    usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void *, size_t, 
-    size_t *);
-int usb_request_get_descriptor_alloc(usb_pipe_t *, usb_request_type_t,
-    usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void **, size_t *);
-int usb_request_get_device_descriptor(usb_pipe_t *,
-    usb_standard_device_descriptor_t *);
-int usb_request_get_bare_configuration_descriptor(usb_pipe_t *, int,
-    usb_standard_configuration_descriptor_t *);
-int usb_request_get_full_configuration_descriptor(usb_pipe_t *, int,
-    void *, size_t, size_t *);
-int usb_request_get_full_configuration_descriptor_alloc(usb_pipe_t *,
-    int, void **, size_t *);
-int usb_request_set_descriptor(usb_pipe_t *, usb_request_type_t,
-    usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void *, size_t);
-int usb_request_get_configuration(usb_pipe_t *, uint8_t *);
-int usb_request_set_configuration(usb_pipe_t *, uint8_t);
-int usb_request_get_interface(usb_pipe_t *, uint8_t, uint8_t *);
-int usb_request_set_interface(usb_pipe_t *, uint8_t, uint8_t);
-
-int usb_request_get_supported_languages(usb_pipe_t *,
-    l18_win_locales_t **, size_t *);
-int usb_request_get_string(usb_pipe_t *, size_t, l18_win_locales_t,
-    char **);
-
-int usb_request_clear_endpoint_halt(usb_pipe_t *, uint16_t);
-int usb_pipe_clear_halt(usb_pipe_t *, usb_pipe_t *);
-int usb_request_get_endpoint_status(usb_pipe_t *, usb_pipe_t *, uint16_t *);
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usbdev/include/usb/usbdevice.h
===================================================================
--- uspace/lib/usbdev/include/usb/usbdevice.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,65 +1,0 @@
-/*
- * Copyright (c) 2011 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * General communication between device drivers and host controller driver.
- */
-#ifndef LIBUSB_USBDEVICE_H_
-#define LIBUSB_USBDEVICE_H_
-
-#include <sys/types.h>
-#include <ipc/devman.h>
-#include <ddf/driver.h>
-#include <bool.h>
-#include <usb/usb.h>
-
-/** Connection to the host controller driver. */
-typedef struct {
-	/** Devman handle of the host controller. */
-	devman_handle_t hc_handle;
-	/** Phone to the host controller. */
-	int hc_phone;
-} usb_hc_connection_t;
-
-int usb_hc_connection_initialize_from_device(usb_hc_connection_t *,
-    ddf_dev_t *);
-int usb_hc_connection_initialize(usb_hc_connection_t *, devman_handle_t);
-
-int usb_hc_connection_open(usb_hc_connection_t *);
-bool usb_hc_connection_is_opened(const usb_hc_connection_t *);
-int usb_hc_connection_close(usb_hc_connection_t *);
-
-
-
-#endif
-/**
- * @}
- */
Index: uspace/lib/usbdev/src/altiface.c
===================================================================
--- uspace/lib/usbdev/src/altiface.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbdev/src/altiface.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbdev
  * @{
  */
@@ -33,8 +33,8 @@
  * Handling alternate interface settings.
  */
-#include <usb/devdrv.h>
-#include <usb/request.h>
+#include <usb/dev/driver.h>
+#include <usb/dev/request.h>
 #include <usb/debug.h>
-#include <usb/dp.h>
+#include <usb/dev/dp.h>
 #include <errno.h>
 #include <str_error.h>
Index: uspace/lib/usbdev/src/devdrv.c
===================================================================
--- uspace/lib/usbdev/src/devdrv.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbdev/src/devdrv.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbdev
  * @{
  */
@@ -33,8 +33,8 @@
  * USB device driver framework.
  */
-#include <usb/devdrv.h>
-#include <usb/request.h>
+#include <usb/dev/driver.h>
+#include <usb/dev/request.h>
 #include <usb/debug.h>
-#include <usb/dp.h>
+#include <usb/dev/dp.h>
 #include <errno.h>
 #include <str_error.h>
Index: uspace/lib/usbdev/src/devpoll.c
===================================================================
--- uspace/lib/usbdev/src/devpoll.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbdev/src/devpoll.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbdev
  * @{
  */
@@ -33,6 +33,6 @@
  * USB device driver framework - automatic interrupt polling.
  */
-#include <usb/devpoll.h>
-#include <usb/request.h>
+#include <usb/dev/poll.h>
+#include <usb/dev/request.h>
 #include <usb/debug.h>
 #include <usb/classes/classes.h>
Index: uspace/lib/usbdev/src/dp.c
===================================================================
--- uspace/lib/usbdev/src/dp.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbdev/src/dp.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbdev
  * @{
  */
@@ -46,5 +46,5 @@
 #include <assert.h>
 #include <bool.h>
-#include <usb/dp.h>
+#include <usb/dev/dp.h>
 #include <usb/descriptor.h>
 
Index: uspace/lib/usbdev/src/hub.c
===================================================================
--- uspace/lib/usbdev/src/hub.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbdev/src/hub.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbdev
  * @{
  */
@@ -33,8 +33,8 @@
  * Functions needed by hub drivers.
  */
-#include <usb/hub.h>
-#include <usb/pipes.h>
-#include <usb/request.h>
-#include <usb/recognise.h>
+#include <usb/dev/hub.h>
+#include <usb/dev/pipes.h>
+#include <usb/dev/request.h>
+#include <usb/dev/recognise.h>
 #include <usbhc_iface.h>
 #include <errno.h>
Index: uspace/lib/usbdev/src/pipepriv.c
===================================================================
--- uspace/lib/usbdev/src/pipepriv.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbdev/src/pipepriv.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbdev
  * @{
  */
Index: uspace/lib/usbdev/src/pipepriv.h
===================================================================
--- uspace/lib/usbdev/src/pipepriv.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbdev/src/pipepriv.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbdev
  * @{
  */
@@ -33,8 +33,8 @@
  * Library internal functions on USB pipes.
  */
-#ifndef LIBUSB_PIPEPRIV_H_
-#define LIBUSB_PIPEPRIV_H_
+#ifndef LIBUSBDEV_PIPEPRIV_H_
+#define LIBUSBDEV_PIPEPRIV_H_
 
-#include <usb/pipes.h>
+#include <usb/dev/pipes.h>
 #include <bool.h>
 
Index: uspace/lib/usbdev/src/pipes.c
===================================================================
--- uspace/lib/usbdev/src/pipes.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbdev/src/pipes.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbdev
  * @{
  */
@@ -34,5 +34,5 @@
  */
 #include <usb/usb.h>
-#include <usb/pipes.h>
+#include <usb/dev/pipes.h>
 #include <usb/debug.h>
 #include <usb/driver.h>
Index: uspace/lib/usbdev/src/pipesinit.c
===================================================================
--- uspace/lib/usbdev/src/pipesinit.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbdev/src/pipesinit.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbdev
  * @{
  */
@@ -35,7 +35,7 @@
  */
 #include <usb/usb.h>
-#include <usb/pipes.h>
-#include <usb/dp.h>
-#include <usb/request.h>
+#include <usb/dev/pipes.h>
+#include <usb/dev/dp.h>
+#include <usb/dev/request.h>
 #include <usbhc_iface.h>
 #include <errno.h>
Index: uspace/lib/usbdev/src/pipesio.c
===================================================================
--- uspace/lib/usbdev/src/pipesio.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbdev/src/pipesio.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbdev
  * @{
  */
@@ -45,9 +45,9 @@
  */
 #include <usb/usb.h>
-#include <usb/pipes.h>
+#include <usb/dev/pipes.h>
 #include <errno.h>
 #include <assert.h>
 #include <usbhc_iface.h>
-#include <usb/request.h>
+#include <usb/dev/request.h>
 #include "pipepriv.h"
 
Index: uspace/lib/usbdev/src/recognise.c
===================================================================
--- uspace/lib/usbdev/src/recognise.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbdev/src/recognise.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbdev
  * @{
  */
@@ -35,8 +35,8 @@
 #include <sys/types.h>
 #include <fibril_synch.h>
-#include <usb/pipes.h>
-#include <usb/recognise.h>
+#include <usb/dev/pipes.h>
+#include <usb/dev/recognise.h>
 #include <usb/ddfiface.h>
-#include <usb/request.h>
+#include <usb/dev/request.h>
 #include <usb/classes/classes.h>
 #include <stdio.h>
Index: uspace/lib/usbdev/src/request.c
===================================================================
--- uspace/lib/usbdev/src/request.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbdev/src/request.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbdev
  * @{
  */
@@ -33,5 +33,5 @@
  * Standard USB requests (implementation).
  */
-#include <usb/request.h>
+#include <usb/dev/request.h>
 #include <errno.h>
 #include <assert.h>
Index: uspace/lib/usbdev/src/usbdevice.c
===================================================================
--- uspace/lib/usbdev/src/usbdevice.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbdev/src/usbdevice.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbdev
  * @{
  */
@@ -36,5 +36,5 @@
 #include <async.h>
 #include <usb_iface.h>
-#include <usb/usbdevice.h>
+#include <usb/dev/hc.h>
 #include <usb/driver.h>
 #include <usb/debug.h>
Index: pace/lib/usbhid/include/usb/classes/hid.h
===================================================================
--- uspace/lib/usbhid/include/usb/classes/hid.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,75 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * @brief USB HID device related types.
- */
-#ifndef LIBUSB_HID_H_
-#define LIBUSB_HID_H_
-
-#include <usb/usb.h>
-#include <usb/classes/hidparser.h>
-#include <usb/descriptor.h>
-
-/** USB/HID device requests. */
-typedef enum {
-	USB_HIDREQ_GET_REPORT = 1,
-	USB_HIDREQ_GET_IDLE = 2,
-	USB_HIDREQ_GET_PROTOCOL = 3,
-	/* Values 4 to 8 are reserved. */
-	USB_HIDREQ_SET_REPORT = 9,
-	USB_HIDREQ_SET_IDLE = 10,
-	USB_HIDREQ_SET_PROTOCOL = 11
-} usb_hid_request_t;
-
-typedef enum {
-	USB_HID_PROTOCOL_BOOT = 0,
-	USB_HID_PROTOCOL_REPORT = 1
-} usb_hid_protocol_t;
-
-/** USB/HID subclass constants. */
-typedef enum {
-	USB_HID_SUBCLASS_NONE = 0,
-	USB_HID_SUBCLASS_BOOT = 1
-} usb_hid_subclass_t;
-
-/** USB/HID interface protocols. */
-typedef enum {
-	USB_HID_PROTOCOL_NONE = 0,
-	USB_HID_PROTOCOL_KEYBOARD = 1,
-	USB_HID_PROTOCOL_MOUSE = 2
-} usb_hid_iface_protocol_t;
-
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usbhid/include/usb/classes/hid/iface.h
===================================================================
--- uspace/lib/usbhid/include/usb/classes/hid/iface.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,47 +1,0 @@
-/*
- * Copyright (c) 2011 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * Client functions for accessing USB HID interface.
- */
-#ifndef LIBUSB_CLASSES_HID_IFACE_H_
-#define LIBUSB_CLASSES_HID_IFACE_H_
-
-#include <sys/types.h>
-
-int usbhid_dev_get_event_length(int);
-int usbhid_dev_get_event(int, uint16_t *, uint16_t *, size_t, size_t *,
-    unsigned int);
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usbhid/include/usb/classes/hid/utled.h
===================================================================
--- uspace/lib/usbhid/include/usb/classes/hid/utled.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,122 +1,0 @@
-/*
- * Copyright (c) 2010 Lubos Slovak
- * 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 libusb
- * @{
- */
-/** @file
- * @brief USB HID Usage Tables - LED page.
- */
-#ifndef LIBUSB_UTLED_H_
-#define LIBUSB_UTLED_H_
-
-typedef enum {
-	USB_HID_LED_UNDEFINED = 0,
-	USB_HID_LED_NUM_LOCK,
-	USB_HID_LED_CAPS_LOCK,
-	USB_HID_LED_SCROLL_LOCK,
-	USB_HID_LED_COMPOSE,
-	USB_HID_LED_KANA,
-	USB_HID_LED_POWER,
-	USB_HID_LED_SHIFT,
-	USB_HID_LED_DND,
-	USB_HID_LED_MUTE,
-	USB_HID_LED_TONE_ENABLE,
-	USB_HID_LED_HIGH_CUT_FILTER,
-	USB_HID_LED_LOW_CUT_FILTER,
-	USB_HID_LED_EQ_ENABLE,
-	USB_HID_LED_SOUND_FIELD_ON,
-	USB_HID_LED_SURROUND_ON,
-	USB_HID_LED_REPEAT,
-	USB_HID_LED_STEREO,
-	USB_HID_LED_SAMPLING_RATE_DETECT,
-	USB_HID_LED_SPINNING,
-	USB_HID_LED_CAV,
-	USB_HID_LED_CLV,
-	USB_HID_LED_RECORDING_FORMAT_DETECT,
-	USB_HID_LED_OFF_HOOK,
-	USB_HID_LED_RING,
-	USB_HID_LED_MESSAGE_WAITING,
-	USB_HID_LED_DATA_MODE,
-	USB_HID_LED_BATTERY_OPERATION,
-	USB_HID_LED_BATTERY_OK,
-	USB_HID_LED_BATTERY_LOW,
-	USB_HID_LED_SPEAKER,
-	USB_HID_LED_HEAD_SET,
-	USB_HID_LED_HOLD,
-	USB_HID_LED_MICRO,
-	USB_HID_LED_COVERAGE,
-	USB_HID_LED_NIGHT_MODE,
-	USB_HID_LED_SEND_CALLS,
-	USB_HID_LED_CALL_PICKUP,
-	USB_HID_LED_CONFERENCE,
-	USB_HID_LED_STAND_BY,
-	USB_HID_LED_CAMERA_ON,
-	USB_HID_LED_CAMERA_OFF,
-	USB_HID_LED_ON_LINE,
-	USB_HID_LED_OFF_LINE,
-	USB_HID_LED_BUSY,
-	USB_HID_LED_READY,
-	USB_HID_LED_PAPER_OUT,
-	USB_HID_LED_PAPER_JAM,
-	USB_HID_LED_REMOTE,
-	USB_HID_LED_FORWARD,
-	USB_HID_LED_REVERSE,
-	USB_HID_LED_STOP,
-	USB_HID_LED_REWIND,
-	USB_HID_LED_FAST_FORWARD,
-	USB_HID_LED_PLAY,
-	USB_HID_LED_PAUSE,
-	USB_HID_LED_RECORD,
-	USB_HID_LED_ERROR,
-	USB_HID_LED_USAGE_SELECTED_IND,
-	USB_HID_LED_USAGE_IN_USE_IND,
-	USB_HID_LED_USAGE_MULTI_MODE_IND,
-	USB_HID_LED_IND_ON,
-	USB_HID_LED_IND_FLASH,
-	USB_HID_LED_IND_SLOW_BLINK,
-	USB_HID_LED_IND_FAST_BLINK,
-	USB_HID_LED_IND_OFF,
-	USB_HID_LED_FLASH_ON_TIME,
-	USB_HID_LED_SLOW_BLINK_ON_TIME,
-	USB_HID_LED_SLOW_BLINK_OFF_TIME,
-	USB_HID_LED_FAST_BLINK_ON_TIME,
-	USB_HID_LED_FAST_BLINK_OFF_TIME,
-	USB_HID_LED_USAGE_IND_COLOR,
-	USB_HID_LED_IND_RED,
-	USB_HID_LED_IND_GREEN,
-	USB_HID_LED_IND_AMBER,
-	USB_HID_LED_GENERIC_IND,
-	USB_HID_LED_SYSTEM_SUSPEND,
-	USB_HID_LED_EXTERNAL_POWER
-} usb_hid_usage_led_t;
-
-#endif /* LIBUSB_UTLED_H_ */
-/**
- * @}
- */
Index: pace/lib/usbhid/include/usb/classes/hid_report_items.h
===================================================================
--- uspace/lib/usbhid/include/usb/classes/hid_report_items.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,106 +1,0 @@
-/*
- * Copyright (c) 2011 Matej Klonfar
- * 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 libusb
- * @{
- */
-/** @file
- * @brief USB HID parser.
- */
-#ifndef LIBUSB_HID_REPORT_ITEMS_H_
-#define LIBUSB_HID_REPORT_ITEMS_H_
-
-#include <stdint.h>
-
-/**
- * Item prefix
- */
-#define USB_HID_ITEM_SIZE(data) 	((uint8_t)(data & 0x3))
-#define USB_HID_ITEM_TAG(data) 		((uint8_t)((data & 0xF0) >> 4))
-#define USB_HID_ITEM_TAG_CLASS(data)	((uint8_t)((data & 0xC) >> 2))
-#define USB_HID_ITEM_IS_LONG(data)	(data == 0xFE)
-
-
-/**
- * Input/Output/Feature Item flags
- */
-/** Constant (1) / Variable (0) */
-#define USB_HID_ITEM_FLAG_CONSTANT(flags) 	((flags & 0x1) == 0x1)
-/** Variable (1) / Array (0) */
-#define USB_HID_ITEM_FLAG_VARIABLE(flags) 	((flags & 0x2) == 0x2)
-/** Absolute / Relative*/
-#define USB_HID_ITEM_FLAG_RELATIVE(flags) 	((flags & 0x4) == 0x4)
-/** Wrap / No Wrap */
-#define USB_HID_ITEM_FLAG_WRAP(flags)		((flags & 0x8) == 0x8)
-#define USB_HID_ITEM_FLAG_LINEAR(flags)		((flags & 0x10) == 0x10)
-#define USB_HID_ITEM_FLAG_PREFERRED(flags)	((flags & 0x20) == 0x20)
-#define USB_HID_ITEM_FLAG_POSITION(flags)	((flags & 0x40) == 0x40)
-#define USB_HID_ITEM_FLAG_VOLATILE(flags)	((flags & 0x80) == 0x80)
-#define USB_HID_ITEM_FLAG_BUFFERED(flags)	((flags & 0x100) == 0x100)
-
-/* MAIN ITEMS */
-#define USB_HID_TAG_CLASS_MAIN				0x0
-#define USB_HID_REPORT_TAG_INPUT			0x8
-#define USB_HID_REPORT_TAG_OUTPUT			0x9
-#define USB_HID_REPORT_TAG_FEATURE			0xB
-#define USB_HID_REPORT_TAG_COLLECTION		0xA
-#define USB_HID_REPORT_TAG_END_COLLECTION	0xC
-
-/* GLOBAL ITEMS */
-#define USB_HID_TAG_CLASS_GLOBAL			0x1
-#define USB_HID_REPORT_TAG_USAGE_PAGE		0x0
-#define USB_HID_REPORT_TAG_LOGICAL_MINIMUM	0x1
-#define USB_HID_REPORT_TAG_LOGICAL_MAXIMUM	0x2
-#define USB_HID_REPORT_TAG_PHYSICAL_MINIMUM 0x3
-#define USB_HID_REPORT_TAG_PHYSICAL_MAXIMUM 0x4
-#define USB_HID_REPORT_TAG_UNIT_EXPONENT	0x5
-#define USB_HID_REPORT_TAG_UNIT				0x6
-#define USB_HID_REPORT_TAG_REPORT_SIZE		0x7
-#define USB_HID_REPORT_TAG_REPORT_ID		0x8
-#define USB_HID_REPORT_TAG_REPORT_COUNT		0x9
-#define USB_HID_REPORT_TAG_PUSH				0xA
-#define USB_HID_REPORT_TAG_POP				0xB
-
-
-/* LOCAL ITEMS */
-#define USB_HID_TAG_CLASS_LOCAL					0x2
-#define USB_HID_REPORT_TAG_USAGE				0x0
-#define USB_HID_REPORT_TAG_USAGE_MINIMUM		0x1
-#define USB_HID_REPORT_TAG_USAGE_MAXIMUM		0x2
-#define USB_HID_REPORT_TAG_DESIGNATOR_INDEX		0x3
-#define USB_HID_REPORT_TAG_DESIGNATOR_MINIMUM	0x4
-#define USB_HID_REPORT_TAG_DESIGNATOR_MAXIMUM	0x5
-#define USB_HID_REPORT_TAG_STRING_INDEX			0x7
-#define USB_HID_REPORT_TAG_STRING_MINIMUM		0x8
-#define USB_HID_REPORT_TAG_STRING_MAXIMUM		0x9
-#define USB_HID_REPORT_TAG_DELIMITER			0xA
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usbhid/include/usb/classes/hiddescriptor.h
===================================================================
--- uspace/lib/usbhid/include/usb/classes/hiddescriptor.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,84 +1,0 @@
-/*
- * Copyright (c) 2011 Matej Klonfar
- * 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 libusb
- * @{
- */
-/** @file
- * USB HID report descriptor and report data parser
- */
-#ifndef LIBUSB_HIDDESCRIPTOR_H_
-#define LIBUSB_HIDDESCRIPTOR_H_
-
-#include <stdint.h>
-#include <adt/list.h>
-#include <usb/classes/hid_report_items.h>
-#include <usb/classes/hidpath.h>
-#include <usb/classes/hidtypes.h>
-
-
-/*
- * Descriptor parser functions
- */
-
-/** */
-int usb_hid_parse_report_descriptor(usb_hid_report_t *report, 
-                                    const uint8_t *data, size_t size);
-
-/** */
-void usb_hid_free_report(usb_hid_report_t *report);
-
-/** */
-void usb_hid_descriptor_print(usb_hid_report_t *report);
-
-
-int usb_hid_report_init(usb_hid_report_t *report);
-int usb_hid_report_append_fields(usb_hid_report_t *report, 
-                                 usb_hid_report_item_t *report_item);
-
-usb_hid_report_description_t * usb_hid_report_find_description(const usb_hid_report_t *report, uint8_t report_id, usb_hid_report_type_t type);
-int usb_hid_report_parse_tag(uint8_t tag, uint8_t class, const uint8_t *data, size_t item_size,
-                             usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
-int usb_hid_report_parse_main_tag(uint8_t tag, const uint8_t *data, size_t item_size,
-                             usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
-int usb_hid_report_parse_global_tag(uint8_t tag, const uint8_t *data, size_t item_size,
-                             usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
-int usb_hid_report_parse_local_tag(uint8_t tag, const uint8_t *data, size_t item_size,
-                             usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
-
-void usb_hid_descriptor_print_list(link_t *head);
-void usb_hid_report_reset_local_items(usb_hid_report_item_t *report_item);
-void usb_hid_free_report_list(link_t *head);
-usb_hid_report_item_t *usb_hid_report_item_clone(const usb_hid_report_item_t *item);
-uint32_t usb_hid_report_tag_data_uint32(const uint8_t *data, size_t size);
-
-usb_hid_report_path_t *usb_hid_report_path_try_insert(usb_hid_report_t *report, usb_hid_report_path_t *cmp_path);
-#endif
-/**
- * @}
- */
Index: pace/lib/usbhid/include/usb/classes/hidparser.h
===================================================================
--- uspace/lib/usbhid/include/usb/classes/hidparser.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,90 +1,0 @@
-/*
- * Copyright (c) 2011 Matej Klonfar
- * 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 libusb
- * @{
- */
-/** @file
- * USB HID report descriptor and report data parser
- */
-#ifndef LIBUSB_HIDPARSER_H_
-#define LIBUSB_HIDPARSER_H_
-
-#include <stdint.h>
-#include <adt/list.h>
-#include <usb/classes/hid_report_items.h>
-#include <usb/classes/hidpath.h>
-#include <usb/classes/hidtypes.h>
-#include <usb/classes/hiddescriptor.h>
-
-
-/*
- * Input report parser functions
- */
-/** */
-int usb_hid_parse_report(const usb_hid_report_t *report, const uint8_t *data, 
-                         size_t size, uint8_t *report_id);
-
-/** */
-size_t usb_hid_report_input_length(const usb_hid_report_t *report,
-	usb_hid_report_path_t *path, int flags);
-
-/*
- * Output report parser functions
- */
-/** Allocates output report buffer*/
-uint8_t *usb_hid_report_output(usb_hid_report_t *report, size_t *size, 
-                               uint8_t report_id);
-
-/** Frees output report buffer*/
-void usb_hid_report_output_free(uint8_t *output);
-
-/** Returns size of output for given usage path */
-size_t usb_hid_report_output_size(usb_hid_report_t *report,
-                                  usb_hid_report_path_t *path, int flags);
-
-/** Makes the output report buffer by translated given data */
-int usb_hid_report_output_translate(usb_hid_report_t *report, uint8_t report_id, 
-                                    uint8_t *buffer, size_t size);
-
-/** */
-usb_hid_report_field_t *usb_hid_report_get_sibling(usb_hid_report_t *report, 
-                                                   usb_hid_report_field_t *field, 
-                                                   usb_hid_report_path_t *path, 
-                                                   int flags, 
-                                                   usb_hid_report_type_t type);
-
-/** */
-uint8_t usb_hid_report_get_report_id(usb_hid_report_t *report, 
-                                     uint8_t report_id, 
-                                     usb_hid_report_type_t type);
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usbhid/include/usb/classes/hidpath.h
===================================================================
--- uspace/lib/usbhid/include/usb/classes/hidpath.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,118 +1,0 @@
-/*
- * Copyright (c) 2011 Matej Klonfar
- * 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 libusb
- * @{
- */
-/** @file
- * USB HID report descriptor and report data parser
- */
-#ifndef LIBUSB_HIDPATH_H_
-#define LIBUSB_HIDPATH_H_
-
-#include <usb/classes/hidparser.h>
-#include <stdint.h>
-#include <adt/list.h>
-
-/**
- * Description of path of usage pages and usages in report descriptor
- */
-/** Wanted usage path must be exactly the same as the searched one */
-#define USB_HID_PATH_COMPARE_STRICT		0
-/** Wanted usage path must be the suffix in the searched one */
-#define USB_HID_PATH_COMPARE_END		1
-/** */
-#define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY	2
-/** Searched usage page must be prefix of the other one */
-#define USB_HID_PATH_COMPARE_BEGIN		4
-/** Searched couple of usage page and usage can be anywhere in usage path */
-#define USB_HID_PATH_COMPARE_ANYWHERE		8
-
-
-/** Collection usage path structure */
-typedef struct {
-	/** */
-	uint32_t usage_page;
-	/** */	
-	uint32_t usage;
-
-	uint8_t flags;
-	/** */
-	link_t link;
-} usb_hid_report_usage_path_t;
-
-/** */
-typedef struct {
-	/** */	
-	int depth;	
-	uint8_t report_id;
-	
-	/** */	
-	link_t link; /* list */
-
-	link_t head; /* head of list of usage paths */
-
-} usb_hid_report_path_t;
-
-/** */
-usb_hid_report_path_t *usb_hid_report_path(void);
-
-/** */
-void usb_hid_report_path_free(usb_hid_report_path_t *path);
-
-/** */
-int usb_hid_report_path_set_report_id(usb_hid_report_path_t *usage_path, 
-                                      uint8_t report_id);
-
-/** */
-int usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, 
-                                    int32_t usage_page, int32_t usage);
-
-/** */
-void usb_hid_report_remove_last_item(usb_hid_report_path_t *usage_path);
-
-/** */
-void usb_hid_report_null_last_item(usb_hid_report_path_t *usage_path);
-
-/** */
-void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path, 
-                                  int32_t tag, int32_t data);
-
-/** */
-int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path, 
-                                      usb_hid_report_path_t *path, int flags);
-
-/** */
-usb_hid_report_path_t *usb_hid_report_path_clone(usb_hid_report_path_t *usage_path);
-
-void usb_hid_print_usage_path(usb_hid_report_path_t *path);
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usbhid/include/usb/classes/hidreport.h
===================================================================
--- uspace/lib/usbhid/include/usb/classes/hidreport.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,65 +1,0 @@
-/*
- * Copyright (c) 2011 Lubos Slovak
- * 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 libusb
- * @{
- */
-/** @file
- * USB HID report parser initialization from descriptors.
- */
-
-#ifndef LIBUSB_HIDREPORT_H_
-#define LIBUSB_HIDREPORT_H_
-
-#include <usb/devdrv.h>
-#include <usb/classes/hidparser.h>
-
-/**
- * Retrieves the Report descriptor from the USB device and initializes the
- * report parser.
- *
- * \param dev USB device representing a HID device.
- * \param parser HID Report parser.
- *
- * \retval EOK if successful.
- * \retval EINVAL if one of the parameters is not given (is NULL).
- * \retval ENOENT if there are some descriptors missing.
- * \retval ENOMEM if an error with allocation occured.
- * \retval EINVAL if the Report descriptor's size does not match the size 
- *         from the interface descriptor.
- * \return Other value inherited from function usb_pipe_start_session(),
- *         usb_pipe_end_session() or usb_request_get_descriptor().
- */
-int usb_hid_process_report_descriptor(usb_device_t *dev, 
-    usb_hid_report_t *report);
-
-#endif /* LIBUSB_HIDREPORT_H_ */
-
-/**
- * @}
- */
Index: pace/lib/usbhid/include/usb/classes/hidreq.h
===================================================================
--- uspace/lib/usbhid/include/usb/classes/hidreq.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,69 +1,0 @@
-/*
- * Copyright (c) 2011 Lubos Slovak
- * 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 libusb
- * @{
- */
-/** @file
- * HID class-specific requests.
- */
-
-#ifndef USB_KBD_HIDREQ_H_
-#define USB_KBD_HIDREQ_H_
-
-#include <stdint.h>
-
-#include <usb/classes/hid.h>
-#include <usb/pipes.h>
-
-/*----------------------------------------------------------------------------*/
-
-int usbhid_req_set_report(usb_pipe_t *ctrl_pipe, int iface_no,
-    usb_hid_report_type_t type, uint8_t *buffer, size_t buf_size);
-
-int usbhid_req_set_protocol(usb_pipe_t *ctrl_pipe, int iface_no, 
-    usb_hid_protocol_t protocol);
-
-int usbhid_req_set_idle(usb_pipe_t *ctrl_pipe, int iface_no, uint8_t duration);
-
-int usbhid_req_get_report(usb_pipe_t *ctrl_pipe, int iface_no, 
-    usb_hid_report_type_t type, uint8_t *buffer, size_t buf_size, 
-    size_t *actual_size);
-
-int usbhid_req_get_protocol(usb_pipe_t *ctrl_pipe, int iface_no, 
-    usb_hid_protocol_t *protocol);
-
-int usbhid_req_get_idle(usb_pipe_t *ctrl_pipe, int iface_no, uint8_t *duration);
-
-/*----------------------------------------------------------------------------*/
-
-#endif /* USB_KBD_HIDREQ_H_ */
-
-/**
- * @}
- */
Index: pace/lib/usbhid/include/usb/classes/hidtypes.h
===================================================================
--- uspace/lib/usbhid/include/usb/classes/hidtypes.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,210 +1,0 @@
-/*
- * Copyright (c) 2011 Matej Klonfar
- * 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 libusb
- * @{
- */
-/** @file
- * USB HID report descriptor and report data parser
- */
-#ifndef LIBUSB_HIDTYPES_H_
-#define LIBUSB_HIDTYPES_H_
-
-#include <stdint.h>
-#include <adt/list.h>
-
-#define USB_HID_MAX_USAGES	20
-
-#define USB_HID_UINT32_TO_INT32(x, size)	((((x) & (1 << ((size) - 1))) != 0) ? -(~(x - 1) & ((1 << size) - 1)) : (x)) //(-(~((x) - 1)))
-#define USB_HID_INT32_TO_UINT32(x, size)	(((x) < 0 ) ? ((1 << (size)) + (x)) : (x))
-
-
-typedef enum {
-	USB_HID_REPORT_TYPE_INPUT = 1,
-	USB_HID_REPORT_TYPE_OUTPUT = 2,
-	USB_HID_REPORT_TYPE_FEATURE = 3
-} usb_hid_report_type_t;
-
-
-typedef struct {
-	/** */
-	int report_count;
-	link_t reports;		/** list of usb_hid_report_description_t */
-
-	link_t collection_paths;
-	int collection_paths_count;
-
-	int use_report_ids;
-	uint8_t last_report_id;
-	
-} usb_hid_report_t;
-
-typedef struct {
-	uint8_t report_id;
-	usb_hid_report_type_t type;
-
-	size_t bit_length;
-	size_t item_length;
-	
-	link_t report_items;	/** list of report items (fields) */
-
-	link_t link;
-} usb_hid_report_description_t;
-
-typedef struct {
-
-	int offset;
-	size_t size;
-
-	uint16_t usage_page;
-	uint16_t usage;
-
-	uint8_t item_flags;
-	usb_hid_report_path_t *collection_path;
-
-	int32_t logical_minimum;
-	int32_t logical_maximum;
-	int32_t physical_minimum;
-	int32_t physical_maximum;
-	uint32_t usage_minimum;
-	uint32_t usage_maximum;
-	uint32_t unit;
-	uint32_t unit_exponent;
-	
-
-	int32_t value;
-
-	link_t link;
-} usb_hid_report_field_t;
-
-
-
-/**
- * state table
- */
-typedef struct {
-	/** report id */	
-	int32_t id;
-	
-	/** */
-	uint16_t extended_usage_page;
-	uint32_t usages[USB_HID_MAX_USAGES];
-	int usages_count;
-
-	/** */
-	uint32_t usage_page;
-
-	/** */	
-	uint32_t usage_minimum;
-	/** */	
-	uint32_t usage_maximum;
-	/** */	
-	int32_t logical_minimum;
-	/** */	
-	int32_t logical_maximum;
-	/** */	
-	int32_t size;
-	/** */	
-	int32_t count;
-	/** */	
-	size_t offset;
-	/** */	
-	int32_t unit_exponent;
-	/** */	
-	int32_t unit;
-
-	/** */
-	uint32_t string_index;
-	/** */	
-	uint32_t string_minimum;
-	/** */	
-	uint32_t string_maximum;
-	/** */	
-	uint32_t designator_index;
-	/** */	
-	uint32_t designator_minimum;
-	/** */	
-	uint32_t designator_maximum;
-	/** */	
-	int32_t physical_minimum;
-	/** */	
-	int32_t physical_maximum;
-
-	/** */	
-	uint8_t item_flags;
-
-	usb_hid_report_type_t type;
-
-	/** current collection path*/	
-	usb_hid_report_path_t *usage_path;
-	/** */	
-	link_t link;
-
-	int in_delimiter;
-} usb_hid_report_item_t;
-
-/** HID parser callbacks for IN items. */
-typedef struct {
-	/** Callback for keyboard.
-	 *
-	 * @param key_codes Array of pressed key (including modifiers).
-	 * @param count Length of @p key_codes.
-	 * @param arg Custom argument.
-	 */
-	void (*keyboard)(const uint8_t *key_codes, size_t count, const uint8_t report_id, void *arg);
-} usb_hid_report_in_callbacks_t;
-
-
-typedef enum {
-	USB_HID_MOD_LCTRL = 0x01,
-	USB_HID_MOD_LSHIFT = 0x02,
-	USB_HID_MOD_LALT = 0x04,
-	USB_HID_MOD_LGUI = 0x08,
-	USB_HID_MOD_RCTRL = 0x10,
-	USB_HID_MOD_RSHIFT = 0x20,
-	USB_HID_MOD_RALT = 0x40,
-	USB_HID_MOD_RGUI = 0x80,
-	USB_HID_MOD_COUNT = 8
-} usb_hid_modifiers_t;
-
-static const usb_hid_modifiers_t 
-    usb_hid_modifiers_consts[USB_HID_MOD_COUNT] = {
-	USB_HID_MOD_LCTRL,
-	USB_HID_MOD_LSHIFT,
-	USB_HID_MOD_LALT,
-	USB_HID_MOD_LGUI,
-	USB_HID_MOD_RCTRL,
-	USB_HID_MOD_RSHIFT,
-	USB_HID_MOD_RALT,
-	USB_HID_MOD_RGUI
-};
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usbhid/include/usb/classes/hidut.h
===================================================================
--- uspace/lib/usbhid/include/usb/classes/hidut.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,73 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * @brief USB HID Usage Tables.
- */
-#ifndef LIBUSB_HIDUT_H_
-#define LIBUSB_HIDUT_H_
-
-/** USB/HID Usage Pages. */
-typedef enum {
-	USB_HIDUT_PAGE_GENERIC_DESKTOP = 1,
-	USB_HIDUT_PAGE_SIMULATION = 2,
-	USB_HIDUT_PAGE_VR = 3,
-	USB_HIDUT_PAGE_SPORT = 4,
-	USB_HIDUT_PAGE_GAME = 5,
-	USB_HIDUT_PAGE_GENERIC_DEVICE = 6,
-	USB_HIDUT_PAGE_KEYBOARD = 7,
-	USB_HIDUT_PAGE_LED = 8,
-	USB_HIDUT_PAGE_BUTTON = 9,
-	USB_HIDUT_PAGE_ORDINAL = 0x0a,
-	USB_HIDUT_PAGE_TELEPHONY_DEVICE = 0x0b,
-	USB_HIDUT_PAGE_CONSUMER = 0x0c
-} usb_hidut_usage_page_t;
-
-/** Usages for Generic Desktop Page. */
-typedef enum {
-	USB_HIDUT_USAGE_GENERIC_DESKTOP_POINTER = 1,
-	USB_HIDUT_USAGE_GENERIC_DESKTOP_MOUSE = 2,
-	USB_HIDUT_USAGE_GENERIC_DESKTOP_JOYSTICK = 4,
-	USB_HIDUT_USAGE_GENERIC_DESKTOP_GAMEPAD = 5,
-	USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYBOARD = 6,
-	USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYPAD = 7,
-	USB_HIDUT_USAGE_GENERIC_DESKTOP_X = 0x30,
-	USB_HIDUT_USAGE_GENERIC_DESKTOP_Y = 0x31,
-	USB_HIDUT_USAGE_GENERIC_DESKTOP_WHEEL = 0x38
-	/* USB_HIDUT_USAGE_GENERIC_DESKTOP_ = , */
-	
-} usb_hidut_usage_generic_desktop_t;
-
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usbhid/include/usb/classes/hidutkbd.h
===================================================================
--- uspace/lib/usbhid/include/usb/classes/hidutkbd.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,175 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * @brief USB HID key codes.
- * @details
- * This is not a typical header as by default it is equal to empty file.
- * However, by cleverly defining the USB_HIDUT_KBD_KEY you can use it
- * to generate conversion tables etc.
- *
- * For example, this creates enum for known keys:
- * @code
-#define USB_HIDUT_KBD_KEY(name, usage_id, l, lc, l1, l2) \
-	USB_KBD_KEY_##name = usage_id,
-typedef enum {
-	#include <usb/hidutkbd.h>
-} usb_key_code_t;
- @endcode
- *
- * Maybe, it might be better that you would place such enums into separate
- * files and create them as separate step before compiling to allow tools
- * such as Doxygen get the definitions right.
- *
- * @warning This file does not include guard to prevent multiple inclusions
- * into a single file.
- */
-
-
-#ifndef USB_HIDUT_KBD_KEY
-/** Declare keyboard key.
- * @param name Key name (identifier).
- * @param usage_id Key code (see Keyboard/Keypad Page (0x07) in HUT1.12.
- * @param letter Corresponding character (0 if not applicable).
- * @param letter_caps Corresponding character with Caps on.
- * @param letter_mod1 Corresponding character with modifier #1 on.
- * @param letter_mod2 Corresponding character with modifier #2 on.
- */
-#define USB_HIDUT_KBD_KEY(name, usage_id, letter, letter_caps, letter_mod1, letter_mod2)
-
-#endif
-
-#define __NONPRINT(name, usage_id) \
-	USB_HIDUT_KBD_KEY(name, usage_id, 0, 0, 0, 0)
-
-/* US alphabet letters */
-USB_HIDUT_KBD_KEY(A, 0x04, 'a', 'A', 0, 0)
-USB_HIDUT_KBD_KEY(B, 0x05, 'b', 'B', 0, 0)
-USB_HIDUT_KBD_KEY(C, 0x06, 'c', 'C', 0, 0)
-USB_HIDUT_KBD_KEY(D, 0x07, 'd', 'D', 0, 0)
-USB_HIDUT_KBD_KEY(E, 0x08, 'e', 'E', 0, 0)
-USB_HIDUT_KBD_KEY(F, 0x09, 'f', 'F', 0, 0)
-USB_HIDUT_KBD_KEY(G, 0x0A, 'g', 'G', 0, 0)
-USB_HIDUT_KBD_KEY(H, 0x0B, 'h', 'H', 0, 0)
-USB_HIDUT_KBD_KEY(I, 0x0C, 'i', 'I', 0, 0)
-USB_HIDUT_KBD_KEY(J, 0x0D, 'j', 'J', 0, 0)
-USB_HIDUT_KBD_KEY(K, 0x0E, 'k', 'K', 0, 0)
-USB_HIDUT_KBD_KEY(L, 0x0F, 'l', 'L', 0, 0)
-USB_HIDUT_KBD_KEY(M, 0x10, 'm', 'M', 0, 0)
-USB_HIDUT_KBD_KEY(N, 0x11, 'n', 'N', 0, 0)
-USB_HIDUT_KBD_KEY(O, 0x12, 'o', 'O', 0, 0)
-USB_HIDUT_KBD_KEY(P, 0x13, 'p', 'P', 0, 0)
-USB_HIDUT_KBD_KEY(Q, 0x14, 'q', 'Q', 0, 0)
-USB_HIDUT_KBD_KEY(R, 0x15, 'r', 'R', 0, 0)
-USB_HIDUT_KBD_KEY(S, 0x16, 's', 'S', 0, 0)
-USB_HIDUT_KBD_KEY(T, 0x17, 't', 'T', 0, 0)
-USB_HIDUT_KBD_KEY(U, 0x18, 'u', 'U', 0, 0)
-USB_HIDUT_KBD_KEY(V, 0x19, 'v', 'V', 0, 0)
-USB_HIDUT_KBD_KEY(W, 0x1A, 'w', 'W', 0, 0)
-USB_HIDUT_KBD_KEY(X, 0x1B, 'x', 'X', 0, 0)
-USB_HIDUT_KBD_KEY(Y, 0x1C, 'y', 'Y', 0, 0)
-USB_HIDUT_KBD_KEY(Z, 0x1D, 'z', 'Z', 0, 0)
-
-/* Keyboard digits */
-USB_HIDUT_KBD_KEY(1, 0x1E, '1', '!', 0, 0)
-USB_HIDUT_KBD_KEY(2, 0x1F, '2', '@', 0, 0)
-USB_HIDUT_KBD_KEY(3, 0x20, '3', '#', 0, 0)
-USB_HIDUT_KBD_KEY(4, 0x21, '4', '$', 0, 0)
-USB_HIDUT_KBD_KEY(5, 0x22, '5', '%', 0, 0)
-USB_HIDUT_KBD_KEY(6, 0x23, '6', '^', 0, 0)
-USB_HIDUT_KBD_KEY(7, 0x24, '7', '&', 0, 0)
-USB_HIDUT_KBD_KEY(8, 0x25, '8', '*', 0, 0)
-USB_HIDUT_KBD_KEY(9, 0x26, '9', '(', 0, 0)
-USB_HIDUT_KBD_KEY(0, 0x27, '0', ')', 0, 0)
-
-/* More-or-less typewriter command keys */
-USB_HIDUT_KBD_KEY(ENTER, 0x28, '\n', 0, 0, 0)
-USB_HIDUT_KBD_KEY(ESCAPE, 0x29, 0, 0, 0, 0)
-USB_HIDUT_KBD_KEY(BACKSPACE, 0x2A, '\b', 0, 0, 0)
-USB_HIDUT_KBD_KEY(TAB, 0x2B, '\t', 0, 0, 0)
-USB_HIDUT_KBD_KEY(SPACE, 0x2C, ' ', 0, 0, 0)
-
-/* Special (printable) characters */
-USB_HIDUT_KBD_KEY(DASH, 0x2D, '-', '_', 0, 0)
-USB_HIDUT_KBD_KEY(EQUALS, 0x2E, '=', '+', 0, 0)
-USB_HIDUT_KBD_KEY(LEFT_BRACKET, 0x2F, '[', '{', 0, 0)
-USB_HIDUT_KBD_KEY(RIGHT_BRACKET, 0x30, ']', '}', 0, 0)
-USB_HIDUT_KBD_KEY(BACKSLASH, 0x31, '\\', '|', 0, 0)
-USB_HIDUT_KBD_KEY(HASH, 0x32, '#', '~', 0, 0)
-USB_HIDUT_KBD_KEY(SEMICOLON, 0x33, ';', ':', 0, 0)
-USB_HIDUT_KBD_KEY(APOSTROPHE, 0x34, '\'', '"', 0, 0)
-USB_HIDUT_KBD_KEY(GRAVE_ACCENT, 0x35, '`', '~', 0, 0)
-USB_HIDUT_KBD_KEY(COMMA, 0x36, ',', '<', 0, 0)
-USB_HIDUT_KBD_KEY(PERIOD, 0x37, '.', '>', 0, 0)
-USB_HIDUT_KBD_KEY(SLASH, 0x38, '/', '?', 0, 0)
-
-USB_HIDUT_KBD_KEY(CAPS_LOCK, 0x39, 0, 0, 0, 0)
-
-/* Function keys */
-__NONPRINT( F1, 0x3A)
-__NONPRINT( F2, 0x3B)
-__NONPRINT( F3, 0x3C)
-__NONPRINT( F4, 0x3D)
-__NONPRINT( F5, 0x3E)
-__NONPRINT( F6, 0x3F)
-__NONPRINT( F7, 0x40)
-__NONPRINT( F8, 0x41)
-__NONPRINT( F9, 0x42)
-__NONPRINT(F10, 0x43)
-__NONPRINT(F11, 0x44)
-__NONPRINT(F12, 0x45)
-
-/* Cursor movement keys & co. */
-__NONPRINT(PRINT_SCREEN, 0x46)
-__NONPRINT(SCROLL_LOCK, 0x47)
-__NONPRINT(PAUSE, 0x48)
-__NONPRINT(INSERT, 0x49)
-__NONPRINT(HOME, 0x4A)
-__NONPRINT(PAGE_UP, 0x4B)
-__NONPRINT(DELETE, 0x4C)
-__NONPRINT(END, 0x4D)
-__NONPRINT(PAGE_DOWN, 0x4E)
-__NONPRINT(RIGHT_ARROW, 0x4F)
-__NONPRINT(LEFT_ARROW, 0x50)
-__NONPRINT(DOWN_ARROW, 0x51)
-__NONPRINT(UP_ARROW, 0x52)
-
-
-
-
-/* USB_HIDUT_KBD_KEY(, 0x, '', '', 0, 0) */
-
-#undef __NONPRINT
-
-/**
- * @}
- */
-
Index: uspace/lib/usbhid/include/usb/hid/hid.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hid.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbhid/include/usb/hid/hid.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * 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 libusbhid
+ * @{
+ */
+/** @file
+ * @brief USB HID device related types.
+ */
+#ifndef LIBUSBHID_HID_H_
+#define LIBUSBHID_HID_H_
+
+#include <usb/usb.h>
+#include <usb/hid/hidparser.h>
+#include <usb/descriptor.h>
+
+/** USB/HID device requests. */
+typedef enum {
+	USB_HIDREQ_GET_REPORT = 1,
+	USB_HIDREQ_GET_IDLE = 2,
+	USB_HIDREQ_GET_PROTOCOL = 3,
+	/* Values 4 to 8 are reserved. */
+	USB_HIDREQ_SET_REPORT = 9,
+	USB_HIDREQ_SET_IDLE = 10,
+	USB_HIDREQ_SET_PROTOCOL = 11
+} usb_hid_request_t;
+
+typedef enum {
+	USB_HID_PROTOCOL_BOOT = 0,
+	USB_HID_PROTOCOL_REPORT = 1
+} usb_hid_protocol_t;
+
+/** USB/HID subclass constants. */
+typedef enum {
+	USB_HID_SUBCLASS_NONE = 0,
+	USB_HID_SUBCLASS_BOOT = 1
+} usb_hid_subclass_t;
+
+/** USB/HID interface protocols. */
+typedef enum {
+	USB_HID_PROTOCOL_NONE = 0,
+	USB_HID_PROTOCOL_KEYBOARD = 1,
+	USB_HID_PROTOCOL_MOUSE = 2
+} usb_hid_iface_protocol_t;
+
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usbhid/include/usb/hid/hid_report_items.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hid_report_items.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbhid/include/usb/hid/hid_report_items.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2011 Matej Klonfar
+ * 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 libusbhid
+ * @{
+ */
+/** @file
+ * @brief USB HID parser.
+ */
+#ifndef LIBUSBHID_HID_REPORT_ITEMS_H_
+#define LIBUSBHID_HID_REPORT_ITEMS_H_
+
+#include <stdint.h>
+
+/**
+ * Item prefix
+ */
+#define USB_HID_ITEM_SIZE(data) 	((uint8_t)(data & 0x3))
+#define USB_HID_ITEM_TAG(data) 		((uint8_t)((data & 0xF0) >> 4))
+#define USB_HID_ITEM_TAG_CLASS(data)	((uint8_t)((data & 0xC) >> 2))
+#define USB_HID_ITEM_IS_LONG(data)	(data == 0xFE)
+
+
+/**
+ * Extended usage macros
+ */
+#define USB_HID_IS_EXTENDED_USAGE(usage)	((usage & 0xFFFF0000) != 0)
+#define USB_HID_EXTENDED_USAGE_PAGE(usage)	((usage & 0xFFFF0000) >> 16)
+#define USB_HID_EXTENDED_USAGE(usage)		(usage & 0xFFFF)
+
+/**
+ * Input/Output/Feature Item flags
+ */
+/** Constant (1) / Variable (0) */
+#define USB_HID_ITEM_FLAG_CONSTANT(flags) 	((flags & 0x1) == 0x1)
+/** Variable (1) / Array (0) */
+#define USB_HID_ITEM_FLAG_VARIABLE(flags) 	((flags & 0x2) == 0x2)
+/** Absolute / Relative*/
+#define USB_HID_ITEM_FLAG_RELATIVE(flags) 	((flags & 0x4) == 0x4)
+/** Wrap / No Wrap */
+#define USB_HID_ITEM_FLAG_WRAP(flags)		((flags & 0x8) == 0x8)
+#define USB_HID_ITEM_FLAG_LINEAR(flags)		((flags & 0x10) == 0x10)
+#define USB_HID_ITEM_FLAG_PREFERRED(flags)	((flags & 0x20) == 0x20)
+#define USB_HID_ITEM_FLAG_POSITION(flags)	((flags & 0x40) == 0x40)
+#define USB_HID_ITEM_FLAG_VOLATILE(flags)	((flags & 0x80) == 0x80)
+#define USB_HID_ITEM_FLAG_BUFFERED(flags)	((flags & 0x100) == 0x100)
+
+/* MAIN ITEMS */
+#define USB_HID_TAG_CLASS_MAIN				0x0
+#define USB_HID_REPORT_TAG_INPUT			0x8
+#define USB_HID_REPORT_TAG_OUTPUT			0x9
+#define USB_HID_REPORT_TAG_FEATURE			0xB
+#define USB_HID_REPORT_TAG_COLLECTION		0xA
+#define USB_HID_REPORT_TAG_END_COLLECTION	0xC
+
+/* GLOBAL ITEMS */
+#define USB_HID_TAG_CLASS_GLOBAL			0x1
+#define USB_HID_REPORT_TAG_USAGE_PAGE		0x0
+#define USB_HID_REPORT_TAG_LOGICAL_MINIMUM	0x1
+#define USB_HID_REPORT_TAG_LOGICAL_MAXIMUM	0x2
+#define USB_HID_REPORT_TAG_PHYSICAL_MINIMUM 0x3
+#define USB_HID_REPORT_TAG_PHYSICAL_MAXIMUM 0x4
+#define USB_HID_REPORT_TAG_UNIT_EXPONENT	0x5
+#define USB_HID_REPORT_TAG_UNIT				0x6
+#define USB_HID_REPORT_TAG_REPORT_SIZE		0x7
+#define USB_HID_REPORT_TAG_REPORT_ID		0x8
+#define USB_HID_REPORT_TAG_REPORT_COUNT		0x9
+#define USB_HID_REPORT_TAG_PUSH				0xA
+#define USB_HID_REPORT_TAG_POP				0xB
+
+
+/* LOCAL ITEMS */
+#define USB_HID_TAG_CLASS_LOCAL					0x2
+#define USB_HID_REPORT_TAG_USAGE				0x0
+#define USB_HID_REPORT_TAG_USAGE_MINIMUM		0x1
+#define USB_HID_REPORT_TAG_USAGE_MAXIMUM		0x2
+#define USB_HID_REPORT_TAG_DESIGNATOR_INDEX		0x3
+#define USB_HID_REPORT_TAG_DESIGNATOR_MINIMUM	0x4
+#define USB_HID_REPORT_TAG_DESIGNATOR_MAXIMUM	0x5
+#define USB_HID_REPORT_TAG_STRING_INDEX			0x7
+#define USB_HID_REPORT_TAG_STRING_MINIMUM		0x8
+#define USB_HID_REPORT_TAG_STRING_MAXIMUM		0x9
+#define USB_HID_REPORT_TAG_DELIMITER			0xA
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usbhid/include/usb/hid/hiddescriptor.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hiddescriptor.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbhid/include/usb/hid/hiddescriptor.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2011 Matej Klonfar
+ * 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 libusbhid
+ * @{
+ */
+/** @file
+ * USB HID report descriptor and report data parser
+ */
+#ifndef LIBUSBHID_HIDDESCRIPTOR_H_
+#define LIBUSBHID_HIDDESCRIPTOR_H_
+
+#include <stdint.h>
+#include <adt/list.h>
+#include <usb/hid/hid_report_items.h>
+#include <usb/hid/hidpath.h>
+#include <usb/hid/hidtypes.h>
+
+
+/*
+ * Descriptor parser functions
+ */
+
+/** */
+int usb_hid_parse_report_descriptor(usb_hid_report_t *report, 
+                                    const uint8_t *data, size_t size);
+
+/** */
+void usb_hid_free_report(usb_hid_report_t *report);
+
+/** */
+void usb_hid_descriptor_print(usb_hid_report_t *report);
+
+
+int usb_hid_report_init(usb_hid_report_t *report);
+int usb_hid_report_append_fields(usb_hid_report_t *report, 
+                                 usb_hid_report_item_t *report_item);
+
+usb_hid_report_description_t * usb_hid_report_find_description(const usb_hid_report_t *report, uint8_t report_id, usb_hid_report_type_t type);
+int usb_hid_report_parse_tag(uint8_t tag, uint8_t class, const uint8_t *data, size_t item_size,
+                             usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
+int usb_hid_report_parse_main_tag(uint8_t tag, const uint8_t *data, size_t item_size,
+                             usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
+int usb_hid_report_parse_global_tag(uint8_t tag, const uint8_t *data, size_t item_size,
+                             usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
+int usb_hid_report_parse_local_tag(uint8_t tag, const uint8_t *data, size_t item_size,
+                             usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
+
+void usb_hid_descriptor_print_list(link_t *head);
+void usb_hid_report_reset_local_items(usb_hid_report_item_t *report_item);
+void usb_hid_free_report_list(link_t *head);
+usb_hid_report_item_t *usb_hid_report_item_clone(const usb_hid_report_item_t *item);
+uint32_t usb_hid_report_tag_data_uint32(const uint8_t *data, size_t size);
+
+usb_hid_report_path_t *usb_hid_report_path_try_insert(usb_hid_report_t *report, usb_hid_report_path_t *cmp_path);
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usbhid/include/usb/hid/hidparser.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hidparser.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbhid/include/usb/hid/hidparser.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2011 Matej Klonfar
+ * 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 libusbhid
+ * @{
+ */
+/** @file
+ * USB HID report descriptor and report data parser
+ */
+#ifndef LIBUSBHID_HIDPARSER_H_
+#define LIBUSBHID_HIDPARSER_H_
+
+#include <stdint.h>
+#include <adt/list.h>
+#include <usb/hid/hid_report_items.h>
+#include <usb/hid/hidpath.h>
+#include <usb/hid/hidtypes.h>
+#include <usb/hid/hiddescriptor.h>
+
+
+/*
+ * Input report parser functions
+ */
+/** */
+int usb_hid_parse_report(const usb_hid_report_t *report, const uint8_t *data, 
+                         size_t size, uint8_t *report_id);
+
+/*
+ * Output report parser functions
+ */
+/** Allocates output report buffer*/
+uint8_t *usb_hid_report_output(usb_hid_report_t *report, size_t *size, 
+                               uint8_t report_id);
+
+/** Frees output report buffer*/
+void usb_hid_report_output_free(uint8_t *output);
+
+/** Returns size of report in items */
+size_t usb_hid_report_size(usb_hid_report_t *report, uint8_t report_id, 
+                           usb_hid_report_type_t type);
+
+/** Makes the output report buffer by translated given data */
+int usb_hid_report_output_translate(usb_hid_report_t *report, uint8_t report_id, 
+                                    uint8_t *buffer, size_t size);
+
+/** */
+usb_hid_report_field_t *usb_hid_report_get_sibling(usb_hid_report_t *report, 
+                                                   usb_hid_report_field_t *field, 
+                                                   usb_hid_report_path_t *path, 
+                                                   int flags, 
+                                                   usb_hid_report_type_t type);
+
+/** */
+uint8_t usb_hid_report_get_report_id(usb_hid_report_t *report, 
+                                     uint8_t report_id, 
+                                     usb_hid_report_type_t type);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usbhid/include/usb/hid/hidpath.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hidpath.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbhid/include/usb/hid/hidpath.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2011 Matej Klonfar
+ * 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 libusbhid
+ * @{
+ */
+/** @file
+ * USB HID report descriptor and report data parser
+ */
+#ifndef LIBUSBHID_HIDPATH_H_
+#define LIBUSBHID_HIDPATH_H_
+
+#include <usb/hid/hidparser.h>
+#include <stdint.h>
+#include <adt/list.h>
+
+/**
+ * Description of path of usage pages and usages in report descriptor
+ */
+/** Wanted usage path must be exactly the same as the searched one */
+#define USB_HID_PATH_COMPARE_STRICT		0
+/** Wanted usage path must be the suffix in the searched one */
+#define USB_HID_PATH_COMPARE_END		1
+/** */
+#define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY	2
+/** Searched usage page must be prefix of the other one */
+#define USB_HID_PATH_COMPARE_BEGIN		4
+/** Searched couple of usage page and usage can be anywhere in usage path */
+#define USB_HID_PATH_COMPARE_ANYWHERE		8
+
+
+/** Collection usage path structure */
+typedef struct {
+	/** */
+	uint32_t usage_page;
+	/** */	
+	uint32_t usage;
+
+	uint8_t flags;
+	/** */
+	link_t link;
+} usb_hid_report_usage_path_t;
+
+/** */
+typedef struct {
+	/** */	
+	int depth;	
+	uint8_t report_id;
+	
+	/** */	
+	link_t link; /* list */
+
+	link_t head; /* head of list of usage paths */
+
+} usb_hid_report_path_t;
+
+/** */
+usb_hid_report_path_t *usb_hid_report_path(void);
+
+/** */
+void usb_hid_report_path_free(usb_hid_report_path_t *path);
+
+/** */
+int usb_hid_report_path_set_report_id(usb_hid_report_path_t *usage_path, 
+                                      uint8_t report_id);
+
+/** */
+int usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, 
+                                    int32_t usage_page, int32_t usage);
+
+/** */
+void usb_hid_report_remove_last_item(usb_hid_report_path_t *usage_path);
+
+/** */
+void usb_hid_report_null_last_item(usb_hid_report_path_t *usage_path);
+
+/** */
+void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path, 
+                                  int32_t tag, int32_t data);
+
+/** */
+int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path, 
+                                      usb_hid_report_path_t *path, int flags);
+
+/** */
+usb_hid_report_path_t *usb_hid_report_path_clone(usb_hid_report_path_t *usage_path);
+
+void usb_hid_print_usage_path(usb_hid_report_path_t *path);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usbhid/include/usb/hid/hidreport.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hidreport.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbhid/include/usb/hid/hidreport.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011 Lubos Slovak
+ * 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 libusbhid
+ * @{
+ */
+/** @file
+ * USB HID report parser initialization from descriptors.
+ */
+
+#ifndef LIBUSBHID_HIDREPORT_H_
+#define LIBUSBHID_HIDREPORT_H_
+
+#include <usb/dev/driver.h>
+#include <usb/hid/hidparser.h>
+
+/**
+ * Retrieves the Report descriptor from the USB device and initializes the
+ * report parser.
+ *
+ * \param dev USB device representing a HID device.
+ * \param parser HID Report parser.
+ *
+ * \retval EOK if successful.
+ * \retval EINVAL if one of the parameters is not given (is NULL).
+ * \retval ENOENT if there are some descriptors missing.
+ * \retval ENOMEM if an error with allocation occured.
+ * \retval EINVAL if the Report descriptor's size does not match the size 
+ *         from the interface descriptor.
+ * \return Other value inherited from function usb_pipe_start_session(),
+ *         usb_pipe_end_session() or usb_request_get_descriptor().
+ */
+int usb_hid_process_report_descriptor(usb_device_t *dev, 
+    usb_hid_report_t *report);
+
+#endif /* LIBUSB_HIDREPORT_H_ */
+
+/**
+ * @}
+ */
Index: uspace/lib/usbhid/include/usb/hid/hidtypes.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hidtypes.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbhid/include/usb/hid/hidtypes.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2011 Matej Klonfar
+ * 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 libusbhid
+ * @{
+ */
+/** @file
+ * USB HID report descriptor and report data parser
+ */
+#ifndef LIBUSBHID_HIDTYPES_H_
+#define LIBUSBHID_HIDTYPES_H_
+
+#include <stdint.h>
+#include <adt/list.h>
+
+#define USB_HID_MAX_USAGES	0xffff
+
+#define USB_HID_UINT32_TO_INT32(x, size)	((((x) & (1 << ((size) - 1))) != 0) ? -(~(x - 1) & ((1 << size) - 1)) : (x)) //(-(~((x) - 1)))
+#define USB_HID_INT32_TO_UINT32(x, size)	(((x) < 0 ) ? ((1 << (size)) + (x)) : (x))
+
+
+typedef enum {
+	USB_HID_REPORT_TYPE_INPUT = 1,
+	USB_HID_REPORT_TYPE_OUTPUT = 2,
+	USB_HID_REPORT_TYPE_FEATURE = 3
+} usb_hid_report_type_t;
+
+
+typedef struct {
+	/** */
+	int report_count;
+	link_t reports;		/** list of usb_hid_report_description_t */
+
+	link_t collection_paths;
+	int collection_paths_count;
+
+	int use_report_ids;
+	uint8_t last_report_id;
+	
+} usb_hid_report_t;
+
+typedef struct {
+	uint8_t report_id;
+	usb_hid_report_type_t type;
+
+	size_t bit_length;
+	size_t item_length;
+	
+	link_t report_items;	/** list of report items (fields) */
+
+	link_t link;
+} usb_hid_report_description_t;
+
+typedef struct {
+
+	int offset;
+	size_t size;
+
+	uint16_t usage_page;
+	uint16_t usage;
+
+	uint8_t item_flags;
+	usb_hid_report_path_t *collection_path;
+
+	int32_t logical_minimum;
+	int32_t logical_maximum;
+	int32_t physical_minimum;
+	int32_t physical_maximum;
+	int32_t usage_minimum;
+	int32_t usage_maximum;
+	uint32_t unit;
+	uint32_t unit_exponent;
+
+	uint32_t *usages;
+	size_t usages_count;
+
+	int32_t value;
+
+	link_t link;
+} usb_hid_report_field_t;
+
+
+
+/**
+ * state table
+ */
+typedef struct {
+	/** report id */	
+	int32_t id;
+	
+	/** */
+	uint16_t extended_usage_page;
+	uint32_t usages[USB_HID_MAX_USAGES];
+	int usages_count;
+
+	/** */
+	uint32_t usage_page;
+
+	/** */	
+	int32_t usage_minimum;
+	/** */	
+	int32_t usage_maximum;
+	/** */	
+	int32_t logical_minimum;
+	/** */	
+	int32_t logical_maximum;
+	/** */	
+	int32_t size;
+	/** */	
+	int32_t count;
+	/** */	
+	size_t offset;
+	/** */	
+	int32_t unit_exponent;
+	/** */	
+	int32_t unit;
+
+	/** */
+	uint32_t string_index;
+	/** */	
+	uint32_t string_minimum;
+	/** */	
+	uint32_t string_maximum;
+	/** */	
+	uint32_t designator_index;
+	/** */	
+	uint32_t designator_minimum;
+	/** */	
+	uint32_t designator_maximum;
+	/** */	
+	int32_t physical_minimum;
+	/** */	
+	int32_t physical_maximum;
+
+	/** */	
+	uint8_t item_flags;
+
+	usb_hid_report_type_t type;
+
+	/** current collection path*/	
+	usb_hid_report_path_t *usage_path;
+	/** */	
+	link_t link;
+
+	int in_delimiter;
+} usb_hid_report_item_t;
+
+/** HID parser callbacks for IN items. */
+typedef struct {
+	/** Callback for keyboard.
+	 *
+	 * @param key_codes Array of pressed key (including modifiers).
+	 * @param count Length of @p key_codes.
+	 * @param arg Custom argument.
+	 */
+	void (*keyboard)(const uint8_t *key_codes, size_t count, const uint8_t report_id, void *arg);
+} usb_hid_report_in_callbacks_t;
+
+
+typedef enum {
+	USB_HID_MOD_LCTRL = 0x01,
+	USB_HID_MOD_LSHIFT = 0x02,
+	USB_HID_MOD_LALT = 0x04,
+	USB_HID_MOD_LGUI = 0x08,
+	USB_HID_MOD_RCTRL = 0x10,
+	USB_HID_MOD_RSHIFT = 0x20,
+	USB_HID_MOD_RALT = 0x40,
+	USB_HID_MOD_RGUI = 0x80,
+	USB_HID_MOD_COUNT = 8
+} usb_hid_modifiers_t;
+
+static const usb_hid_modifiers_t 
+    usb_hid_modifiers_consts[USB_HID_MOD_COUNT] = {
+	USB_HID_MOD_LCTRL,
+	USB_HID_MOD_LSHIFT,
+	USB_HID_MOD_LALT,
+	USB_HID_MOD_LGUI,
+	USB_HID_MOD_RCTRL,
+	USB_HID_MOD_RSHIFT,
+	USB_HID_MOD_RALT,
+	USB_HID_MOD_RGUI
+};
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usbhid/include/usb/hid/iface.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/iface.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbhid/include/usb/hid/iface.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * 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 libusbhid
+ * @{
+ */
+/** @file
+ * Client functions for accessing USB HID interface.
+ */
+#ifndef LIBUSBHID_CLASSES_HID_IFACE_H_
+#define LIBUSBHID_CLASSES_HID_IFACE_H_
+
+#include <sys/types.h>
+
+int usbhid_dev_get_event_length(int);
+int usbhid_dev_get_event(int, uint16_t *, uint16_t *, size_t, size_t *,
+    unsigned int);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usbhid/include/usb/hid/request.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/request.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbhid/include/usb/hid/request.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2011 Lubos Slovak
+ * 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 libusbhid
+ * @{
+ */
+/** @file
+ * HID class-specific requests.
+ */
+
+#ifndef USB_KBD_HIDREQ_H_
+#define USB_KBD_HIDREQ_H_
+
+#include <stdint.h>
+
+#include <usb/hid/hid.h>
+#include <usb/dev/pipes.h>
+
+/*----------------------------------------------------------------------------*/
+
+int usbhid_req_set_report(usb_pipe_t *ctrl_pipe, int iface_no,
+    usb_hid_report_type_t type, uint8_t *buffer, size_t buf_size);
+
+int usbhid_req_set_protocol(usb_pipe_t *ctrl_pipe, int iface_no, 
+    usb_hid_protocol_t protocol);
+
+int usbhid_req_set_idle(usb_pipe_t *ctrl_pipe, int iface_no, uint8_t duration);
+
+int usbhid_req_get_report(usb_pipe_t *ctrl_pipe, int iface_no, 
+    usb_hid_report_type_t type, uint8_t *buffer, size_t buf_size, 
+    size_t *actual_size);
+
+int usbhid_req_get_protocol(usb_pipe_t *ctrl_pipe, int iface_no, 
+    usb_hid_protocol_t *protocol);
+
+int usbhid_req_get_idle(usb_pipe_t *ctrl_pipe, int iface_no, uint8_t *duration);
+
+/*----------------------------------------------------------------------------*/
+
+#endif /* USB_KBD_HIDREQ_H_ */
+
+/**
+ * @}
+ */
Index: uspace/lib/usbhid/include/usb/hid/usages/core.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/usages/core.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbhid/include/usb/hid/usages/core.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * 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 libusbhid
+ * @{
+ */
+/** @file
+ * @brief USB HID Usage Tables.
+ */
+#ifndef LIBUSBHID_HIDUT_H_
+#define LIBUSBHID_HIDUT_H_
+
+/** USB/HID Usage Pages. */
+typedef enum {
+	USB_HIDUT_PAGE_GENERIC_DESKTOP = 1,
+	USB_HIDUT_PAGE_SIMULATION = 2,
+	USB_HIDUT_PAGE_VR = 3,
+	USB_HIDUT_PAGE_SPORT = 4,
+	USB_HIDUT_PAGE_GAME = 5,
+	USB_HIDUT_PAGE_GENERIC_DEVICE = 6,
+	USB_HIDUT_PAGE_KEYBOARD = 7,
+	USB_HIDUT_PAGE_LED = 8,
+	USB_HIDUT_PAGE_BUTTON = 9,
+	USB_HIDUT_PAGE_ORDINAL = 0x0a,
+	USB_HIDUT_PAGE_TELEPHONY_DEVICE = 0x0b,
+	USB_HIDUT_PAGE_CONSUMER = 0x0c
+} usb_hidut_usage_page_t;
+
+/** Usages for Generic Desktop Page. */
+typedef enum {
+	USB_HIDUT_USAGE_GENERIC_DESKTOP_POINTER = 1,
+	USB_HIDUT_USAGE_GENERIC_DESKTOP_MOUSE = 2,
+	USB_HIDUT_USAGE_GENERIC_DESKTOP_JOYSTICK = 4,
+	USB_HIDUT_USAGE_GENERIC_DESKTOP_GAMEPAD = 5,
+	USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYBOARD = 6,
+	USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYPAD = 7,
+	USB_HIDUT_USAGE_GENERIC_DESKTOP_X = 0x30,
+	USB_HIDUT_USAGE_GENERIC_DESKTOP_Y = 0x31,
+	USB_HIDUT_USAGE_GENERIC_DESKTOP_WHEEL = 0x38
+	/* USB_HIDUT_USAGE_GENERIC_DESKTOP_ = , */
+	
+} usb_hidut_usage_generic_desktop_t;
+
+typedef enum {
+	USB_HIDUT_USAGE_CONSUMER_CONSUMER_CONTROL = 1
+} usb_hidut_usage_consumer_t;
+
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usbhid/include/usb/hid/usages/kbdgen.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/usages/kbdgen.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbhid/include/usb/hid/usages/kbdgen.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * 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 libusbhid
+ * @{
+ */
+/** @file
+ * @brief USB HID key codes.
+ * @details
+ * This is not a typical header as by default it is equal to empty file.
+ * However, by cleverly defining the USB_HIDUT_KBD_KEY you can use it
+ * to generate conversion tables etc.
+ *
+ * For example, this creates enum for known keys:
+ * @code
+#define USB_HIDUT_KBD_KEY(name, usage_id, l, lc, l1, l2) \
+	USB_KBD_KEY_##name = usage_id,
+typedef enum {
+	#include <usb/hidutkbd.h>
+} usb_key_code_t;
+ @endcode
+ *
+ * Maybe, it might be better that you would place such enums into separate
+ * files and create them as separate step before compiling to allow tools
+ * such as Doxygen get the definitions right.
+ *
+ * @warning This file does not include guard to prevent multiple inclusions
+ * into a single file.
+ */
+
+
+#ifndef USB_HIDUT_KBD_KEY
+/** Declare keyboard key.
+ * @param name Key name (identifier).
+ * @param usage_id Key code (see Keyboard/Keypad Page (0x07) in HUT1.12.
+ * @param letter Corresponding character (0 if not applicable).
+ * @param letter_caps Corresponding character with Caps on.
+ * @param letter_mod1 Corresponding character with modifier #1 on.
+ * @param letter_mod2 Corresponding character with modifier #2 on.
+ */
+#define USB_HIDUT_KBD_KEY(name, usage_id, letter, letter_caps, letter_mod1, letter_mod2)
+
+#endif
+
+#define __NONPRINT(name, usage_id) \
+	USB_HIDUT_KBD_KEY(name, usage_id, 0, 0, 0, 0)
+
+/* US alphabet letters */
+USB_HIDUT_KBD_KEY(A, 0x04, 'a', 'A', 0, 0)
+USB_HIDUT_KBD_KEY(B, 0x05, 'b', 'B', 0, 0)
+USB_HIDUT_KBD_KEY(C, 0x06, 'c', 'C', 0, 0)
+USB_HIDUT_KBD_KEY(D, 0x07, 'd', 'D', 0, 0)
+USB_HIDUT_KBD_KEY(E, 0x08, 'e', 'E', 0, 0)
+USB_HIDUT_KBD_KEY(F, 0x09, 'f', 'F', 0, 0)
+USB_HIDUT_KBD_KEY(G, 0x0A, 'g', 'G', 0, 0)
+USB_HIDUT_KBD_KEY(H, 0x0B, 'h', 'H', 0, 0)
+USB_HIDUT_KBD_KEY(I, 0x0C, 'i', 'I', 0, 0)
+USB_HIDUT_KBD_KEY(J, 0x0D, 'j', 'J', 0, 0)
+USB_HIDUT_KBD_KEY(K, 0x0E, 'k', 'K', 0, 0)
+USB_HIDUT_KBD_KEY(L, 0x0F, 'l', 'L', 0, 0)
+USB_HIDUT_KBD_KEY(M, 0x10, 'm', 'M', 0, 0)
+USB_HIDUT_KBD_KEY(N, 0x11, 'n', 'N', 0, 0)
+USB_HIDUT_KBD_KEY(O, 0x12, 'o', 'O', 0, 0)
+USB_HIDUT_KBD_KEY(P, 0x13, 'p', 'P', 0, 0)
+USB_HIDUT_KBD_KEY(Q, 0x14, 'q', 'Q', 0, 0)
+USB_HIDUT_KBD_KEY(R, 0x15, 'r', 'R', 0, 0)
+USB_HIDUT_KBD_KEY(S, 0x16, 's', 'S', 0, 0)
+USB_HIDUT_KBD_KEY(T, 0x17, 't', 'T', 0, 0)
+USB_HIDUT_KBD_KEY(U, 0x18, 'u', 'U', 0, 0)
+USB_HIDUT_KBD_KEY(V, 0x19, 'v', 'V', 0, 0)
+USB_HIDUT_KBD_KEY(W, 0x1A, 'w', 'W', 0, 0)
+USB_HIDUT_KBD_KEY(X, 0x1B, 'x', 'X', 0, 0)
+USB_HIDUT_KBD_KEY(Y, 0x1C, 'y', 'Y', 0, 0)
+USB_HIDUT_KBD_KEY(Z, 0x1D, 'z', 'Z', 0, 0)
+
+/* Keyboard digits */
+USB_HIDUT_KBD_KEY(1, 0x1E, '1', '!', 0, 0)
+USB_HIDUT_KBD_KEY(2, 0x1F, '2', '@', 0, 0)
+USB_HIDUT_KBD_KEY(3, 0x20, '3', '#', 0, 0)
+USB_HIDUT_KBD_KEY(4, 0x21, '4', '$', 0, 0)
+USB_HIDUT_KBD_KEY(5, 0x22, '5', '%', 0, 0)
+USB_HIDUT_KBD_KEY(6, 0x23, '6', '^', 0, 0)
+USB_HIDUT_KBD_KEY(7, 0x24, '7', '&', 0, 0)
+USB_HIDUT_KBD_KEY(8, 0x25, '8', '*', 0, 0)
+USB_HIDUT_KBD_KEY(9, 0x26, '9', '(', 0, 0)
+USB_HIDUT_KBD_KEY(0, 0x27, '0', ')', 0, 0)
+
+/* More-or-less typewriter command keys */
+USB_HIDUT_KBD_KEY(ENTER, 0x28, '\n', 0, 0, 0)
+USB_HIDUT_KBD_KEY(ESCAPE, 0x29, 0, 0, 0, 0)
+USB_HIDUT_KBD_KEY(BACKSPACE, 0x2A, '\b', 0, 0, 0)
+USB_HIDUT_KBD_KEY(TAB, 0x2B, '\t', 0, 0, 0)
+USB_HIDUT_KBD_KEY(SPACE, 0x2C, ' ', 0, 0, 0)
+
+/* Special (printable) characters */
+USB_HIDUT_KBD_KEY(DASH, 0x2D, '-', '_', 0, 0)
+USB_HIDUT_KBD_KEY(EQUALS, 0x2E, '=', '+', 0, 0)
+USB_HIDUT_KBD_KEY(LEFT_BRACKET, 0x2F, '[', '{', 0, 0)
+USB_HIDUT_KBD_KEY(RIGHT_BRACKET, 0x30, ']', '}', 0, 0)
+USB_HIDUT_KBD_KEY(BACKSLASH, 0x31, '\\', '|', 0, 0)
+USB_HIDUT_KBD_KEY(HASH, 0x32, '#', '~', 0, 0)
+USB_HIDUT_KBD_KEY(SEMICOLON, 0x33, ';', ':', 0, 0)
+USB_HIDUT_KBD_KEY(APOSTROPHE, 0x34, '\'', '"', 0, 0)
+USB_HIDUT_KBD_KEY(GRAVE_ACCENT, 0x35, '`', '~', 0, 0)
+USB_HIDUT_KBD_KEY(COMMA, 0x36, ',', '<', 0, 0)
+USB_HIDUT_KBD_KEY(PERIOD, 0x37, '.', '>', 0, 0)
+USB_HIDUT_KBD_KEY(SLASH, 0x38, '/', '?', 0, 0)
+
+USB_HIDUT_KBD_KEY(CAPS_LOCK, 0x39, 0, 0, 0, 0)
+
+/* Function keys */
+__NONPRINT( F1, 0x3A)
+__NONPRINT( F2, 0x3B)
+__NONPRINT( F3, 0x3C)
+__NONPRINT( F4, 0x3D)
+__NONPRINT( F5, 0x3E)
+__NONPRINT( F6, 0x3F)
+__NONPRINT( F7, 0x40)
+__NONPRINT( F8, 0x41)
+__NONPRINT( F9, 0x42)
+__NONPRINT(F10, 0x43)
+__NONPRINT(F11, 0x44)
+__NONPRINT(F12, 0x45)
+
+/* Cursor movement keys & co. */
+__NONPRINT(PRINT_SCREEN, 0x46)
+__NONPRINT(SCROLL_LOCK, 0x47)
+__NONPRINT(PAUSE, 0x48)
+__NONPRINT(INSERT, 0x49)
+__NONPRINT(HOME, 0x4A)
+__NONPRINT(PAGE_UP, 0x4B)
+__NONPRINT(DELETE, 0x4C)
+__NONPRINT(END, 0x4D)
+__NONPRINT(PAGE_DOWN, 0x4E)
+__NONPRINT(RIGHT_ARROW, 0x4F)
+__NONPRINT(LEFT_ARROW, 0x50)
+__NONPRINT(DOWN_ARROW, 0x51)
+__NONPRINT(UP_ARROW, 0x52)
+
+
+
+
+/* USB_HIDUT_KBD_KEY(, 0x, '', '', 0, 0) */
+
+#undef __NONPRINT
+
+/**
+ * @}
+ */
+
Index: uspace/lib/usbhid/include/usb/hid/usages/led.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/usages/led.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
+++ uspace/lib/usbhid/include/usb/hid/usages/led.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2010 Lubos Slovak
+ * 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 libusbhid
+ * @{
+ */
+/** @file
+ * @brief USB HID Usage Tables - LED page.
+ */
+#ifndef LIBUSBHID_UTLED_H_
+#define LIBUSBHID_UTLED_H_
+
+typedef enum {
+	USB_HID_LED_UNDEFINED = 0,
+	USB_HID_LED_NUM_LOCK,
+	USB_HID_LED_CAPS_LOCK,
+	USB_HID_LED_SCROLL_LOCK,
+	USB_HID_LED_COMPOSE,
+	USB_HID_LED_KANA,
+	USB_HID_LED_POWER,
+	USB_HID_LED_SHIFT,
+	USB_HID_LED_DND,
+	USB_HID_LED_MUTE,
+	USB_HID_LED_TONE_ENABLE,
+	USB_HID_LED_HIGH_CUT_FILTER,
+	USB_HID_LED_LOW_CUT_FILTER,
+	USB_HID_LED_EQ_ENABLE,
+	USB_HID_LED_SOUND_FIELD_ON,
+	USB_HID_LED_SURROUND_ON,
+	USB_HID_LED_REPEAT,
+	USB_HID_LED_STEREO,
+	USB_HID_LED_SAMPLING_RATE_DETECT,
+	USB_HID_LED_SPINNING,
+	USB_HID_LED_CAV,
+	USB_HID_LED_CLV,
+	USB_HID_LED_RECORDING_FORMAT_DETECT,
+	USB_HID_LED_OFF_HOOK,
+	USB_HID_LED_RING,
+	USB_HID_LED_MESSAGE_WAITING,
+	USB_HID_LED_DATA_MODE,
+	USB_HID_LED_BATTERY_OPERATION,
+	USB_HID_LED_BATTERY_OK,
+	USB_HID_LED_BATTERY_LOW,
+	USB_HID_LED_SPEAKER,
+	USB_HID_LED_HEAD_SET,
+	USB_HID_LED_HOLD,
+	USB_HID_LED_MICRO,
+	USB_HID_LED_COVERAGE,
+	USB_HID_LED_NIGHT_MODE,
+	USB_HID_LED_SEND_CALLS,
+	USB_HID_LED_CALL_PICKUP,
+	USB_HID_LED_CONFERENCE,
+	USB_HID_LED_STAND_BY,
+	USB_HID_LED_CAMERA_ON,
+	USB_HID_LED_CAMERA_OFF,
+	USB_HID_LED_ON_LINE,
+	USB_HID_LED_OFF_LINE,
+	USB_HID_LED_BUSY,
+	USB_HID_LED_READY,
+	USB_HID_LED_PAPER_OUT,
+	USB_HID_LED_PAPER_JAM,
+	USB_HID_LED_REMOTE,
+	USB_HID_LED_FORWARD,
+	USB_HID_LED_REVERSE,
+	USB_HID_LED_STOP,
+	USB_HID_LED_REWIND,
+	USB_HID_LED_FAST_FORWARD,
+	USB_HID_LED_PLAY,
+	USB_HID_LED_PAUSE,
+	USB_HID_LED_RECORD,
+	USB_HID_LED_ERROR,
+	USB_HID_LED_USAGE_SELECTED_IND,
+	USB_HID_LED_USAGE_IN_USE_IND,
+	USB_HID_LED_USAGE_MULTI_MODE_IND,
+	USB_HID_LED_IND_ON,
+	USB_HID_LED_IND_FLASH,
+	USB_HID_LED_IND_SLOW_BLINK,
+	USB_HID_LED_IND_FAST_BLINK,
+	USB_HID_LED_IND_OFF,
+	USB_HID_LED_FLASH_ON_TIME,
+	USB_HID_LED_SLOW_BLINK_ON_TIME,
+	USB_HID_LED_SLOW_BLINK_OFF_TIME,
+	USB_HID_LED_FAST_BLINK_ON_TIME,
+	USB_HID_LED_FAST_BLINK_OFF_TIME,
+	USB_HID_LED_USAGE_IND_COLOR,
+	USB_HID_LED_IND_RED,
+	USB_HID_LED_IND_GREEN,
+	USB_HID_LED_IND_AMBER,
+	USB_HID_LED_GENERIC_IND,
+	USB_HID_LED_SYSTEM_SUSPEND,
+	USB_HID_LED_EXTERNAL_POWER
+} usb_hid_usage_led_t;
+
+#endif /* LIBUSB_UTLED_H_ */
+/**
+ * @}
+ */
Index: uspace/lib/usbhid/src/hiddescriptor.c
===================================================================
--- uspace/lib/usbhid/src/hiddescriptor.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbhid/src/hiddescriptor.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbhid
  * @{
  */
@@ -33,5 +33,5 @@
  * HID report descriptor and report data parser implementation.
  */
-#include <usb/classes/hidparser.h>
+#include <usb/hid/hidparser.h>
 #include <errno.h>
 #include <stdio.h>
@@ -64,6 +64,9 @@
 {
 	/* find or append current collection path to the list */
-	link_t *path_it = report->collection_paths.next;
+	//link_t *path_it = report->collection_paths.next;
+	link_t *path_it = report->collection_paths.prev->next;
 	usb_hid_report_path_t *path = NULL;
+	
+	
 	while(path_it != &report->collection_paths) {
 		path = list_get_instance(path_it, usb_hid_report_path_t, link);
@@ -116,8 +119,14 @@
 	int i;
 
-	for(i=0; i<report_item->usages_count; i++){
-		usb_log_debug("usages (%d) - %x\n", i, report_item->usages[i]);
-	}
-
+	uint32_t *usages;
+	int usages_used=0;
+	if(report_item->usages_count > 0){
+		usages = malloc(sizeof(int32_t) * report_item->usages_count);
+		memcpy(usages, report_item->usages, sizeof(int32_t) * report_item->usages_count);
+	}
+	else {
+		usages = NULL;
+	}
+	
 	usb_hid_report_path_t *path = report_item->usage_path;	
 	for(i=0; i<report_item->count; i++){
@@ -133,16 +142,21 @@
 		field->physical_maximum = report_item->physical_maximum;
 
-		field->usage_minimum = report_item->usage_minimum;
-		field->usage_maximum = report_item->usage_maximum;
-		if(report_item->extended_usage_page != 0){
-			field->usage_page = report_item->extended_usage_page;
+		if(USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags) == 0){
+			/* 
+			 	Store usage array. The Correct Usage Page and Usage is depending 
+			 	on data in report and will be filled later
+			*/
+			field->usage = 0;
+			field->usage_page = 0; //report_item->usage_page;
+
+			field->usages_count = report_item->usages_count;
+			field->usages = usages;
+			usages_used = 1;
 		}
 		else {
-			field->usage_page = report_item->usage_page;
-		}
-
-		if(report_item->usages_count > 0 && ((report_item->usage_minimum == 0) && (report_item->usage_maximum == 0))) {
-			uint32_t usage;
-			if(i < report_item->usages_count){
+
+			/* Fill the correct Usage and Usage Page */
+			int32_t usage;
+			if(i < report_item->usages_count) {
 				usage = report_item->usages[i];
 			}
@@ -151,18 +165,13 @@
 			}
 
-						
-			if((usage & 0xFFFF0000) != 0){
-				field->usage_page = (usage >> 16);					
-				field->usage = (usage & 0xFFFF);
+			if(USB_HID_IS_EXTENDED_USAGE(usage)){
+				field->usage = USB_HID_EXTENDED_USAGE(usage);
+				field->usage_page = USB_HID_EXTENDED_USAGE_PAGE(usage);
 			}
 			else {
+				// should not occur
 				field->usage = usage;
-			}
-
-			
-		}	
-
-		if((USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags) != 0) && (!((report_item->usage_minimum == 0) && (report_item->usage_maximum == 0)))) {
-			field->usage = report_item->usage_minimum + i;					
+				field->usage_page = report_item->usage_page;
+			}
 		}
 		
@@ -209,4 +218,8 @@
 	}
 
+	// free only when not used!!!
+	if(usages && usages_used == 0) {
+		free(usages);
+	}
 
 	return EOK;
@@ -450,4 +463,5 @@
 			
 		case USB_HID_REPORT_TAG_COLLECTION:
+
 			// store collection atributes
 			path_item = list_get_instance(usage_path->head.prev, usb_hid_report_usage_path_t, link);
@@ -455,6 +469,10 @@
 			
 			// set last item
-			usb_hid_report_set_last_item(usage_path, USB_HID_TAG_CLASS_GLOBAL, report_item->usage_page);
-			usb_hid_report_set_last_item(usage_path, USB_HID_TAG_CLASS_LOCAL, report_item->usages[report_item->usages_count-1]);
+			usb_hid_report_set_last_item(usage_path, 
+			                             USB_HID_TAG_CLASS_GLOBAL, 
+			                             USB_HID_EXTENDED_USAGE_PAGE(report_item->usages[report_item->usages_count-1]));
+			usb_hid_report_set_last_item(usage_path, 
+			                             USB_HID_TAG_CLASS_LOCAL, 
+			                             USB_HID_EXTENDED_USAGE(report_item->usages[report_item->usages_count-1]));
 			
 			// append the new one which will be set by common
@@ -551,4 +569,6 @@
                              usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path)
 {
+	int32_t extended_usage;
+	
 	switch(tag) {
 		case USB_HID_REPORT_TAG_USAGE:
@@ -560,10 +580,12 @@
 					report_item->in_delimiter = INSIDE_DELIMITER_SET;
 				case OUTSIDE_DELIMITER_SET:
-					report_item->usages[report_item->usages_count] = usb_hid_report_tag_data_uint32(data,item_size);
+					extended_usage = ((report_item->usage_page) << 16);
+					extended_usage += usb_hid_report_tag_data_uint32(data,item_size);
+					report_item->usages[report_item->usages_count] = extended_usage;
 					report_item->usages_count++;
 					break;
 			}
 			break;
-		case USB_HID_REPORT_TAG_USAGE_MINIMUM:
+		case USB_HID_REPORT_TAG_USAGE_MINIMUM:			
 			if (item_size == 3) {
 				// usage extended usages
@@ -577,4 +599,9 @@
 		case USB_HID_REPORT_TAG_USAGE_MAXIMUM:
 			if (item_size == 3) {
+
+				if(report_item->extended_usage_page != ((usb_hid_report_tag_data_uint32(data,item_size) & 0xFF00) >> 16)) {
+					return EINVAL;
+				}
+				
 				// usage extended usages
 				report_item->extended_usage_page = (usb_hid_report_tag_data_uint32(data,item_size) & 0xFF00) >> 16; 
@@ -584,4 +611,18 @@
 				report_item->usage_maximum = usb_hid_report_tag_data_uint32(data,item_size);
 			}
+
+			// vlozit zaznamy do pole usages
+			int32_t i;
+			for(i=report_item->usage_minimum; i<=report_item->usage_maximum; i++) {
+				if(report_item->extended_usage_page) {
+					report_item->usages[report_item->usages_count++] = (report_item->extended_usage_page << 16) + i;
+				}
+				else {
+					
+					report_item->usages[report_item->usages_count++] = (report_item->usage_page << 16) + i;
+				}
+			}
+			report_item->extended_usage_page = 0;
+			
 			break;
 		case USB_HID_REPORT_TAG_DESIGNATOR_INDEX:
@@ -663,4 +704,5 @@
 		usb_log_debug("\t\ttUSAGEMIN: %X\n", report_item->usage_minimum);
 		usb_log_debug("\t\tUSAGEMAX: %X\n", report_item->usage_maximum);
+		usb_log_debug("\t\tUSAGES COUNT: %zu\n", report_item->usages_count);
 
 		usb_log_debug("\t\tVALUE: %X\n", report_item->value);
@@ -668,5 +710,5 @@
 		usb_log_debug("\t\tUSAGE PAGE: %X\n", report_item->usage_page);
 		
-		//usb_hid_print_usage_path(report_item->collection_path);
+		usb_hid_print_usage_path(report_item->collection_path);
 
 		usb_log_debug("\n");		
@@ -700,5 +742,5 @@
 		usb_hid_descriptor_print_list(&report_des->report_items);
 
-
+/*
 		link_t *path_it = report->collection_paths.next;
 		while(path_it != &report->collection_paths) {
@@ -706,5 +748,5 @@
 			path_it = path_it->next;
 		}
-		
+*/		
 		report_it = report_it->next;
 	}
Index: uspace/lib/usbhid/src/hidiface.c
===================================================================
--- uspace/lib/usbhid/src/hidiface.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbhid/src/hidiface.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbhid
  * @{
  */
@@ -35,5 +35,5 @@
 #include <dev_iface.h>
 #include <usbhid_iface.h>
-#include <usb/classes/hid/iface.h>
+#include <usb/hid/iface.h>
 #include <errno.h>
 #include <str_error.h>
Index: uspace/lib/usbhid/src/hidparser.c
===================================================================
--- uspace/lib/usbhid/src/hidparser.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbhid/src/hidparser.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbhid
  * @{
  */
@@ -33,5 +33,5 @@
  * HID report descriptor and report data parser implementation.
  */
-#include <usb/classes/hidparser.h>
+#include <usb/hid/hidparser.h>
 #include <errno.h>
 #include <stdio.h>
@@ -69,4 +69,28 @@
 
 
+/** Returns size of report of specified report id and type in items
+ *
+ * @param parser Opaque report parser structure
+ * @param report_id 
+ * @param type
+ * @return Number of items in specified report
+ */
+size_t usb_hid_report_size(usb_hid_report_t *report, uint8_t report_id, 
+                           usb_hid_report_type_t type)
+{
+	usb_hid_report_description_t *report_des;
+
+	if(report == NULL) {
+		return 0;
+	}
+
+	report_des = usb_hid_report_find_description (report, report_id, type);
+	if(report_des == NULL){
+		return 0;
+	}
+	else {
+		return report_des->item_length;
+	}
+}
 
 
@@ -87,5 +111,5 @@
 	usb_hid_report_description_t *report_des;
 	usb_hid_report_type_t type = USB_HID_REPORT_TYPE_INPUT;
-
+	
 	if(report == NULL) {
 		return EINVAL;
@@ -114,5 +138,15 @@
 				// array
 				item->value = usb_hid_translate_data(item, data);
-			    item->usage = (item->value - item->physical_minimum) + item->usage_minimum;
+		
+				item->usage = USB_HID_EXTENDED_USAGE(item->usages[item->value - item->physical_minimum]);
+				item->usage_page = USB_HID_EXTENDED_USAGE_PAGE(item->usages[item->value - item->physical_minimum]);				
+
+				usb_hid_report_set_last_item (item->collection_path, 
+				                              USB_HID_TAG_CLASS_GLOBAL,
+				                              item->usage_page);
+				usb_hid_report_set_last_item (item->collection_path, 
+				                              USB_HID_TAG_CLASS_LOCAL,
+				                              item->usage);
+				
 			}
 			else {
@@ -123,5 +157,5 @@
 		list_item = list_item->next;
 	}
-	   
+	
 	return EOK;
 	
@@ -206,48 +240,4 @@
 }
 
-/**
- * Returns number of items in input report which are accessible by given usage path
- *
- * @param parser Opaque report descriptor structure
- * @param path Usage path specification
- * @param flags Usage path comparison flags
- * @return Number of items in input report
- */
-size_t usb_hid_report_input_length(const usb_hid_report_t *report,
-	usb_hid_report_path_t *path, int flags)
-{	
-	
-	size_t ret = 0;
-
-	if(report == NULL) {
-		return 0;
-	}
-
-	usb_hid_report_description_t *report_des;
-	report_des = usb_hid_report_find_description (report, path->report_id, USB_HID_REPORT_TYPE_INPUT);
-	if(report_des == NULL) {
-		return 0;
-	}
-
-	link_t *field_it = report_des->report_items.next;
-	usb_hid_report_field_t *field;
-	while(field_it != &report_des->report_items) {
-
-		field = list_get_instance(field_it, usb_hid_report_field_t, link);
-		if(USB_HID_ITEM_FLAG_CONSTANT(field->item_flags) == 0) {
-			
-			usb_hid_report_path_append_item (field->collection_path, field->usage_page, field->usage);
-			if(usb_hid_report_compare_usage_path (field->collection_path, path, flags) == EOK) {
-				ret++;
-			}
-			usb_hid_report_remove_last_item (field->collection_path);
-		}
-		
-		field_it = field_it->next;
-	}
-
-	return ret;
-	}
-
 /*** OUTPUT API **/
 
@@ -304,46 +294,4 @@
 }
 
-/** Returns size of output for given usage path 
- *
- * @param parser Opaque report parser structure
- * @param path Usage path specified which items will be thought for the output
- * @param flags Flags of usage path structure comparison
- * @return Number of items matching the given usage path
- */
-size_t usb_hid_report_output_size(usb_hid_report_t *report,
-                                  usb_hid_report_path_t *path, int flags)
-{
-	size_t ret = 0;	
-	usb_hid_report_description_t *report_des;
-
-	if(report == NULL) {
-		return 0;
-	}
-
-	report_des = usb_hid_report_find_description (report, path->report_id, USB_HID_REPORT_TYPE_OUTPUT);
-	if(report_des == NULL){
-		return 0;
-	}
-	
-	link_t *field_it = report_des->report_items.next;
-	usb_hid_report_field_t *field;
-	while(field_it != &report_des->report_items) {
-
-		field = list_get_instance(field_it, usb_hid_report_field_t, link);
-		if(USB_HID_ITEM_FLAG_CONSTANT(field->item_flags) == 0){
-			usb_hid_report_path_append_item (field->collection_path, field->usage_page, field->usage);
-			if(usb_hid_report_compare_usage_path (field->collection_path, path, flags) == EOK) {
-				ret++;
-			}
-			usb_hid_report_remove_last_item (field->collection_path);
-		}
-		
-		field_it = field_it->next;
-	}
-
-	return ret;
-	
-}
-
 /** Makes the output report buffer for data given in the report structure
  *
@@ -385,59 +333,60 @@
 		report_item = list_get_instance(item, usb_hid_report_field_t, link);
 
-			if(USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags) == 0) {
+		usb_log_debug("OUTPUT ITEM usage(%x), value(%x)\n", report_item->usage, report_item->value);
+		
+		if(USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags) == 0) {
 					
-				// array
-				value = usb_hid_translate_data_reverse(report_item, report_item->value);
-				offset = report_item->offset;
-				length = report_item->size;
-			}
-			else {
-				// variable item
-				value  = usb_hid_translate_data_reverse(report_item, report_item->value);
-				offset = report_item->offset;
-				length = report_item->size;
-			}
-
-			if((offset/8) == ((offset+length-1)/8)) {
-				// je to v jednom bytu
-				if(((size_t)(offset/8) >= size) || ((size_t)(offset+length-1)/8) >= size) {
-					break; // TODO ErrorCode
+			// array
+			value = usb_hid_translate_data_reverse(report_item, report_item->value);
+			offset = report_item->offset;
+			length = report_item->size;
+		}
+		else {
+			// variable item
+			value  = usb_hid_translate_data_reverse(report_item, report_item->value);
+			offset = report_item->offset;
+			length = report_item->size;
+		}
+
+		usb_log_debug("\ttranslated value: %x\n", value);
+
+		if((offset/8) == ((offset+length-1)/8)) {
+			// je to v jednom bytu
+			if(((size_t)(offset/8) >= size) || ((size_t)(offset+length-1)/8) >= size) {
+				break; // TODO ErrorCode
+			}
+			size_t shift = 8 - offset%8 - length;
+			value = value << shift;							
+			value = value & (((1 << length)-1) << shift);
+				
+			uint8_t mask = 0;
+			mask = 0xff - (((1 << length) - 1) << shift);
+			buffer[offset/8] = (buffer[offset/8] & mask) | value;
+		}
+		else {
+			int i = 0;
+			uint8_t mask = 0;
+			for(i = (offset/8); i <= ((offset+length-1)/8); i++) {
+				if(i == (offset/8)) {
+					tmp_value = value;
+					tmp_value = tmp_value & ((1 << (8-(offset%8)))-1);				
+					tmp_value = tmp_value << (offset%8);
+	
+					mask = ~(((1 << (8-(offset%8)))-1) << (offset%8));
+					buffer[i] = (buffer[i] & mask) | tmp_value;			
 				}
-
-				size_t shift = 8 - offset%8 - length;
-
-				value = value << shift;							
-				value = value & (((1 << length)-1) << shift);
+				else if (i == ((offset + length -1)/8)) {
+					
+					value = value >> (length - ((offset + length) % 8));
+					value = value & ((1 << (length - ((offset + length) % 8))) - 1);
 				
-				uint8_t mask = 0;
-				mask = 0xff - (((1 << length) - 1) << shift);
-				buffer[offset/8] = (buffer[offset/8] & mask) | value;
-			}
-			else {
-				int i = 0;
-				uint8_t mask = 0;
-				for(i = (offset/8); i <= ((offset+length-1)/8); i++) {
-					if(i == (offset/8)) {
-						tmp_value = value;
-						tmp_value = tmp_value & ((1 << (8-(offset%8)))-1);				
-						tmp_value = tmp_value << (offset%8);
-	
-						mask = ~(((1 << (8-(offset%8)))-1) << (offset%8));
-						buffer[i] = (buffer[i] & mask) | tmp_value;			
-					}
-					else if (i == ((offset + length -1)/8)) {
-						
-						value = value >> (length - ((offset + length) % 8));
-						value = value & ((1 << (length - ((offset + length) % 8))) - 1);
-				
-						mask = (1 << (length - ((offset + length) % 8))) - 1;
-						buffer[i] = (buffer[i] & mask) | value;
-					}
-					else {
-						buffer[i] = value & (0xFF << i);
-					}
+					mask = (1 << (length - ((offset + length) % 8))) - 1;
+					buffer[i] = (buffer[i] & mask) | value;
 				}
-			}
-
+				else {
+					buffer[i] = value & (0xFF << i);
+				}
+			}
+		}
 
 		// reset value
@@ -472,34 +421,21 @@
 	}
 	
-
-	if((USB_HID_ITEM_FLAG_VARIABLE(item->item_flags) == 0)) {
-
-		// variable item
-		if(item->physical_maximum == item->physical_minimum){
-		    resolution = 1;
-		}
-		else {
-		    resolution = (item->logical_maximum - item->logical_minimum) /
-			((item->physical_maximum - item->physical_minimum) *
-			(usb_pow(10,(item->unit_exponent))));
-		}
-
-		ret = ((value - item->physical_minimum) * resolution) + item->logical_minimum;
-	}
-	else {
-		// bitmapa
-		if(value == 0) {
-			ret = 0;
-		}
-		else {
-			size_t bitmap_idx = (value - item->usage_minimum);
-			ret = 1 << bitmap_idx;
-		}
-	}
-
+	// variable item
+	if(item->physical_maximum == item->physical_minimum){
+	    resolution = 1;
+	}
+	else {
+	    resolution = (item->logical_maximum - item->logical_minimum) /
+		((item->physical_maximum - item->physical_minimum) *
+		(usb_pow(10,(item->unit_exponent))));
+	}
+
+	ret = ((value - item->physical_minimum) * resolution) + item->logical_minimum;
+	usb_log_debug("\tvalue(%x), resolution(%x), phymin(%x) logmin(%x), ret(%x)\n", value, resolution, item->physical_minimum, item->logical_minimum, ret);
+	
 	if((item->logical_minimum < 0) || (item->logical_maximum < 0)){
 		return USB_HID_INT32_TO_UINT32(ret, item->size);
 	}
-	return (int32_t)ret;
+	return (int32_t)0 + ret;
 }
 
Index: uspace/lib/usbhid/src/hidpath.c
===================================================================
--- uspace/lib/usbhid/src/hidpath.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbhid/src/hidpath.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbhid
  * @{
  */
@@ -33,5 +33,5 @@
  * HID report descriptor and report data parser implementation.
  */
-#include <usb/classes/hidparser.h>
+#include <usb/hid/hidparser.h>
 #include <errno.h>
 #include <stdio.h>
@@ -41,4 +41,7 @@
 #include <assert.h>
 
+
+#define USB_HID_SAME_USAGE(usage1, usage2)	((usage1 == usage2) || (usage1 == 0) || (usage2 == 0))
+#define USB_HID_SAME_USAGE_PAGE(page1, page2)	((page1 == page2) || (page1 == 0) || (page2 == 0))
 
 /**
@@ -203,7 +206,7 @@
 			while(report_link != &report_path->head) {
 				report_item = list_get_instance(report_link, usb_hid_report_usage_path_t, link);
-				if(report_item->usage_page == path_item->usage_page){
+				if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page, path_item->usage_page)){
 					if(only_page == 0){
-						if(report_item->usage == path_item->usage) {
+						if(USB_HID_SAME_USAGE(report_item->usage, path_item->usage)) {
 							return EOK;
 						}
@@ -242,7 +245,7 @@
 					                              link);		
 
-					if((report_item->usage_page != path_item->usage_page) || 
+					if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, path_item->usage_page) || 
 					   ((only_page == 0) && 
-					    (report_item->usage != path_item->usage))) {
+					    !USB_HID_SAME_USAGE(report_item->usage, path_item->usage))) {
 							
 						   return 1;
@@ -282,9 +285,9 @@
 					                              usb_hid_report_usage_path_t, 
 					                              link);		
-
-					if((report_item->usage_page != path_item->usage_page) || 
+						  
+					if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, path_item->usage_page) || 
 					   ((only_page == 0) && 
-					    (report_item->usage != path_item->usage))) {
-						   return 1;
+					    !USB_HID_SAME_USAGE(report_item->usage, path_item->usage))) {
+							return 1;
 					} else {
 						report_link = report_link->prev;
Index: uspace/lib/usbhid/src/hidreport.c
===================================================================
--- uspace/lib/usbhid/src/hidreport.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbhid/src/hidreport.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbhid
  * @{
  */
@@ -40,13 +40,13 @@
 
 #include <usb/debug.h>
-#include <usb/classes/hidparser.h>
-#include <usb/dp.h>
-#include <usb/devdrv.h>
-#include <usb/pipes.h>
-#include <usb/classes/hid.h>
+#include <usb/hid/hidparser.h>
+#include <usb/dev/dp.h>
+#include <usb/dev/driver.h>
+#include <usb/dev/pipes.h>
+#include <usb/hid/hid.h>
 #include <usb/descriptor.h>
-#include <usb/request.h>
-
-#include <usb/classes/hidreport.h>
+#include <usb/dev/request.h>
+
+#include <usb/hid/hidreport.h>
 
 static int usb_hid_get_report_descriptor(usb_device_t *dev, 
Index: uspace/lib/usbhid/src/hidreq.c
===================================================================
--- uspace/lib/usbhid/src/hidreq.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbhid/src/hidreq.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -38,10 +38,10 @@
 #include <str_error.h>
 
-#include <usb/classes/hid.h>
+#include <usb/hid/hid.h>
 #include <usb/debug.h>
-#include <usb/request.h>
-#include <usb/pipes.h>
-
-#include <usb/classes/hidreq.h>
+#include <usb/dev/request.h>
+#include <usb/dev/pipes.h>
+
+#include <usb/hid/request.h>
 
 /*----------------------------------------------------------------------------*/
Index: uspace/lib/usbhost/Makefile
===================================================================
--- uspace/lib/usbhost/Makefile	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbhost/Makefile	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -35,5 +35,4 @@
 
 SOURCES = \
-	src/addrkeep.c \
 	src/batch.c \
 	src/device_keeper.c \
Index: pace/lib/usbhost/include/usb/addrkeep.h
===================================================================
--- uspace/lib/usbhost/include/usb/addrkeep.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,86 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * USB address keeping for host controller drivers.
- */
-#ifndef LIBUSB_ADDRKEEP_H_
-#define LIBUSB_ADDRKEEP_H_
-
-#include <usb/usb.h>
-#include <fibril_synch.h>
-#include <devman.h>
-
-/** Info about used address. */
-typedef struct {
-	/** Linked list member. */
-	link_t link;
-	/** Address. */
-	usb_address_t address;
-	/** Corresponding devman handle. */
-	devman_handle_t devman_handle;
-} usb_address_keeping_used_t;
-
-/** Structure for keeping track of free and used USB addresses. */
-typedef struct {
-	/** Head of list of used addresses. */
-	link_t used_addresses;
-	/** Upper bound for USB addresses. */
-	usb_address_t max_address;
-	/** Mutex protecting used address. */
-	fibril_mutex_t used_addresses_guard;
-	/** Condition variable for used addresses. */
-	fibril_condvar_t used_addresses_condvar;
-
-	/** Condition variable mutex for default address. */
-	fibril_mutex_t default_condvar_guard;
-	/** Condition variable for default address. */
-	fibril_condvar_t default_condvar;
-	/** Whether is default address available. */
-	bool default_available;
-} usb_address_keeping_t;
-
-void usb_address_keeping_init(usb_address_keeping_t *, usb_address_t);
-
-void usb_address_keeping_reserve_default(usb_address_keeping_t *);
-void usb_address_keeping_release_default(usb_address_keeping_t *);
-
-usb_address_t usb_address_keeping_request(usb_address_keeping_t *);
-int usb_address_keeping_release(usb_address_keeping_t *, usb_address_t);
-void usb_address_keeping_devman_bind(usb_address_keeping_t *, usb_address_t,
-    devman_handle_t);
-usb_address_t usb_address_keeping_find(usb_address_keeping_t *,
-    devman_handle_t);
-
-#endif
-/**
- * @}
- */
Index: uspace/lib/usbhost/include/usb/host/batch.h
===================================================================
--- uspace/lib/usbhost/include/usb/host/batch.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbhost/include/usb/host/batch.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -26,5 +26,5 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/** @addtogroup libusb
+/** @addtogroup libusbhost
  * @{
  */
@@ -32,6 +32,6 @@
  * USB transfer transaction structures.
  */
-#ifndef LIBUSB_HOST_BATCH_H
-#define LIBUSB_HOST_BATCH_H
+#ifndef LIBUSBHOST_HOST_BATCH_H
+#define LIBUSBHOST_HOST_BATCH_H
 
 #include <adt/list.h>
Index: uspace/lib/usbhost/include/usb/host/device_keeper.h
===================================================================
--- uspace/lib/usbhost/include/usb/host/device_keeper.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbhost/include/usb/host/device_keeper.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbhost
  * @{
  */
@@ -38,6 +38,6 @@
  * This structure shall simplify the management.
  */
-#ifndef LIBUSB_HOST_DEVICE_KEEPER_H
-#define LIBUSB_HOST_DEVICE_KEEPER_H
+#ifndef LIBUSBHOST_HOST_DEVICE_KEEPER_H
+#define LIBUSBHOST_HOST_DEVICE_KEEPER_H
 
 #include <adt/list.h>
Index: uspace/lib/usbhost/include/usb/host/endpoint.h
===================================================================
--- uspace/lib/usbhost/include/usb/host/endpoint.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbhost/include/usb/host/endpoint.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbhost
  * @{
  */
@@ -33,6 +33,6 @@
  *
  */
-#ifndef LIBUSB_HOST_ENDPOINT_H
-#define LIBUSB_HOST_ENDPOINT_H
+#ifndef LIBUSBHOST_HOST_ENDPOINT_H
+#define LIBUSBHOST_HOST_ENDPOINT_H
 
 #include <assert.h>
Index: uspace/lib/usbhost/include/usb/host/usb_endpoint_manager.h
===================================================================
--- uspace/lib/usbhost/include/usb/host/usb_endpoint_manager.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbhost/include/usb/host/usb_endpoint_manager.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -26,5 +26,5 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/** @addtogroup libusb
+/** @addtogroup libusbhost
  * @{
  */
@@ -37,6 +37,6 @@
  * This structure shall simplify the management.
  */
-#ifndef LIBUSB_HOST_USB_ENDPOINT_MANAGER_H
-#define LIBUSB_HOST_YSB_ENDPOINT_MANAGER_H
+#ifndef LIBUSBHOST_HOST_USB_ENDPOINT_MANAGER_H
+#define LIBUSBHOST_HOST_YSB_ENDPOINT_MANAGER_H
 
 #include <stdlib.h>
Index: pace/lib/usbhost/src/addrkeep.c
===================================================================
--- uspace/lib/usbhost/src/addrkeep.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ 	(revision )
@@ -1,347 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * @brief Address keeping.
- */
-#include <usb/addrkeep.h>
-#include <errno.h>
-#include <assert.h>
-
-/** For loop over all used addresses in address keeping.
- *
- * @param link Iterator.
- * @param addresses Addresses keeping structure to iterate.
- */
-#define for_all_used_addresses(link, addresses) \
-	for (link = (addresses)->used_addresses.next; \
-	    link != &(addresses)->used_addresses; \
-	    link = link->next)
-
-/** Get instance of usb_address_keeping_used_t. */
-#define used_address_get_instance(lnk) \
-	list_get_instance(lnk, usb_address_keeping_used_t, link)
-
-/** Invalid value of devman handle. */
-#define INVALID_DEVMAN_HANDLE \
-	((devman_handle_t)-1)
-
-/** Creates structure for used USB address.
- *
- * @param address USB address.
- * @return Initialized structure.
- * @retval NULL Out of memory.
- */
-static usb_address_keeping_used_t *usb_address_keeping_used_create(
-    usb_address_t address)
-{
-	usb_address_keeping_used_t *info
-	    = malloc(sizeof(usb_address_keeping_used_t));
-	if (info == NULL) {
-		return NULL;
-	}
-
-	info->address = address;
-	info->devman_handle = INVALID_DEVMAN_HANDLE;
-	list_initialize(&info->link);
-	return info;
-}
-
-/** Destroys structure for used USB address.
- *
- * @param info Structure to be destroyed.
- */
-static void usb_address_keeping_used_destroy(usb_address_keeping_used_t *info)
-{
-	free(info);
-}
-
-/** Find used USB address structure by USB address.
- *
- * It is expected that guard mutex is already locked.
- *
- * @param addresses Address keeping info.
- * @param address Address to be found.
- * @return Structure describing looked for address.
- * @retval NULL Address not found.
- */
-static usb_address_keeping_used_t *usb_address_keeping_used_find_no_lock(
-    usb_address_keeping_t *addresses, usb_address_t address)
-{
-	link_t *link;
-	for_all_used_addresses(link, addresses) {
-		usb_address_keeping_used_t *info
-		    = used_address_get_instance(link);
-
-		if (info->address == address) {
-			return info;
-		}
-	}
-
-	return NULL;
-}
-
-/** Initialize address keeping structure.
- *
- * @param addresses Address keeping info.
- * @param max_address Maximum USB address (exclusive bound).
- */
-void usb_address_keeping_init(usb_address_keeping_t *addresses,
-    usb_address_t max_address)
-{
-	/*
-	 * Items related with used addresses.
-	 */
-	addresses->max_address = max_address;
-	list_initialize(&addresses->used_addresses);
-	fibril_mutex_initialize(&addresses->used_addresses_guard);
-	fibril_condvar_initialize(&addresses->used_addresses_condvar);
-
-	/*
-	 * Items related with default address.
-	 */
-	addresses->default_available = true;
-	fibril_condvar_initialize(&addresses->default_condvar);
-	fibril_mutex_initialize(&addresses->default_condvar_guard);
-}
-
-/** Reserved default USB address.
- *
- * This function blocks until reserved address is available.
- *
- * @see usb_address_keeping_release_default
- *
- * @param addresses Address keeping info.
- */
-void usb_address_keeping_reserve_default(usb_address_keeping_t *addresses)
-{
-	fibril_mutex_lock(&addresses->default_condvar_guard);
-	while (!addresses->default_available) {
-		fibril_condvar_wait(&addresses->default_condvar,
-			&addresses->default_condvar_guard);
-	}
-	addresses->default_available = false;
-	fibril_mutex_unlock(&addresses->default_condvar_guard);
-}
-
-/** Releases default USB address.
- *
- * @see usb_address_keeping_reserve_default
- *
- * @param addresses Address keeping info.
- */
-void usb_address_keeping_release_default(usb_address_keeping_t *addresses)
-{
-	fibril_mutex_lock(&addresses->default_condvar_guard);
-	addresses->default_available = true;
-	fibril_condvar_signal(&addresses->default_condvar);
-	fibril_mutex_unlock(&addresses->default_condvar_guard);
-}
-
-/** Request free address assignment.
- *
- * This function does not block when there are not free addresses to be
- * assigned.
- *
- * @param addresses Address keeping info.
- * @return USB address that could be used or negative error code.
- * @retval ELIMIT No more addresses to assign.
- * @retval ENOMEM Out of memory.
- */
-usb_address_t usb_address_keeping_request(usb_address_keeping_t *addresses)
-{
-	usb_address_t previous_address = 0;
-	usb_address_t free_address = 0;
-
-	fibril_mutex_lock(&addresses->used_addresses_guard);
-	link_t *new_address_position;
-	if (list_empty(&addresses->used_addresses)) {
-		free_address = 1;
-		new_address_position = addresses->used_addresses.next;
-	} else {
-		usb_address_keeping_used_t *first
-		    = used_address_get_instance(addresses->used_addresses.next);
-		previous_address = first->address;
-		
-		for_all_used_addresses(new_address_position, addresses) {
-			usb_address_keeping_used_t *info
-			    = used_address_get_instance(new_address_position);
-			if (info->address > previous_address + 1) {
-				free_address = previous_address + 1;
-				break;
-			}
-			previous_address = info->address;
-		}
-
-		if (free_address == 0) {
-			usb_address_keeping_used_t *last
-			    = used_address_get_instance(addresses->used_addresses.next);
-			free_address = last->address + 1;
-		}
-	}
-
-	if (free_address >= addresses->max_address) {
-		free_address = ELIMIT;
-		goto leave;
-	}
-
-	usb_address_keeping_used_t *used
-	    = usb_address_keeping_used_create(free_address);
-	if (used == NULL) {
-		free_address = ENOMEM;
-		goto leave;
-	}
-
-	list_prepend(&used->link, new_address_position);
-
-leave:
-	fibril_mutex_unlock(&addresses->used_addresses_guard);
-
-	return free_address;
-}
-
-/** Release USB address.
- *
- * @param addresses Address keeping info.
- * @param address Address to be released.
- * @return Error code.
- * @retval ENOENT Address is not in use.
- */
-int usb_address_keeping_release(usb_address_keeping_t *addresses,
-    usb_address_t address)
-{
-	int rc = ENOENT;
-
-	fibril_mutex_lock(&addresses->used_addresses_guard);
-
-	usb_address_keeping_used_t *info
-	    = usb_address_keeping_used_find_no_lock(addresses, address);
-
-	if (info != NULL) {
-		rc = EOK;
-		list_remove(&info->link);
-		usb_address_keeping_used_destroy(info);
-	}
-
-	fibril_mutex_unlock(&addresses->used_addresses_guard);
-
-	return rc;
-}
-
-/** Bind devman handle with USB address.
- *
- * When the @p address is invalid (e.g. no such entry), the request
- * is silently ignored.
- *
- * @param addresses Address keeping info.
- * @param address USB address.
- * @param handle Devman handle.
- */
-void usb_address_keeping_devman_bind(usb_address_keeping_t *addresses,
-    usb_address_t address, devman_handle_t handle)
-{
-	fibril_mutex_lock(&addresses->used_addresses_guard);
-
-	usb_address_keeping_used_t *info
-	    = usb_address_keeping_used_find_no_lock(addresses, address);
-	if (info == NULL) {
-		goto leave;
-	}
-
-	assert(info->address == address);
-	info->devman_handle = handle;
-
-	/*
-	 * Inform that new handle was added.
-	 */
-	fibril_condvar_broadcast(&addresses->used_addresses_condvar);
-
-leave:
-	fibril_mutex_unlock(&addresses->used_addresses_guard);
-}
-
-/** Find address by its devman handle.
- *
- * @param addresses Address keeping info.
- * @param handle Devman handle.
- * @return USB address or negative error code.
- * @retval ENOENT No such address.
- */
-static usb_address_t usb_address_keeping_find_no_lock(
-    usb_address_keeping_t *addresses, devman_handle_t handle)
-{
-	usb_address_t address = ENOENT;
-
-	link_t *link;
-	for_all_used_addresses(link, addresses) {
-		usb_address_keeping_used_t *info
-		    = used_address_get_instance(link);
-
-		if (info->devman_handle == handle) {
-			address = info->address;
-			break;
-		}
-	}
-
-	return address;
-}
-
-/** Find USB address by its devman handle.
- *
- * This function blocks until corresponding address is found.
- *
- * @param addresses Address keeping info.
- * @param handle Devman handle.
- * @return USB address or negative error code.
- */
-usb_address_t usb_address_keeping_find(usb_address_keeping_t *addresses,
-    devman_handle_t handle)
-{
-	usb_address_t address = ENOENT;
-
-	fibril_mutex_lock(&addresses->used_addresses_guard);
-	while (true) {
-		address = usb_address_keeping_find_no_lock(addresses, handle);
-		if (address != ENOENT) {
-			break;
-		}
-		fibril_condvar_wait(&addresses->used_addresses_condvar,
-		    &addresses->used_addresses_guard);
-	}
-
-	fibril_mutex_unlock(&addresses->used_addresses_guard);
-
-	return address;
-}
-
-/**
- * @}
- */
Index: uspace/lib/usbhost/src/batch.c
===================================================================
--- uspace/lib/usbhost/src/batch.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbhost/src/batch.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -26,5 +26,5 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/** @addtogroup libusb
+/** @addtogroup libusbhost
  * @{
  */
Index: uspace/lib/usbhost/src/device_keeper.c
===================================================================
--- uspace/lib/usbhost/src/device_keeper.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbhost/src/device_keeper.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusb
+/** @addtogroup libusbhost
  * @{
  */
Index: uspace/lib/usbvirt/include/usbvirt/device.h
===================================================================
--- uspace/lib/usbvirt/include/usbvirt/device.h	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbvirt/include/usbvirt/device.h	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -37,5 +37,5 @@
 
 #include <usb/usb.h>
-#include <usb/request.h>
+#include <usb/dev/request.h>
 
 /** Maximum number of endpoints supported by virtual USB. */
Index: uspace/lib/usbvirt/src/ctrltransfer.c
===================================================================
--- uspace/lib/usbvirt/src/ctrltransfer.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbvirt/src/ctrltransfer.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -34,5 +34,5 @@
  */
 #include "private.h"
-#include <usb/request.h>
+#include <usb/dev/request.h>
 #include <usb/debug.h>
 #include <assert.h>
Index: uspace/lib/usbvirt/src/stdreq.c
===================================================================
--- uspace/lib/usbvirt/src/stdreq.c	(revision d736fe38a9f7781f4f215851ebdd9bb698510061)
+++ uspace/lib/usbvirt/src/stdreq.c	(revision c7b582620681e6a7655a2fe435df4bb9bbac4977)
@@ -34,5 +34,5 @@
  */
 #include "private.h"
-#include <usb/request.h>
+#include <usb/dev/request.h>
 #include <assert.h>
 #include <errno.h>
