From: Tom Lear <tom@trap.mtview.ca.us>
Subject: ignore gaps in the input device numbering
Bug-Debian: http://bugs.debian.org/326149
Origin: vendor, http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=132;filename=lsinput.diff;att=1;bug=326149
Forwarded: yes

---
Index: input-utils-0.0.20050727/lsinput.c
===================================================================
--- input-utils-0.0.20050727.orig/lsinput.c	2006-07-10 08:51:34.000000000 +0200
+++ input-utils-0.0.20050727/lsinput.c	2006-07-10 08:52:03.000000000 +0200
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <sys/stat.h>
 #include <unistd.h>
 #include <fcntl.h>
 
@@ -10,14 +11,19 @@
 static void list_devices(void)
 {
 	int i,fd;
+        char filename[32];
+        struct stat statbuf;
 
 	for (i = 0; i < 32; i++) {
-		/* try to open */
-		fd = device_open(i,1);
-		if (-1 == fd)
-			return;
-		device_info(fd);
-		close(fd);
+                snprintf(filename,sizeof(filename), "/dev/input/event%d",i);
+                if (stat(filename, &statbuf) == 0) {
+                        /* try to open */
+                        fd = device_open(i,1);
+                        if (-1 == fd)
+                                return;
+                        device_info(fd);
+                        close(fd);
+                }
 	}
 	return;
 }
