--- lsinput.c.orig 2004-04-21 04:55:44.000000000 -0700
+++ lsinput.c 2006-07-09 16:58:46.000000000 -0700
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
@@ -10,14 +11,20 @@
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;
}