Index: uspace/drv/usbhid/kbddev.c
===================================================================
--- uspace/drv/usbhid/kbddev.c	(revision a8def7d8500034405ad3c075274cb7b3e4d8745b)
+++ uspace/drv/usbhid/kbddev.c	(revision fc5ed5dee7e65b8744a655665eee2259fa6febc4)
@@ -51,4 +51,5 @@
 #include <usb/classes/hidparser.h>
 #include <usb/classes/classes.h>
+#include <usb/classes/hidut.h>
 
 #include "kbddev.h"
@@ -122,4 +123,17 @@
 	KC_RALT,          /* USB_HID_MOD_RALT */
 	0,                /* USB_HID_MOD_RGUI */
+};
+
+typedef enum usbhid_lock_code {
+	USBHID_LOCK_NUM = 0x53,
+	USBHID_LOCK_CAPS = 0x39,
+	USBHID_LOCK_SCROLL = 0x47,
+	USBHID_LOCK_COUNT = 3
+} usbhid_lock_code;
+
+static const usbhid_lock_code usbhid_lock_codes[USBHID_LOCK_COUNT] = {
+	USBHID_LOCK_NUM,
+	USBHID_LOCK_CAPS,
+	USBHID_LOCK_SCROLL
 };
 
@@ -346,36 +360,45 @@
  * @sa usbhid_kbd_push_ev()
  */
-static void usbhid_kbd_check_modifier_changes(usbhid_kbd_t *kbd_dev,
-    uint8_t modifiers)
-{
-	/*
-	 * TODO: why the USB keyboard has NUM_, SCROLL_ and CAPS_LOCK
-	 *       both as modifiers and as keys with their own scancodes???
-	 *
-	 * modifiers should be sent as normal keys to usbhid_parse_scancode()!!
-	 * so maybe it would be better if I received it from report parser in 
-	 * that way
-	 */
-	
-	int i;
-	for (i = 0; i < USB_HID_MOD_COUNT; ++i) {
-		if ((modifiers & usb_hid_modifiers_consts[i]) &&
-		    !(kbd_dev->modifiers & usb_hid_modifiers_consts[i])) {
-			// modifier pressed
-			if (usbhid_modifiers_keycodes[i] != 0) {
-				usbhid_kbd_push_ev(kbd_dev, KEY_PRESS, 
-				    usbhid_modifiers_keycodes[i]);
-			}
-		} else if (!(modifiers & usb_hid_modifiers_consts[i]) &&
-		    (kbd_dev->modifiers & usb_hid_modifiers_consts[i])) {
-			// modifier released
-			if (usbhid_modifiers_keycodes[i] != 0) {
-				usbhid_kbd_push_ev(kbd_dev, KEY_RELEASE, 
-				    usbhid_modifiers_keycodes[i]);
-			}
-		}	// no change
-	}
-	
-	kbd_dev->modifiers = modifiers;
+//static void usbhid_kbd_check_modifier_changes(usbhid_kbd_t *kbd_dev, 
+//    const uint8_t *key_codes, size_t count)
+//{
+//	/*
+//	 * TODO: why the USB keyboard has NUM_, SCROLL_ and CAPS_LOCK
+//	 *       both as modifiers and as keyUSB_HID_LOCK_COUNTs with their own scancodes???
+//	 *
+//	 * modifiers should be sent as normal keys to usbhid_parse_scancode()!!
+//	 * so maybe it would be better if I received it from report parser in 
+//	 * that way
+//	 */
+	
+//	int i;
+//	for (i = 0; i < count; ++i) {
+//		if ((modifiers & usb_hid_modifiers_consts[i]) &&
+//		    !(kbd_dev->modifiers & usb_hid_modifiers_consts[i])) {
+//			// modifier pressed
+//			if (usbhid_modifiers_keycodes[i] != 0) {
+//				usbhid_kbd_push_ev(kbd_dev, KEY_PRESS, 
+//				    usbhid_modifiers_keycodes[i]);
+//			}
+//		} else if (!(modifiers & usb_hid_modifiers_consts[i]) &&
+//		    (kbd_dev->modifiers & usb_hid_modifiers_consts[i])) {
+//			// modifier released
+//			if (usbhid_modifiers_keycodes[i] != 0) {
+//				usbhid_kbd_push_ev(kbd_dev, KEY_RELEASE, 
+//				    usbhid_modifiers_keycodes[i]);
+//			}
+//		}	// no change
+//	}
+	
+//	kbd_dev->modifiers = modifiers;
+//}
+
+/*----------------------------------------------------------------------------*/
+
+static inline int usbhid_kbd_is_lock(unsigned int key_code) 
+{
+	return (key_code == KC_NUM_LOCK
+	    || key_code == KC_SCROLL_LOCK
+	    || key_code == KC_CAPS_LOCK);
 }
 
@@ -404,4 +427,7 @@
 	/*
 	 * First of all, check if the kbd have reported phantom state.
+	 *
+	 * TODO: this must be changed as we don't know which keys are modifiers
+	 *       and which are regular keys.
 	 */
 	i = 0;
@@ -434,5 +460,7 @@
 			// not found, i.e. the key was released
 			key = usbhid_parse_scancode(kbd_dev->keys[j]);
-			usbhid_kbd_repeat_stop(kbd_dev, key);
+			if (!usbhid_kbd_is_lock(key)) {
+				usbhid_kbd_repeat_stop(kbd_dev, key);
+			}
 			usbhid_kbd_push_ev(kbd_dev, KEY_RELEASE, key);
 			usb_log_debug2("Key released: %d\n", key);
@@ -458,5 +486,7 @@
 			    key_codes[i]);
 			usbhid_kbd_push_ev(kbd_dev, KEY_PRESS, key);
-			usbhid_kbd_repeat_start(kbd_dev, key);
+			if (!usbhid_kbd_is_lock(key)) {
+				usbhid_kbd_repeat_start(kbd_dev, key);
+			}
 		} else {
 			// found, nothing happens
@@ -510,5 +540,5 @@
 	}
 	
-	usbhid_kbd_check_modifier_changes(kbd_dev, modifiers);
+	///usbhid_kbd_check_modifier_changes(kbd_dev, key_codes, count);
 	usbhid_kbd_check_key_changes(kbd_dev, key_codes, count);
 }
@@ -679,5 +709,13 @@
 	
 	// save the size of the report (boot protocol report by default)
-	kbd_dev->key_count = BOOTP_REPORT_SIZE;
+//	kbd_dev->key_count = BOOTP_REPORT_SIZE;
+	
+	usb_hid_report_path_t path;
+	path.usage_page = USB_HIDUT_PAGE_KEYBOARD;
+	kbd_dev->key_count = usb_hid_report_input_length(
+	    kbd_dev->hid_dev->parser, &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));
