Index: uspace/lib/usb/include/usb/classes/hid_report_items.h
===================================================================
--- uspace/lib/usb/include/usb/classes/hid_report_items.h	(revision c7a2e7ec1c726c515237c4ca2105dbd3ac1d4837)
+++ uspace/lib/usb/include/usb/classes/hid_report_items.h	(revision b7d960699b942f03e28e729f2b07c38e352f3588)
@@ -42,6 +42,6 @@
 #define USB_HID_REPORT_TAG_INPUT			0x8
 #define USB_HID_REPORT_TAG_OUTPUT			0x9
-#define USB_HID_REPORT_TAG_FEATURE			0xA
-#define USB_HID_REPORT_TAG_COLLECTION		0xB
+#define USB_HID_REPORT_TAG_FEATURE			0xB
+#define USB_HID_REPORT_TAG_COLLECTION		0xA
 #define USB_HID_REPORT_TAG_END_COLLECTION	0xC
 
Index: uspace/lib/usb/src/hidparser.c
===================================================================
--- uspace/lib/usb/src/hidparser.c	(revision c7a2e7ec1c726c515237c4ca2105dbd3ac1d4837)
+++ uspace/lib/usb/src/hidparser.c	(revision b7d960699b942f03e28e729f2b07c38e352f3588)
@@ -36,12 +36,15 @@
 #include <errno.h>
 #include <stdio.h>
-#include <adt/list.h>
 #include <malloc.h>
 #include <mem.h>
-
-#define USB_HID_NEW_REPORT_ITEM 0
-
-
-int usb_hid_report_parse_tag(uint8_t tag, uint8_t class, const const uint8_t *data, size_t item_size,
+#include <assert.h>
+#include <usb/debug.h>
+
+#define USB_HID_NEW_REPORT_ITEM 1
+#define USB_HID_NO_ACTION		2
+#define USB_HID_UNKNOWN_TAG		-99
+
+
+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);
 int usb_hid_report_parse_main_tag(uint8_t tag, const uint8_t *data, size_t item_size,
@@ -56,5 +59,5 @@
 void usb_hid_free_report_list(link_t *head);
 int32_t usb_hid_report_tag_data_int32(const uint8_t *data, size_t size);
-size_t usb_hid_count_item_offset(usb_hid_report_item_t * report_item, size_t offset);
+inline size_t usb_hid_count_item_offset(usb_hid_report_item_t * report_item, size_t offset);
 /**
  *
@@ -81,5 +84,5 @@
  */
 int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser, 
-    const const uint8_t *data, size_t size)
+    const uint8_t *data, size_t size)
 {
 	size_t i=0;
@@ -99,36 +102,46 @@
 	link_initialize(&(report_item->link));	
 	
-	while(i<size){
-		
+	while(i<size){	
 		if(!USB_HID_ITEM_IS_LONG(data[i])){
+
+			if((i+1) >= size){
+				return -1; // TODO ERROR CODE
+			}
+			
 			tag = USB_HID_ITEM_TAG(data[i]);
 			item_size = USB_HID_ITEM_SIZE(data[i]);
 			class = USB_HID_ITEM_TAG_CLASS(data[i]);
-						
-			ret = usb_hid_report_parse_tag(tag,class,(data + (i+1)),
+
+			usb_log_debug2(
+				"i(%u) data(%X) value(%X): TAG %u, class %u, size %u - ", i, 
+			    data[i], usb_hid_report_tag_data_int32(data+i+1,item_size), 
+			    tag, class, item_size);
+			
+			ret = usb_hid_report_parse_tag(tag,class,data+i+1,
 			                         item_size,report_item);
+			printf("ret: %u\n", ret);
 			switch(ret){
 				case USB_HID_NEW_REPORT_ITEM:
 					// store report item to report and create the new one
-					printf("\nNEW REPORT ITEM: %X",tag);
-
+					usb_log_debug("\nNEW REPORT ITEM: %X",tag);
+
+					report_item->offset = offset;
 					offset = usb_hid_count_item_offset(report_item, offset);
-					report_item->offset = offset;
 					switch(tag) {
 						case USB_HID_REPORT_TAG_INPUT:
-							printf(" - INPUT\n");
+							usb_log_debug(" - INPUT\n");
 							list_append(&(report_item->link), &(parser->input));
 							break;
 						case USB_HID_REPORT_TAG_OUTPUT:
-							printf(" - OUTPUT\n");
+							usb_log_debug(" - OUTPUT\n");
 								list_append(&(report_item->link), &(parser->output));
 
 							break;
 						case USB_HID_REPORT_TAG_FEATURE:
-							printf(" - FEATURE\n");
+							usb_log_debug(" - FEATURE\n");
 								list_append(&(report_item->link), &(parser->feature));
 							break;
 						default:
-						    printf("\tjump over tag: %X\n", tag	q);
+						    usb_log_debug("\tjump over - tag %X\n", tag);
 						    break;
 					}
@@ -153,5 +166,5 @@
 					
 				default:
-					// nothing special to do
+					// nothing special to do					
 					break;
 			}
@@ -183,5 +196,5 @@
  */
 int usb_hid_parse_report(const usb_hid_report_parser_t *parser,  
-    const const uint8_t *data, size_t size,
+    const uint8_t *data, size_t size,
     const usb_hid_report_in_callbacks_t *callbacks, void *arg)
 {
@@ -215,5 +228,5 @@
  * @return Error code
  */
-int usb_hid_boot_keyboard_input_report(const const uint8_t *data, size_t size,
+int usb_hid_boot_keyboard_input_report(const uint8_t *data, size_t size,
 	const usb_hid_report_in_callbacks_t *callbacks, void *arg)
 {
@@ -273,16 +286,18 @@
  * @return Code of action to be done next
  */
-int usb_hid_report_parse_tag(uint8_t tag, uint8_t class, const const uint8_t *data, size_t item_size,
+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)
 {	
+	int ret;
+	
 	switch(class){
 		case USB_HID_TAG_CLASS_MAIN:
 
-			if(usb_hid_report_parse_main_tag(tag,data,item_size,report_item) == EOK) {
+			if((ret=usb_hid_report_parse_main_tag(tag,data,item_size,report_item)) == EOK) {
 				return USB_HID_NEW_REPORT_ITEM;
 			}
 			else {
 				/*TODO process the error */
-				return -1;
+				return ret;
 			   }
 			break;
@@ -296,5 +311,5 @@
 			break;
 		default:
-			return -1; /* TODO ERROR CODE - UNKNOWN TAG CODE */
+			return USB_HID_NO_ACTION;
 	}
 }
@@ -318,6 +333,6 @@
 		case USB_HID_REPORT_TAG_OUTPUT:
 		case USB_HID_REPORT_TAG_FEATURE:
-			report_item->item_flags = *data;
-			return USB_HID_NEW_REPORT_ITEM;
+			report_item->item_flags = *data;			
+			return EOK;			
 			break;
 			
@@ -330,8 +345,8 @@
 			break;
 		default:
-			return -1; //TODO ERROR CODE
-	}
-
-	return EOK;
+			return USB_HID_NO_ACTION;
+	}
+
+	return USB_HID_NO_ACTION;
 }
 
@@ -388,5 +403,5 @@
 			
 		default:
-			return -1; //TODO ERROR CODE INVALID GLOBAL TAG
+			return USB_HID_NO_ACTION;
 	}
 	
@@ -441,5 +456,5 @@
 */		
 		default:
-			return -1; //TODO ERROR CODE INVALID LOCAL TAG NOW IS ONLY UNSUPPORTED
+			return USB_HID_NO_ACTION;
 	}
 	
@@ -484,7 +499,5 @@
 	    return;
 	}
-
-	
-        printf("\tHEAD %p\n",head);
+        
 	for(item = head->next; item != head; item = item->next) {
                 
