Index: uspace/drv/usbhid/kbd/kbddev.c
===================================================================
--- uspace/drv/usbhid/kbd/kbddev.c	(revision 72052090a7ad5a6ebda57a82ce17215a1c257026)
+++ uspace/drv/usbhid/kbd/kbddev.c	(revision cc5908ebb647ae50145e0da5792c167a91835e00)
@@ -700,6 +700,6 @@
 	
 	while (field != NULL) {
-		usb_log_debug2("FIELD (%p) - VALUE(%d) USAGE(%u)\n", 
-		    field, field->value, field->usage);
+		//usb_log_debug2("FIELD (%p) - VALUE(%d) USAGE(%u)\n", 
+		//    field, field->value, field->usage);
 		
 		assert(i < kbd_dev->key_count);
@@ -865,7 +865,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 +907,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", 
Index: uspace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.c
===================================================================
--- uspace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.c	(revision 72052090a7ad5a6ebda57a82ce17215a1c257026)
+++ uspace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.c	(revision cc5908ebb647ae50145e0da5792c167a91835e00)
@@ -300,7 +300,7 @@
 	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);
+	lgtch_dev->key_count = usb_hid_report_size(hid_dev->report, 1, 
+		USB_HID_REPORT_TYPE_INPUT);
+	
 	usb_hid_report_path_free(path);
 	
Index: uspace/drv/usbhid/usbhid.c
===================================================================
--- uspace/drv/usbhid/usbhid.c	(revision 72052090a7ad5a6ebda57a82ce17215a1c257026)
+++ uspace/drv/usbhid/usbhid.c	(revision cc5908ebb647ae50145e0da5792c167a91835e00)
@@ -203,6 +203,6 @@
 	
 	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, mapping->report_id, 
+	    USB_HID_REPORT_TYPE_INPUT);
 	usb_log_debug("Size of the input report: %zuB\n", size);
 	
Index: uspace/drv/usbkbd/kbddev.c
===================================================================
--- uspace/drv/usbkbd/kbddev.c	(revision 72052090a7ad5a6ebda57a82ce17215a1c257026)
+++ uspace/drv/usbkbd/kbddev.c	(revision cc5908ebb647ae50145e0da5792c167a91835e00)
@@ -771,6 +771,6 @@
 	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);
+	kbd_dev->key_count = usb_hid_report_size(
+	    kbd_dev->parser, 0, USB_HID_REPORT_TYPE_INPUT);
 	usb_hid_report_path_free (path);
 	
@@ -803,7 +803,6 @@
 	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);
+	kbd_dev->led_output_size = usb_hid_report_size(kbd_dev->parser, 0, 
+	    USB_HID_REPORT_TYPE_OUTPUT);
 	
 	usb_log_debug("Output report size (in items): %zu\n", 
Index: uspace/lib/usb/include/usb/classes/hid_report_items.h
===================================================================
--- uspace/lib/usb/include/usb/classes/hid_report_items.h	(revision 72052090a7ad5a6ebda57a82ce17215a1c257026)
+++ uspace/lib/usb/include/usb/classes/hid_report_items.h	(revision cc5908ebb647ae50145e0da5792c167a91835e00)
@@ -46,4 +46,11 @@
 #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)
 
 /**
Index: uspace/lib/usb/include/usb/classes/hidparser.h
===================================================================
--- uspace/lib/usb/include/usb/classes/hidparser.h	(revision 72052090a7ad5a6ebda57a82ce17215a1c257026)
+++ uspace/lib/usb/include/usb/classes/hidparser.h	(revision cc5908ebb647ae50145e0da5792c167a91835e00)
@@ -51,8 +51,4 @@
                          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
@@ -65,7 +61,7 @@
 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);
+/** 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 */
Index: uspace/lib/usb/include/usb/classes/hidtypes.h
===================================================================
--- uspace/lib/usb/include/usb/classes/hidtypes.h	(revision 72052090a7ad5a6ebda57a82ce17215a1c257026)
+++ uspace/lib/usb/include/usb/classes/hidtypes.h	(revision cc5908ebb647ae50145e0da5792c167a91835e00)
@@ -39,5 +39,5 @@
 #include <adt/list.h>
 
-#define USB_HID_MAX_USAGES	20
+#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)))
@@ -92,9 +92,11 @@
 	int32_t physical_minimum;
 	int32_t physical_maximum;
-	uint32_t usage_minimum;
-	uint32_t usage_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;
@@ -121,7 +123,7 @@
 
 	/** */	
-	uint32_t usage_minimum;
-	/** */	
-	uint32_t usage_maximum;
+	int32_t usage_minimum;
+	/** */	
+	int32_t usage_maximum;
 	/** */	
 	int32_t logical_minimum;
Index: uspace/lib/usb/src/hiddescriptor.c
===================================================================
--- uspace/lib/usb/src/hiddescriptor.c	(revision 72052090a7ad5a6ebda57a82ce17215a1c257026)
+++ uspace/lib/usb/src/hiddescriptor.c	(revision cc5908ebb647ae50145e0da5792c167a91835e00)
@@ -116,8 +116,16 @@
 	int i;
 
-	for(i=0; i<report_item->usages_count; i++){
-		usb_log_debug("usages (%d) - %x\n", i, report_item->usages[i]);
-	}
-
+	usb_log_debug("usages_count  - %zu\n", report_item->usages_count);
+
+	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 +141,20 @@
 		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 = 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 +163,12 @@
 			}
 
-						
-			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 {
 				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 +215,8 @@
 	}
 
+	// free only when not used!!!
+	if(usages && usages_used == 0) {
+		free(usages);
+	}
 
 	return EOK;
@@ -565,5 +575,5 @@
 			}
 			break;
-		case USB_HID_REPORT_TAG_USAGE_MINIMUM:
+		case USB_HID_REPORT_TAG_USAGE_MINIMUM:			
 			if (item_size == 3) {
 				// usage extended usages
@@ -577,4 +587,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 +599,17 @@
 				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++] = i;
+				}
+			}
+			report_item->extended_usage_page = 0;
+			
 			break;
 		case USB_HID_REPORT_TAG_DESIGNATOR_INDEX:
Index: uspace/lib/usb/src/hidparser.c
===================================================================
--- uspace/lib/usb/src/hidparser.c	(revision 72052090a7ad5a6ebda57a82ce17215a1c257026)
+++ uspace/lib/usb/src/hidparser.c	(revision cc5908ebb647ae50145e0da5792c167a91835e00)
@@ -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;
+	}
+}
 
 
@@ -114,5 +138,8 @@
 				// 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]);
+
 			}
 			else {
@@ -206,48 +233,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 **/
 
@@ -302,46 +285,4 @@
 		free (output);
 	}
-}
-
-/** 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;
-	
 }
 
