From 07b17059f1bb98a29afa2033b4f74ce83acb5f5e Mon Sep 17 00:00:00 2001 From: grant2258 Date: Tue, 11 Dec 2018 23:24:21 +0000 Subject: [PATCH 1/4] fix udev mouse --- input/drivers/udev_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index 2c63754ec6..8066eaab50 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -523,7 +523,7 @@ static bool udev_input_add_device(udev_input_t *udev, 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) + else if (type == UDEV_INPUT_MOUSE && ioctl(fd, EVIOCGABS(ABS_X), &absinfo) > 0) { if (absinfo.minimum >= absinfo.maximum) goto error; From 1d8dd133b73fd185f5e7042c86e97be7490ba309 Mon Sep 17 00:00:00 2001 From: grant2258 Date: Wed, 12 Dec 2018 17:29:31 +0000 Subject: [PATCH 2/4] tidy code up --- input/drivers/udev_input.c | 43 ++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index 8066eaab50..b4eef0ce8d 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -523,21 +523,38 @@ static bool udev_input_add_device(udev_input_t *udev, 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) + else if (type == UDEV_INPUT_MOUSE) { - if (absinfo.minimum >= absinfo.maximum) - goto error; + if (ioctl(fd, EVIOCGABS(ABS_X), &absinfo) >= 0) + { + + if (absinfo.minimum >= absinfo.maximum ) + { + device->mouse.x_min = 0; + device->mouse.x_max = 0; + } + else + { + device->mouse.x_min = absinfo.minimum; + device->mouse.x_min = absinfo.maximum; + } + } - 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; - } + if (ioctl(fd, EVIOCGABS(ABS_Y), &absinfo) >= 0) + { + + if (absinfo.minimum >= absinfo.maximum ) + { + device->mouse.y_min = 0; + device->mouse.y_max = 0; + } + else + { + device->mouse.y_min = absinfo.minimum; + device->mouse.y_min = absinfo.maximum; + } + } + } tmp = ( udev_input_device_t**)realloc(udev->devices, (udev->num_devices + 1) * sizeof(*udev->devices)); From fd6856ce2036d1b827aca428a0b22d2519c64bed Mon Sep 17 00:00:00 2001 From: grant2258 Date: Wed, 12 Dec 2018 18:27:29 +0000 Subject: [PATCH 3/4] fix tpouchpad as well --- input/drivers/udev_input.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index b4eef0ce8d..f3b61a8b4d 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -505,25 +505,9 @@ 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) + if (type == UDEV_INPUT_MOUSE || type == UDEV_INPUT_TOUCHPAD ) { if (ioctl(fd, EVIOCGABS(ABS_X), &absinfo) >= 0) { @@ -554,7 +538,7 @@ static bool udev_input_add_device(udev_input_t *udev, device->mouse.y_min = absinfo.maximum; } } - } + } tmp = ( udev_input_device_t**)realloc(udev->devices, (udev->num_devices + 1) * sizeof(*udev->devices)); From 74de0ade0341152f158d32d41c006051f2f9cf87 Mon Sep 17 00:00:00 2001 From: grant2258 Date: Sun, 16 Dec 2018 20:52:15 +0000 Subject: [PATCH 4/4] resolve changes --- input/drivers/udev_input.c | 46 ++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index f3b61a8b4d..33f8b613cc 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -511,36 +511,34 @@ static bool udev_input_add_device(udev_input_t *udev, { if (ioctl(fd, EVIOCGABS(ABS_X), &absinfo) >= 0) { - - if (absinfo.minimum >= absinfo.maximum ) - { - device->mouse.x_min = 0; - device->mouse.x_max = 0; - } - else - { - device->mouse.x_min = absinfo.minimum; - device->mouse.x_min = absinfo.maximum; - } + 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; + } } - if (ioctl(fd, EVIOCGABS(ABS_Y), &absinfo) >= 0) + if (ioctl(fd, EVIOCGABS(ABS_Y), &absinfo) >= 0) { - - if (absinfo.minimum >= absinfo.maximum ) - { - device->mouse.y_min = 0; - device->mouse.y_max = 0; - } - else - { - device->mouse.y_min = absinfo.minimum; - device->mouse.y_min = absinfo.maximum; - } + 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)