Index: uspace/srv/hid/input/ctl/kbdev.c
===================================================================
--- uspace/srv/hid/input/ctl/kbdev.c	(revision 86ffa27f45682aa2a5736f665f400ad262ce5baf)
+++ uspace/srv/hid/input/ctl/kbdev.c	(revision cc574511968ab8b7b5afe2cbb60c2053608cc393)
@@ -48,5 +48,7 @@
 #include <kbd_ctl.h>
 #include <kbd_port.h>
+#include <loc.h>
 #include <stdlib.h>
+#include <sys/typefmt.h>
 #include <vfs/vfs_sess.h>
 
@@ -70,7 +72,4 @@
 	/** Session with kbdev device */
 	async_sess_t *sess;
-
-	/** File descriptor of open kbdev device */
-	int fd;
 } kbdev_t;
 
@@ -84,5 +83,4 @@
 
 	kbdev->kbd_dev = kdev;
-	kbdev->fd = -1;
 
 	return kbdev;
@@ -93,6 +91,4 @@
 	if (kbdev->sess != NULL)
 		async_hangup(kbdev->sess);
-	if (kbdev->fd >= 0)
-		close(kbdev->fd);
 	free(kbdev);
 }
@@ -100,22 +96,17 @@
 static int kbdev_ctl_init(kbd_dev_t *kdev)
 {
-	const char *pathname;
 	async_sess_t *sess;
 	async_exch_t *exch;
 	kbdev_t *kbdev;
-	int fd;
+	char *svc_name;
 	int rc;
 
-	pathname = kdev->dev_path;
+	if (asprintf(&svc_name, "devname%" PRIun, kdev->service_id) > 0)
+		svc_name = (char *) "unknown";
 
-	fd = open(pathname, O_RDWR);
-	if (fd < 0) {
-		return -1;
-	}
-
-	sess = fd_session(EXCHANGE_SERIALIZE, fd);
+	sess = loc_service_connect(EXCHANGE_SERIALIZE, kdev->service_id, 0);
 	if (sess == NULL) {
-		printf("%s: Failed starting session with '%s'\n", NAME, pathname);
-		close(fd);
+		printf("%s: Failed starting session with '%s.'\n", NAME,
+		    svc_name);
 		return -1;
 	}
@@ -124,14 +115,14 @@
 	if (kbdev == NULL) {
 		printf("%s: Failed allocating device structure for '%s'.\n",
-		    NAME, pathname);
+		    NAME, svc_name);
 		return -1;
 	}
 
-	kbdev->fd = fd;
 	kbdev->sess = sess;
 
 	exch = async_exchange_begin(sess);
 	if (exch == NULL) {
-		printf("%s: Failed starting exchange with '%s'.\n", NAME, pathname);
+		printf("%s: Failed starting exchange with '%s'.\n", NAME,
+		    svc_name);
 		kbdev_destroy(kbdev);
 		return -1;
@@ -141,5 +132,5 @@
 	if (rc != EOK) {
 		printf("%s: Failed creating callback connection from '%s'.\n",
-		    NAME, pathname);
+		    NAME, svc_name);
 		async_exchange_end(exch);
 		kbdev_destroy(kbdev);
Index: uspace/srv/hid/input/generic/input.c
===================================================================
--- uspace/srv/hid/input/generic/input.c	(revision 86ffa27f45682aa2a5736f665f400ad262ce5baf)
+++ uspace/srv/hid/input/generic/input.c	(revision cc574511968ab8b7b5afe2cbb60c2053608cc393)
@@ -38,4 +38,5 @@
 
 #include <adt/list.h>
+#include <bool.h>
 #include <ipc/services.h>
 #include <ipc/input.h>
@@ -275,5 +276,5 @@
 	kdev->port_ops = port;
 	kdev->ctl_ops = ctl;
-	kdev->dev_path = NULL;
+	kdev->service_id = 0;
 	
 	/* Initialize port driver. */
@@ -303,5 +304,5 @@
 	mdev->port_ops = port;
 	mdev->proto_ops = proto;
-	mdev->dev_path = NULL;
+	mdev->service_id = 0;
 	
 	/* Initialize port driver. */
@@ -324,8 +325,8 @@
 /** Add new kbdev device.
  *
- * @param dev_path Filesystem path to the device (/loc/class/...)
+ * @param service_id	Service ID of the keyboard device
  *
  */
-static int kbd_add_kbdev(const char *dev_path)
+static int kbd_add_kbdev(service_id_t service_id)
 {
 	kbd_dev_t *kdev = kbd_dev_new();
@@ -333,5 +334,5 @@
 		return -1;
 	
-	kdev->dev_path = dev_path;
+	kdev->service_id = service_id;
 	kdev->port_ops = NULL;
 	kdev->ctl_ops = &kbdev_ctl;
@@ -352,8 +353,8 @@
 /** Add new mousedev device.
  *
- * @param dev_path Filesystem path to the device (/loc/class/...)
+ * @param service_id	Service ID of the mouse device
  *
  */
-static int mouse_add_mousedev(const char *dev_path)
+static int mouse_add_mousedev(service_id_t service_id)
 {
 	mouse_dev_t *mdev = mouse_dev_new();
@@ -361,5 +362,5 @@
 		return -1;
 	
-	mdev->dev_path = dev_path;
+	mdev->service_id = service_id;
 	mdev->port_ops = NULL;
 	mdev->proto_ops = &mousedev_proto;
@@ -487,10 +488,25 @@
  *
  */
+#include <sys/typefmt.h>
 static int dev_discovery_fibril(void *arg)
 {
-	char *dev_path;
-	size_t kbd_id = 1;
-	size_t mouse_id = 1;
+	category_id_t keyboard_cat, mouse_cat;
+	service_id_t *svcs;
+	size_t count, i;
+	bool already_known;
+	const char *dev_name = "todo";
 	int rc;
+	
+	rc = loc_category_get_id("keyboard", &keyboard_cat, IPC_FLAG_BLOCKING);
+	if (rc != EOK) {
+		printf("%s: Failed resolving category 'keyboard'.\n", NAME);
+		return ENOENT;
+	}
+	
+	rc = loc_category_get_id("mouse", &mouse_cat, IPC_FLAG_BLOCKING);
+	if (rc != EOK) {
+		printf("%s: Failed resolving category 'mouse'.\n", NAME);
+		return ENOENT;
+	}
 	
 	while (true) {
@@ -498,36 +514,68 @@
 		
 		/*
-		 * Check for new keyboard device
+		 * Check for new keyboard devices
 		 */
-		rc = asprintf(&dev_path, "/loc/class/keyboard\\%zu", kbd_id);
-		if (rc < 0)
+		rc = loc_category_get_svcs(keyboard_cat, &svcs, &count);
+		if (rc != EOK) {
+			printf("%s: Failed getting list of keyboard devices.\n",
+			    NAME);
 			continue;
-		
-		if (kbd_add_kbdev(dev_path) == EOK) {
-			printf("%s: Connected keyboard device '%s'\n",
-			    NAME, dev_path);
+		}
+
+		for (i = 0; i < count; i++) {
+			already_known = false;
 			
-			/* XXX Handle device removal */
-			++kbd_id;
+			/* Determine whether we already know this device. */
+			list_foreach(kbd_devs, kdev_link) {
+				kbd_dev_t *kdev = list_get_instance(kdev_link,
+				    kbd_dev_t, kbd_devs);
+				if (kdev->service_id == svcs[i]) {
+					already_known = true;
+					break;
+				}
+			}
+
+			if (!already_known) {
+				if (kbd_add_kbdev(svcs[i]) == EOK) {
+					printf("%s: Connected keyboard device '%s'\n",
+					    NAME, dev_name);
+				}
+			}
 		}
 		
-		free(dev_path);
+		/* XXX Handle device removal */
 		
 		/*
-		 * Check for new mouse device
+		 * Check for new mouse devices
 		 */
-		rc = asprintf(&dev_path, "/loc/class/mouse\\%zu", mouse_id);
-		if (rc < 0)
+		rc = loc_category_get_svcs(mouse_cat, &svcs, &count);
+		if (rc != EOK) {
+			printf("%s: Failed getting list of mouse devices.\n",
+			    NAME);
 			continue;
-		
-		if (mouse_add_mousedev(dev_path) == EOK) {
-			printf("%s: Connected mouse device '%s'\n",
-			    NAME, dev_path);
+		}
+
+		for (i = 0; i < count; i++) {
+			already_known = false;
 			
-			/* XXX Handle device removal */
-			++mouse_id;
+			/* Determine whether we already know this device. */
+			list_foreach(mouse_devs, mdev_link) {
+				mouse_dev_t *mdev = list_get_instance(mdev_link,
+				    mouse_dev_t, mouse_devs);
+				if (mdev->service_id == svcs[i]) {
+					already_known = true;
+					break;
+				}
+			}
+
+			if (!already_known) {
+				if (mouse_add_mousedev(svcs[i]) == EOK) {
+					printf("%s: Connected mouse device '%s'\n",
+					    NAME, dev_name);
+				}
+			}
 		}
 		
-		free(dev_path);
+		/* XXX Handle device removal */
 	}
 	
Index: uspace/srv/hid/input/include/kbd.h
===================================================================
--- uspace/srv/hid/input/include/kbd.h	(revision 86ffa27f45682aa2a5736f665f400ad262ce5baf)
+++ uspace/srv/hid/input/include/kbd.h	(revision cc574511968ab8b7b5afe2cbb60c2053608cc393)
@@ -40,4 +40,5 @@
 
 #include <adt/list.h>
+#include <ipc/loc.h>
 
 struct kbd_port_ops;
@@ -49,6 +50,6 @@
 	link_t kbd_devs;
 
-	/** Path to the device (only for kbdev devices) */
-	const char *dev_path;
+	/** Service ID (only for kbdev devices) */
+	service_id_t service_id;
 
 	/** Port ops */
Index: uspace/srv/hid/input/include/mouse.h
===================================================================
--- uspace/srv/hid/input/include/mouse.h	(revision 86ffa27f45682aa2a5736f665f400ad262ce5baf)
+++ uspace/srv/hid/input/include/mouse.h	(revision cc574511968ab8b7b5afe2cbb60c2053608cc393)
@@ -39,4 +39,5 @@
 
 #include <adt/list.h>
+#include <ipc/loc.h>
 
 struct mouse_port_ops;
@@ -47,6 +48,6 @@
 	link_t mouse_devs;
 	
-	/** Path to the device (only for mouseev devices) */
-	const char *dev_path;
+	/** Service ID (only for mousedev devices) */
+	service_id_t service_id;
 	
 	/** Port ops */
Index: uspace/srv/hid/input/proto/mousedev.c
===================================================================
--- uspace/srv/hid/input/proto/mousedev.c	(revision 86ffa27f45682aa2a5736f665f400ad262ce5baf)
+++ uspace/srv/hid/input/proto/mousedev.c	(revision cc574511968ab8b7b5afe2cbb60c2053608cc393)
@@ -44,7 +44,9 @@
 #include <ipc/mouseev.h>
 #include <input.h>
+#include <loc.h>
 #include <mouse.h>
 #include <mouse_port.h>
 #include <mouse_proto.h>
+#include <sys/typefmt.h>
 
 /** Mousedev softstate */
@@ -55,7 +57,4 @@
 	/** Session to mouse device */
 	async_sess_t *sess;
-	
-	/** File descriptor of open mousedev device */
-	int fd;
 } mousedev_t;
 
@@ -67,5 +66,4 @@
 	
 	mousedev->mouse_dev = mdev;
-	mousedev->fd = -1;
 	
 	return mousedev;
@@ -76,7 +74,4 @@
 	if (mousedev->sess != NULL)
 		async_hangup(mousedev->sess);
-	
-	if (mousedev->fd >= 0)
-		close(mousedev->fd);
 	
 	free(mousedev);
@@ -122,14 +117,13 @@
 static int mousedev_proto_init(mouse_dev_t *mdev)
 {
-	const char *pathname = mdev->dev_path;
+	char *svc_name;
 	
-	int fd = open(pathname, O_RDWR);
-	if (fd < 0)
-		return -1;
+	if (asprintf(&svc_name, "devname%" PRIun, mdev->service_id) > 0)
+		svc_name = (char *) "unknown";
 	
-	async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd);
+	async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE,
+	    mdev->service_id, 0);
 	if (sess == NULL) {
-		printf("%s: Failed starting session with '%s'\n", NAME, pathname);
-		close(fd);
+		printf("%s: Failed starting session with '%s'\n", NAME, svc_name);
 		return -1;
 	}
@@ -138,14 +132,14 @@
 	if (mousedev == NULL) {
 		printf("%s: Failed allocating device structure for '%s'.\n",
-		    NAME, pathname);
+		    NAME, svc_name);
 		return -1;
 	}
 	
-	mousedev->fd = fd;
 	mousedev->sess = sess;
 	
 	async_exch_t *exch = async_exchange_begin(sess);
 	if (exch == NULL) {
-		printf("%s: Failed starting exchange with '%s'.\n", NAME, pathname);
+		printf("%s: Failed starting exchange with '%s'.\n", NAME,
+		    svc_name);
 		mousedev_destroy(mousedev);
 		return -1;
@@ -157,5 +151,5 @@
 	if (rc != EOK) {
 		printf("%s: Failed creating callback connection from '%s'.\n",
-		    NAME, pathname);
+		    NAME, svc_name);
 		mousedev_destroy(mousedev);
 		return -1;
