Index: uspace/lib/usb/include/usb/classes/hidparser.h
===================================================================
--- uspace/lib/usb/include/usb/classes/hidparser.h	(revision 9c0f158ec9d9a5b5e8917c8e5ed621caa6528a3f)
+++ uspace/lib/usb/include/usb/classes/hidparser.h	(revision 57d9c05edc9538826f5cee0e24dd67049c5a02b9)
@@ -31,5 +31,5 @@
  */
 /** @file
- * @brief USB HID parser.
+ * USB HID report descriptor and report data parser
  */
 #ifndef LIBUSB_HIDPARSER_H_
@@ -74,13 +74,20 @@
 #define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY	4
 
+/** */
 typedef struct {
+	/** */
 	int32_t usage_page;
+	/** */	
 	int32_t usage;
-
+	/** */
 	link_t link;
 } usb_hid_report_usage_path_t;
 
+/** */
 typedef struct {
+	/** */	
 	int depth;	
+	
+	/** */	
 	link_t link;
 } usb_hid_report_path_t;
@@ -90,32 +97,50 @@
  */
 typedef struct {
+	/** */	
 	int32_t id;
+	/** */	
 	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 delimiter;
-
+	/** */	
 	int32_t unit_exponent;
+	/** */	
 	int32_t unit;
 
-	/*
-	 * some not yet used fields
-	 */
+	/** */
 	int32_t string_index;
+	/** */	
 	int32_t string_minimum;
+	/** */	
 	int32_t string_maximum;
+	/** */	
 	int32_t designator_index;
+	/** */	
 	int32_t designator_minimum;
+	/** */	
 	int32_t designator_maximum;
+	/** */	
 	int32_t physical_minimum;
+	/** */	
 	int32_t physical_maximum;
 
+	/** */	
 	uint8_t item_flags;
 
+	/** */	
 	usb_hid_report_path_t *usage_path;
+	/** */	
 	link_t link;
 } usb_hid_report_item_t;
@@ -124,6 +149,9 @@
 /** HID report parser structure. */
 typedef struct {	
+	/** */	
 	link_t input;
+	/** */	
 	link_t output;
+	/** */	
 	link_t feature;
 } usb_hid_report_parser_t;	
@@ -190,16 +218,34 @@
 
 /*
- * modifiers definitions
- */
-
+ * Descriptor parser functions
+ */
+/** */
+int usb_hid_parser_init(usb_hid_report_parser_t *parser);
+
+/** */
+int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser, 
+    const uint8_t *data, size_t size);
+
+/** */
+void usb_hid_free_report_parser(usb_hid_report_parser_t *parser);
+
+/** */
+void usb_hid_descriptor_print(usb_hid_report_parser_t *parser);
+
+/*
+ * Boot protocol functions
+ */
+/** */
 int usb_hid_boot_keyboard_input_report(const uint8_t *data, size_t size,
 	const usb_hid_report_in_callbacks_t *callbacks, void *arg);
 
+/** */
 int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size);
 
-int usb_hid_parser_init(usb_hid_report_parser_t *parser);
-int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser, 
-    const uint8_t *data, size_t size);
-
+
+/*
+ * Input report parser functions
+ */
+/** */
 int usb_hid_parse_report(const usb_hid_report_parser_t *parser,  
     const uint8_t *data, size_t size,
@@ -207,26 +253,44 @@
     const usb_hid_report_in_callbacks_t *callbacks, void *arg);
 
+/** */
 size_t usb_hid_report_input_length(const usb_hid_report_parser_t *parser,
 	usb_hid_report_path_t *path, int flags);
 
 
-void usb_hid_free_report_parser(usb_hid_report_parser_t *parser);
-
-void usb_hid_descriptor_print(usb_hid_report_parser_t *parser);
-
-/* usage path functions */
+
+/* 
+ * usage path functions 
+ */
+/** */
 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_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);
 
 
-// output API
+/*
+ * Output report parser functions
+ */
 /** Allocates output report buffer*/
 uint8_t *usb_hid_report_output(usb_hid_report_parser_t *parser);
+
 /** Frees output report buffer*/
 void usb_hid_report_output_free(uint8_t *output);
@@ -235,4 +299,5 @@
 size_t usb_hid_report_output_size(usb_hid_report_parser_t *parser,
                                   usb_hid_report_path_t *path, int flags);
+
 /** Updates the output report buffer by translated given data */
 int usb_hid_report_output_translate(usb_hid_report_parser_t *parser,
Index: uspace/lib/usb/src/hidparser.c
===================================================================
--- uspace/lib/usb/src/hidparser.c	(revision 9c0f158ec9d9a5b5e8917c8e5ed621caa6528a3f)
+++ uspace/lib/usb/src/hidparser.c	(revision 57d9c05edc9538826f5cee0e24dd67049c5a02b9)
@@ -31,5 +31,5 @@
  */
 /** @file
- * @brief HID parser implementation.
+ * HID report descriptor and report data parser implementation.
  */
 #include <usb/classes/hidparser.h>
@@ -40,10 +40,16 @@
 #include <usb/debug.h>
 
+/** */
 #define USB_HID_NEW_REPORT_ITEM 1
+
+/** */
 #define USB_HID_NO_ACTION		2
+
+/** */
 #define USB_HID_UNKNOWN_TAG		-99
 
-#define BAD_HACK_USAGE_PAGE		0x07
-
+/*
+ * Private descriptor parser functions
+ */
 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);
@@ -58,4 +64,8 @@
 int usb_hid_report_reset_local_items();
 void usb_hid_free_report_list(link_t *head);
+
+/*
+ * Data translation private functions
+ */
 int32_t usb_hid_report_tag_data_int32(const uint8_t *data, size_t size);
 inline size_t usb_hid_count_item_offset(usb_hid_report_item_t * report_item, size_t offset);
@@ -63,5 +73,5 @@
 int usb_pow(int a, int b);
 
-
+// TODO: tohle ma bejt asi jinde
 int usb_pow(int a, int b)
 {
@@ -80,13 +90,16 @@
 
 /**
- *
+ * Initialize the report descriptor parser structure
+ *
+ * @param parser Report descriptor parser structure
+ * @return Error code
  */
 int usb_hid_parser_init(usb_hid_report_parser_t *parser)
 {
-   if(parser == NULL) {
-	return EINVAL;
-   }
-
-    list_initialize(&(parser->input));
+	if(parser == NULL) {
+		return EINVAL;
+	}
+
+	list_initialize(&(parser->input));
     list_initialize(&(parser->output));
     list_initialize(&(parser->feature));
@@ -301,4 +314,5 @@
 
 /**
+ * Parse one tag of the report descriptor
  *
  * @param Tag to parse
@@ -517,5 +531,5 @@
  * Prints content of given list of report items.
  *
- * @param List of report items
+ * @param List of report items (usb_hid_report_item_t)
  * @return void
  */
@@ -549,8 +563,5 @@
 			path = path->next;
 		}
-		
-		
-//		usb_log_debug("\tUSAGE: %X\n", report_item->usage);
-//		usb_log_debug("\tUSAGE PAGE: %X\n", report_item->usage_page);
+				
 		usb_log_debug("\tLOGMIN: %X\n", report_item->logical_minimum);
 		usb_log_debug("\tLOGMAX: %X\n", report_item->logical_maximum);		
@@ -567,7 +578,7 @@
 }
 /**
- * Prints content of given descriptor in human readable format.
- *
- * @param Parsed descriptor to print
+ * Prints content of given report descriptor in human readable format.
+ *
+ * @param parser Parsed descriptor to print
  * @return void
  */
@@ -592,5 +603,6 @@
  * Releases whole linked list of report items
  *
- * 
+ * @param head Head of list of report descriptor items (usb_hid_report_item_t)
+ * @return void
  */
 void usb_hid_free_report_list(link_t *head)
@@ -624,8 +636,8 @@
 }
 
-/** Free the HID report parser structure 
+/** Frees the HID report descriptor parser structure 
  *
  * @param parser Opaque HID report parser structure
- * @return Error code
+ * @return void
  */
 void usb_hid_free_report_parser(usb_hid_report_parser_t *parser)
@@ -657,9 +669,4 @@
     const usb_hid_report_in_callbacks_t *callbacks, void *arg)
 {
-	/*
-	 *
-	 * only key codes (usage page 0x07) will be processed
-	 * other usages will be ignored 
-	 */
 	link_t *list_item;
 	usb_hid_report_item_t *item;
@@ -673,7 +680,6 @@
 		return EINVAL;
 	}
-
-	
-	// get the size of result keycodes array
+	
+	/* get the size of result array */
 	key_count = usb_hid_report_input_length(parser, path, flags);
 
@@ -682,5 +688,5 @@
 	}
 
-	// read data		
+	/* read data */
 	list_item = parser->input.next;	   
 	while(list_item != &(parser->input)) {
@@ -716,5 +722,12 @@
 }
 
-
+/**
+ * Translate data from the report as specified in report descriptor
+ *
+ * @param item Report descriptor item with definition of translation
+ * @param data Data to translate
+ * @param j Index of processed field in report descriptor item
+ * @return Translated data
+ */
 int usb_hid_translate_data(usb_hid_report_item_t *item, const uint8_t *data, size_t j)
 {
@@ -793,16 +806,24 @@
 }
 
+/**
+ *
+ *
+ * @param parser
+ * @param path
+ * @param flags
+ * @return
+ */
 size_t usb_hid_report_input_length(const usb_hid_report_parser_t *parser,
 	usb_hid_report_path_t *path, int flags)
 {	
-	int ret = 0;
+	size_t ret = 0;
 	link_t *item;
 	usb_hid_report_item_t *report_item;
 
 	if(parser == NULL) {
-		return EINVAL;
-	}
-	
-	item = (&parser->input)->next;
+		return 0;
+	}
+	
+	item = parser->input.next;
 	while(&parser->input != item) {
 		report_item = list_get_instance(item, usb_hid_report_item_t, link);
@@ -821,4 +842,8 @@
 /**
  * 
+ * @param usage_path
+ * @param usage_page
+ * @param usage
+ * @return
  */
 int usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, 
@@ -842,4 +867,6 @@
 /**
  *
+ * @param usage_path
+ * @return
  */
 void usb_hid_report_remove_last_item(usb_hid_report_path_t *usage_path)
@@ -857,4 +884,6 @@
 /**
  *
+ * @param usage_path
+ * @return
  */
 void usb_hid_report_null_last_item(usb_hid_report_path_t *usage_path)
@@ -870,4 +899,8 @@
 /**
  *
+ * @param usage_path
+ * @param tag
+ * @param data
+ * @return
  */
 void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path, int32_t tag, int32_t data)
@@ -891,5 +924,10 @@
 
 /**
- *
+ * 
+ *
+ * @param report_path
+ * @param path
+ * @param flags
+ * @return
  */
 int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path, 
@@ -989,4 +1027,5 @@
 /**
  *
+ * @return
  */
 usb_hid_report_path_t *usb_hid_report_path(void)
@@ -1006,4 +1045,6 @@
 /**
  *
+ * @param path
+ * @return void
  */
 void usb_hid_report_path_free(usb_hid_report_path_t *path)
@@ -1018,4 +1059,6 @@
  * Clone content of given usage path to the new one
  *
+ * @param usage_path
+ * @return
  */
 usb_hid_report_path_t *usb_hid_report_path_clone(usb_hid_report_path_t *usage_path)
@@ -1045,4 +1088,147 @@
 
 
+/*** OUTPUT API **/
+
+/** Allocates output report buffer
+ *
+ * @param parser
+ * @param size
+ * @return
+ */
+uint8_t *usb_hid_report_output(usb_hid_report_parser_t *parser, size_t *size)
+{
+	if(parser == NULL) {
+		*size = 0;
+		return NULL;
+	}
+	
+	// read the last outpu report item
+	usb_hid_report_item_t *last;
+	link_t *link;
+
+	link = parser->output.prev;
+	if(link != &parser->output) {
+		last = list_get_instance(link, usb_hid_report_item_t, link);
+		*size = (last->offset + (last->size * last->count)) / 8;
+
+		uint8_t *buffer = malloc(sizeof(uint8_t) * (*size));
+		return buffer;
+	}
+	else {
+		*size = 0;		
+		return NULL;
+	}
+}
+
+
+/** Frees output report buffer
+ *
+ * @param output Output report buffer
+ * @return
+ */
+void usb_hid_report_output_free(uint8_t *output)
+{
+	if(output != NULL) {
+		free (output);
+	}
+}
+
+/** Returns size of output for given usage path 
+ *
+ * @param parser
+ * @param path
+ * @param flags
+ * @return
+ */
+size_t usb_hid_report_output_size(usb_hid_report_parser_t *parser,
+                                  usb_hid_report_path_t *path, int flags)
+{
+	size_t ret = 0;
+	link_t *item;
+	usb_hid_report_item_t *report_item;
+
+	if(parser == NULL) {
+		return 0;
+	}
+	
+	item = parser->output.next;
+	while(&parser->input != item) {
+		report_item = list_get_instance(item, usb_hid_report_item_t, link);
+		if(!USB_HID_ITEM_FLAG_CONSTANT(report_item->item_flags) &&
+		   (usb_hid_report_compare_usage_path(report_item->usage_path, path, flags) == EOK)) {
+			ret += report_item->count;
+		}
+
+		item = item->next;
+	} 
+
+	return ret;
+	
+}
+
+/** Updates the output report buffer by translated given data 
+ *
+ * @param parser
+ * @param path
+ * @param flags
+ * @param buffer
+ * @param size
+ * @param data
+ * @param data_size
+ * @return
+ */
+int usb_hid_report_output_translate(usb_hid_report_parser_t *parser,
+                                    usb_hid_report_path_t *path, int flags,
+                                    uint8_t *buffer, size_t size,
+                                    int32_t *data, size_t data_size)
+{
+	//TODO
+	//
+	//go throught output descriptor and 
+	// if path match then take data from the begin, translate them and
+	// or to the buffer
+	//
+	// it should be the reverse process to input translation
+	
+	usb_hid_report_item_t *report_item;
+	link_t *item;	
+	size_t idx=0;
+	int i=0;
+	int32_t field_value=0;
+	int32_t value=0;
+	int8_t mask;
+	int8_t offset;
+	
+	if(parser == NULL) {
+		return EINVAL;
+	}
+
+	item = parser->output.next;	
+	while(item != &parser->output) {
+		report_item = list_get_instance(item, usb_hid_report_item_t ,link);
+
+		if(idx > size) {
+			return EINVAL;
+		}
+
+		for(i=0; i<report_item->count; i++, idx++) {
+			// translate data
+			value = usb_hid_translate_data_output(report_item, data[idx]);
+
+			// pres kazdy byte v bufferu kteryho se to tyka
+			for(){
+				// vybrat ktera cast value patri do tohodle bytu
+				// shiftnout podle pozice
+				
+				//samotny vlozeni do bufferu
+				buffer[x+j] |= value[j];
+			}			
+		}
+	}
+
+	return EOK;
+}
+
+
 /**
  * @}
