Index: uspace/lib/usb/src/hidparser.c
===================================================================
--- uspace/lib/usb/src/hidparser.c	(revision b04967a003044e09e0002312ae3874f7d2c88a6e)
+++ uspace/lib/usb/src/hidparser.c	(revision c156c2d0df49edf3338754d987f9771ce6097be4)
@@ -70,5 +70,5 @@
 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);
-int usb_hid_translate_data(usb_hid_report_item_t *item, const uint8_t *data, size_t j);
+int usb_hid_translate_data(const usb_hid_report_parser_t *parser, usb_hid_report_item_t *item, const uint8_t *data, size_t j);
 int32_t usb_hid_translate_data_reverse(usb_hid_report_item_t *item, int32_t value);
 int usb_pow(int a, int b);
@@ -103,6 +103,6 @@
 
 	list_initialize(&(parser->input));
-    list_initialize(&(parser->output));
-    list_initialize(&(parser->feature));
+    	list_initialize(&(parser->output));
+    	list_initialize(&(parser->feature));
 
 	list_initialize(&(parser->stack));
@@ -246,6 +246,8 @@
 					// push current state to stack
 					new_report_item = usb_hid_report_item_clone(report_item);
-					list_prepend (&parser->stack, &new_report_item->link);
-					
+					usb_hid_report_path_t *tmp_path = usb_hid_report_path_clone(usage_path);
+					new_report_item->usage_path = tmp_path; 
+
+					list_prepend (&new_report_item->link, &parser->stack);
 					break;
 				case USB_HID_REPORT_TAG_POP:
@@ -254,6 +256,15 @@
 						return EINVAL;
 					}
+					free(report_item);
+						
+					report_item = list_get_instance(parser->stack.next, usb_hid_report_item_t, link);
 					
-					report_item = list_get_instance(&parser->stack, usb_hid_report_item_t, link);
+					usb_hid_report_usage_path_t *tmp_usage_path;
+					tmp_usage_path = list_get_instance(report_item->usage_path->link.prev, usb_hid_report_usage_path_t, link);
+					
+					usb_hid_report_set_last_item(usage_path, tmp_usage_path->usage_page, tmp_usage_path->usage);
+
+					usb_hid_report_path_free(report_item->usage_path);
+					list_initialize(&report_item->usage_path->link);
 					list_remove (parser->stack.next);
 					
@@ -469,4 +480,5 @@
 		case USB_HID_REPORT_TAG_PUSH:
 		case USB_HID_REPORT_TAG_POP:
+			usb_log_debug("PUSH/POP processed\n");
 			return tag;
 			break;
@@ -678,5 +690,5 @@
 	usb_hid_free_report_list(&parser->output);
 	usb_hid_free_report_list(&parser->feature);
-
+	usb_hid_free_report_list(&parser->stack);
 	return;
 }
@@ -709,15 +721,16 @@
 		return EINVAL;
 	}
-	
-	/* get the size of result array */
-	key_count = usb_hid_report_input_length(parser, path, flags);
-
-	if(!(keys = malloc(sizeof(uint8_t) * key_count))){
-		return ENOMEM;
-	}
 
 	if(parser->use_report_id != 0) {
 		report_id = data[0];
 		usb_hid_report_path_set_report_id(path, report_id);
+	}
+
+
+	/* get the size of result array */
+	key_count = usb_hid_report_input_length(parser, path, flags);
+
+	if(!(keys = malloc(sizeof(uint8_t) * key_count))){
+		return ENOMEM;
 	}
 
@@ -734,9 +747,9 @@
 				   ((item->usage_minimum == 0) && (item->usage_maximum == 0))) {
 					// variable item
-					keys[i++] = usb_hid_translate_data(item, data,j);
+					keys[i++] = usb_hid_translate_data(parser, item, data,j);
 				}
 				else {
 					// bitmapa
-					if((item_value = usb_hid_translate_data(item, data, j)) != 0) {
+					if((item_value = usb_hid_translate_data(parser, item, data, j)) != 0) {
 						keys[i++] = (item->count - 1 - j) + item->usage_minimum;
 					}
@@ -758,5 +771,5 @@
 
 /**
- * Translate data from the report as specified in report descriptor
+ * Translate data from the report as specified in report descriptor item
  *
  * @param item Report descriptor item with definition of translation
@@ -765,5 +778,5 @@
  * @return Translated data
  */
-int usb_hid_translate_data(usb_hid_report_item_t *item, const uint8_t *data, size_t j)
+int usb_hid_translate_data(const usb_hid_report_parser_t *parser, usb_hid_report_item_t *item, const uint8_t *data, size_t j)
 {
 	int resolution;
@@ -775,5 +788,5 @@
 	const uint8_t *foo;
 
-	// now only common numbers llowed
+	// now only shot tags are allowed
 	if(item->size > 32) {
 		return 0;
@@ -795,7 +808,6 @@
 
 	offset = item->offset + (j * item->size);
-	if(item->id != 0) {
+	if(parser->use_report_id != 0) {
 		offset += 8;
-		usb_log_debug("MOVED OFFSET BY 1Byte, REPORT_ID(%d)\n", item->id);
 	}
 	
@@ -1157,4 +1169,8 @@
 		*size = (last->offset + (last->size * last->count)) / 8;
 
+		if(parser->use_report_id != 0) {
+			*size += 1;
+		}
+
 		uint8_t *buffer = malloc(sizeof(uint8_t) * (*size));
 		memset(buffer, 0, sizeof(uint8_t) * (*size));
@@ -1210,5 +1226,5 @@
 
 		item = item->next;
-	} 
+	}
 
 	return ret;
