[PATCH libinput] evdev: accept but disable ABS_MISC and above for min/max == 0
Peter Hutterer
peter.hutterer at who-t.net
Sun Apr 19 15:40:15 PDT 2015
This is sort-of legitimate, so simply disable the axes and continue.
Any real axis we require to have a real range.
https://bugs.freedesktop.org/show_bug.cgi?id=90090
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/evdev.c | 26 ++++--
test/Makefile.am | 1 +
test/device.c | 4 +-
test/litest-mouse-roccat.c | 205 +++++++++++++++++++++++++++++++++++++++++++++
test/litest.c | 2 +
test/litest.h | 1 +
6 files changed, 231 insertions(+), 8 deletions(-)
create mode 100644 test/litest-mouse-roccat.c
diff --git a/src/evdev.c b/src/evdev.c
index da33eae..1a7282d 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1513,11 +1513,27 @@ evdev_check_min_max(struct evdev_device *device, unsigned int code)
absinfo = libevdev_get_abs_info(evdev, code);
if (absinfo->minimum == absinfo->maximum) {
- log_bug_kernel(device->base.seat->libinput,
- "Device '%s' has min == max on %s\n",
- device->devname,
- libevdev_event_code_get_name(EV_ABS, code));
- return -1;
+ /* Some devices have a sort-of legitimate min/max of 0 for
+ * ABS_MISC and above (e.g. Roccat Kone XTD). Don't ignore
+ * them, simply disable the axes so we won't get events,
+ * we don't know what to do with them anyway.
+ */
+ if (absinfo->minimum == 0 &&
+ code >= ABS_MISC && code < ABS_MT_SLOT) {
+ log_info(device->base.seat->libinput,
+ "Disabling EV_ABS %#x on device '%s' (min == max == 0)\n",
+ code,
+ device->devname);
+ libevdev_disable_event_code(device->evdev,
+ EV_ABS,
+ code);
+ } else {
+ log_bug_kernel(device->base.seat->libinput,
+ "Device '%s' has min == max on %s\n",
+ device->devname,
+ libevdev_event_code_get_name(EV_ABS, code));
+ return -1;
+ }
}
return 0;
diff --git a/test/Makefile.am b/test/Makefile.am
index fdfb84c..a616c5c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -19,6 +19,7 @@ liblitest_la_SOURCES = \
litest-keyboard.c \
litest-keyboard-razer-blackwidow.c \
litest-mouse.c \
+ litest-mouse-roccat.c \
litest-ms-surface-cover.c \
litest-protocol-a-touch-screen.c \
litest-qemu-usb-tablet.c \
diff --git a/test/device.c b/test/device.c
index ed3c2e0..b603189 100644
--- a/test/device.c
+++ b/test/device.c
@@ -831,9 +831,7 @@ START_TEST(abs_device_no_range)
li = litest_create_context();
litest_disable_log_handler(li);
- for (code = 0; code < ABS_MT_SLOT; code++) {
- if (code == ABS_MISC)
- continue;
+ for (code = 0; code < ABS_MISC; code++) {
absinfo[2].value = code;
uinput = litest_create_uinput_abs_device("test device", NULL,
absinfo,
diff --git a/test/litest-mouse-roccat.c b/test/litest-mouse-roccat.c
new file mode 100644
index 0000000..adccd3d
--- /dev/null
+++ b/test/litest-mouse-roccat.c
@@ -0,0 +1,205 @@
+/*
+ * Copyright © 2015 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "litest.h"
+#include "litest-int.h"
+
+static void litest_mouse_roccat_setup(void)
+{
+ struct litest_device *d = litest_create_device(LITEST_MOUSE_ROCCAT);
+ litest_set_current_device(d);
+}
+
+static struct input_id input_id = {
+ .bustype = 0x3,
+ .vendor = 0x1e7d,
+ .product = 0x2e22,
+};
+
+static int events[] = {
+ EV_REL, REL_X,
+ EV_REL, REL_Y,
+ EV_REL, REL_WHEEL,
+ EV_REL, REL_HWHEEL,
+ EV_REL, REL_DIAL,
+ EV_KEY, KEY_ESC,
+ EV_KEY, KEY_ENTER,
+ EV_KEY, KEY_KPMINUS,
+ EV_KEY, KEY_KPPLUS,
+ EV_KEY, KEY_UP,
+ EV_KEY, KEY_LEFT,
+ EV_KEY, KEY_RIGHT,
+ EV_KEY, KEY_DOWN,
+ EV_KEY, KEY_MUTE,
+ EV_KEY, KEY_VOLUMEDOWN,
+ EV_KEY, KEY_VOLUMEUP,
+ EV_KEY, KEY_POWER,
+ EV_KEY, KEY_PAUSE,
+ EV_KEY, KEY_STOP,
+ EV_KEY, KEY_PROPS,
+ EV_KEY, KEY_UNDO,
+ EV_KEY, KEY_COPY,
+ EV_KEY, KEY_OPEN,
+ EV_KEY, KEY_PASTE,
+ EV_KEY, KEY_FIND,
+ EV_KEY, KEY_CUT,
+ EV_KEY, KEY_HELP,
+ EV_KEY, KEY_MENU,
+ EV_KEY, KEY_CALC,
+ EV_KEY, KEY_SLEEP,
+ EV_KEY, KEY_FILE,
+ EV_KEY, KEY_WWW,
+ EV_KEY, KEY_COFFEE,
+ EV_KEY, KEY_MAIL,
+ EV_KEY, KEY_BOOKMARKS,
+ EV_KEY, KEY_BACK,
+ EV_KEY, KEY_FORWARD,
+ EV_KEY, KEY_EJECTCD,
+ EV_KEY, KEY_NEXTSONG,
+ EV_KEY, KEY_PLAYPAUSE,
+ EV_KEY, KEY_PREVIOUSSONG,
+ EV_KEY, KEY_STOPCD,
+ EV_KEY, KEY_RECORD,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 EV_KEY, KEY_DVD,
+ EV_KEY, KEY_AUDIO,
+ EV_KEY, KEY_VIDEO,
+ EV_KEY, KEY_MEMO,
+ EV_KEY, KEY_CALENDAR,
+ EV_KEY, KEY_RED,
+ EV_KEY, KEY_GREEN,
+ EV_KEY, KEY_YELLOW,
+ EV_KEY, KEY_BLUE,
+ EV_KEY, KEY_CHANNELUP,
+ EV_KEY, KEY_CHANNELDOWN,
+ EV_KEY, KEY_LAST,
+ EV_KEY, KEY_NEXT,
+ EV_KEY, KEY_RESTART,
+ EV_KEY, KEY_SLOW,
+ EV_KEY, KEY_SHUFFLE,
+ EV_KEY, KEY_PREVIOUS,
+ EV_KEY, KEY_VIDEOPHONE,
+ EV_KEY, KEY_GAMES,
+ EV_KEY, KEY_ZOOMIN,
+ EV_KEY, KEY_ZOOMOUT,
+ EV_KEY, KEY_ZOOMRESET,
+ EV_KEY, KEY_WORDPROCESSOR,
+ EV_KEY, KEY_EDITOR,
+ EV_KEY, KEY_SPREADSHEET,
+ EV_KEY, KEY_GRAPHICSEDITOR,
+ EV_KEY, KEY_PRESENTATION,
+ EV_KEY, KEY_DATABASE,
+ EV_KEY, KEY_NEWS,
+ EV_KEY, KEY_VOICEMAIL,
+ EV_KEY, KEY_ADDRESSBOOK,
+ EV_KEY, KEY_MESSENGER,
+ EV_KEY, KEY_DISPLAYTOGGLE,
+ EV_KEY, KEY_SPELLCHECK,
+ EV_KEY, KEY_LOGOFF,
+ EV_KEY, KEY_MEDIA_REPEAT,
+ EV_KEY, KEY_IMAGES,
+ EV_KEY, KEY_BUTTONCONFIG,
+ EV_KEY, KEY_TASKMANAGER,
+ EV_KEY, KEY_JOURNAL,
+ EV_KEY, KEY_CONTROLPANEL,
+ EV_KEY, KEY_APPSELECT,
+ EV_KEY, KEY_SCREENSAVER,
+ EV_KEY, KEY_VOICECOMMAND,
+ EV_KEY, KEY_BRIGHTNESS_MIN,
+ EV_KEY, KEY_BRIGHTNESS_MAX,
+ -1 , -1,
+};
+
+static struct input_absinfo absinfo[] = {
+ { ABS_VOLUME, 0, 572, 0, 0, 0 },
+ { ABS_MISC, 0, 0, 0, 0, 0 },
+ { ABS_MISC + 1, 0, 0, 0, 0, 0 },
+ { ABS_MISC + 2, 0, 0, 0, 0, 0 },
+ { ABS_MISC + 3, 0, 0, 0, 0, 0 },
+ { .value = -1 }
+};
+
+struct litest_test_device litest_mouse_roccat_device = {
+ .type = LITEST_MOUSE_ROCCAT,
+ .features = LITEST_RELATIVE | LITEST_BUTTON | LITEST_WHEEL,
+ .shortname = "mouse_roccat",
+ .setup = litest_mouse_roccat_setup,
+ .interface = NULL,
+
+ .name = "ROCCAT ROCCAT Kone XTD",
+ .id = &input_id,
+ .absinfo = absinfo,
+ .events = events,
+};
diff --git a/test/litest.c b/test/litest.c
index 2481f69..235ccb9 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -100,6 +100,7 @@ extern struct litest_test_device litest_protocol_a_screen;
extern struct litest_test_device litest_wacom_finger_device;
extern struct litest_test_device litest_keyboard_blackwidow_device;
extern struct litest_test_device litest_wheel_only_device;
+extern struct litest_test_device litest_mouse_roccat_device;
struct litest_test_device* devices[] = {
&litest_synaptics_clickpad_device,
@@ -121,6 +122,7 @@ struct litest_test_device* devices[] = {
&litest_wacom_finger_device,
&litest_keyboard_blackwidow_device,
&litest_wheel_only_device,
+ &litest_mouse_roccat_device,
NULL,
};
diff --git a/test/litest.h b/test/litest.h
index ca67983..e5a8030 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -55,6 +55,7 @@ enum litest_device_type {
LITEST_WACOM_FINGER = -19,
LITEST_KEYBOARD_BLACKWIDOW = -20,
LITEST_WHEEL_ONLY = -21,
+ LITEST_MOUSE_ROCCAT = -22,
};
enum litest_device_feature {
--
2.3.4
More information about the wayland-devel
mailing list