--- ../xf86-input-evdev-1.0.0.5-orig/src/evdev.c 2005-09-23 18:32:23.000000000 -0400 +++ src/evdev.c 2006-07-11 22:49:12.000000000 -0400 @@ -118,6 +118,7 @@ static void EvdevReadInput(InputInfoPtr pInfo) { + static time_t polling = 0; struct input_event ev; int len, value; int dx, dy; @@ -125,13 +126,43 @@ dx = 0; dy = 0; + if(polling) { + /* Poll the device every second until it is openable again. */ + const char *device; + int fd; + time_t now = time(NULL); + if(polling == now) + return; + polling = now; + + device = xf86CheckStrOption(pInfo->conf_idev->commonOptions, + "Device", NULL); + do { + xf86WaitForInput(-1, 500); + fd = open(device, O_RDWR, 0); + } while(fd < 0); + pInfo->fd = fd; + xf86Msg(X_INFO, "%s: Device replugged.\n", pInfo->name); + EvdevProc(pInfo->dev, DEVICE_OFF); + EvdevProc(pInfo->dev, DEVICE_ON); + polling = 0; + } + while (xf86WaitForInput (pInfo->fd, 0) > 0) { len = read(pInfo->fd, &ev, sizeof ev); if (len != sizeof ev) { /* The kernel promises that we always only read a complete * event, so len != sizeof ev is an error. */ - xf86Msg(X_ERROR, "Read error: %s\n", strerror(errno)); - break; + if(errno != ENODEV) { + xf86Msg(X_ERROR, "Read error: %s\n", strerror(errno)); + } else { + xf86Msg(X_INFO, "%s: Unplugged; waiting for replug.\n", + pInfo->name); + polling = time(NULL); + close(pInfo->fd); + pInfo->fd = -42; + } + break; } /* Get the signed value, earlier kernels had this as unsigned */