diff -Naur xorg-server-1.12.3/hw/kdrive/linux/evdev.c xorg-server-1.12.3-magellan/hw/kdrive/linux/evdev.c --- xorg-server-1.12.3/hw/kdrive/linux/evdev.c 2012-06-26 06:12:50.000000000 +0200 +++ xorg-server-1.12.3-magellan/hw/kdrive/linux/evdev.c 2012-08-21 16:49:17.955981151 +0200 @@ -191,6 +191,8 @@ "/dev/input/event1", "/dev/input/event2", "/dev/input/event3", + "/dev/input/event4", + "/dev/input/event5", }; #define NUM_DEFAULT_EVDEV (sizeof (kdefaultEvdev) / sizeof (kdefaultEvdev[0])) @@ -200,15 +202,29 @@ { int i; int fd; + int ret; + unsigned long ev[NBITS(EV_MAX)]; if (!pi->path) { for (i = 0; i < NUM_DEFAULT_EVDEV; i++) { - fd = open(kdefaultEvdev[i], 2); - if (fd >= 0) { + if ((fd = open (kdefaultEvdev[i], 2)) < 0) { + continue; + } + ret = ioctl (fd, EVIOCGBIT (0, sizeof (ev)), ev); + close (fd); + if (ret < 0) { + ErrorF("EVIOCGBIT 0\n"); + continue; + } + if (ISBITSET (ev, EV_KEY) && ISBITSET (ev, EV_REL)) { pi->path = strdup(kdefaultEvdev[i]); break; } } + if (!pi->path) { + ErrorF("Failed to find a valid mouse device\n"); + return BadMatch; + } } else { fd = open(pi->path, O_RDWR); @@ -216,10 +232,8 @@ ErrorF("Failed to open evdev device %s\n", pi->path); return BadMatch; } + close(fd); } - - close(fd); - pi->name = strdup("Evdev mouse"); return Success;