diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index 2c63754ec6f..33f8b613cc7 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -505,41 +505,40 @@ static bool udev_input_add_device(udev_input_t *udev, strlcpy(device->devnode, devnode, sizeof(device->devnode)); - /* Touchpads report in absolute coords. */ - if (type == UDEV_INPUT_TOUCHPAD) - { - if (ioctl(fd, EVIOCGABS(ABS_X), &absinfo) < 0 || - absinfo.minimum >= absinfo.maximum) - goto error; - - device->mouse.x_min = absinfo.minimum; - device->mouse.x_max = absinfo.maximum; - - if (ioctl(fd, EVIOCGABS(ABS_Y), &absinfo) < 0 || - absinfo.minimum >= absinfo.maximum) - goto error; - - device->mouse.y_min = absinfo.minimum; - device->mouse.y_max = absinfo.maximum; - } + /* UDEV_INPUT_MOUSE may report in absolute coords too */ - else if (type == UDEV_INPUT_MOUSE && ioctl(fd, EVIOCGABS(ABS_X), &absinfo) >= 0) + if (type == UDEV_INPUT_MOUSE || type == UDEV_INPUT_TOUCHPAD ) { - if (absinfo.minimum >= absinfo.maximum) - goto error; - - device->mouse.x_min = absinfo.minimum; - device->mouse.x_max = absinfo.maximum; - - if (ioctl(fd, EVIOCGABS(ABS_Y), &absinfo) < 0 || - absinfo.minimum >= absinfo.maximum) - goto error; + if (ioctl(fd, EVIOCGABS(ABS_X), &absinfo) >= 0) + { + if (absinfo.minimum >= absinfo.maximum ) + { + device->mouse.x_min = -1; + device->mouse.x_max = 1; + } + else + { + device->mouse.x_min = absinfo.minimum; + device->mouse.x_min = absinfo.maximum; + } + } - device->mouse.y_min = absinfo.minimum; - device->mouse.y_max = absinfo.maximum; + if (ioctl(fd, EVIOCGABS(ABS_Y), &absinfo) >= 0) + { + if (absinfo.minimum >= absinfo.maximum ) + { + device->mouse.y_min = -1; + device->mouse.y_max = 1; + } + else + { + device->mouse.y_min = absinfo.minimum; + device->mouse.y_min = absinfo.maximum; + } + } } - tmp = ( udev_input_device_t**)realloc(udev->devices, + tmp = ( udev_input_device_t**)realloc(udev->devices, (udev->num_devices + 1) * sizeof(*udev->devices)); if (!tmp)