summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2015-04-28 16:45:35 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2015-04-28 17:12:31 +1000
commita7b2d04e90cb66526a825deaf38da9924b4fb89e (patch)
tree0901c8dbb30c72fb48a707a45efd7e71c8431d77
parent512a00505ad45cf93a84522e132327a5b0dbc221 (diff)
evdev: enable button scrolling by default on mice without wheels
If we have a middle button but no wheels, enable on-button scrolling for the middle button by default. This applies e.g. to the Logitech trackball added as new test device here. This makes the separate check for POINTINGSTICK obsolete but I'd rather leave this in to be more explicit about it. https://bugs.freedesktop.org/show_bug.cgi?id=90208 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--src/evdev.c22
-rw-r--r--test/Makefile.am1
-rw-r--r--test/litest-logitech-trackball.c64
-rw-r--r--test/litest.c2
-rw-r--r--test/litest.h1
-rw-r--r--test/pointer.c21
6 files changed, 107 insertions, 4 deletions
diff --git a/src/evdev.c b/src/evdev.c
index d65b113..16ac499 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -983,8 +983,15 @@ evdev_scroll_get_default_method(struct libinput_device *device)
if (libevdev_has_property(evdev->evdev, INPUT_PROP_POINTING_STICK))
return LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
- else
- return LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
+
+ /* Mice without a scroll wheel but with middle button have on-button
+ * scrolling by default */
+ if (!libevdev_has_event_code(evdev->evdev, EV_REL, REL_WHEEL) &&
+ !libevdev_has_event_code(evdev->evdev, EV_REL, REL_HWHEEL) &&
+ libevdev_has_event_code(evdev->evdev, EV_KEY, BTN_MIDDLE))
+ return LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
+
+ return LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
}
static enum libinput_config_status
@@ -1016,8 +1023,15 @@ evdev_scroll_get_default_button(struct libinput_device *device)
if (libevdev_has_property(evdev->evdev, INPUT_PROP_POINTING_STICK))
return BTN_MIDDLE;
- else
- return 0;
+
+ /* A device that defaults to button scrolling defaults
+ to BTN_MIDDLE */
+ if (evdev_scroll_get_default_method(device) ==
+ LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN &&
+ libevdev_has_event_code(evdev->evdev, EV_KEY, BTN_MIDDLE))
+ return BTN_MIDDLE;
+
+ return 0;
}
static int
diff --git a/test/Makefile.am b/test/Makefile.am
index a616c5c..be0c5d9 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -18,6 +18,7 @@ liblitest_la_SOURCES = \
litest-generic-singletouch.c \
litest-keyboard.c \
litest-keyboard-razer-blackwidow.c \
+ litest-logitech-trackball.c \
litest-mouse.c \
litest-mouse-roccat.c \
litest-ms-surface-cover.c \
diff --git a/test/litest-logitech-trackball.c b/test/litest-logitech-trackball.c
new file mode 100644
index 0000000..5e862d8
--- /dev/null
+++ b/test/litest-logitech-trackball.c
@@ -0,0 +1,64 @@
+/*
+ * 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_logitech_trackball_setup(void)
+{
+ struct litest_device *d = litest_create_device(LITEST_LOGITECH_TRACKBALL);
+ litest_set_current_device(d);
+}
+
+static struct input_id input_id = {
+ .bustype = 0x3,
+ .vendor = 0x46d,
+ .product = 0xc408,
+};
+
+static int events[] = {
+ EV_KEY, BTN_LEFT,
+ EV_KEY, BTN_RIGHT,
+ EV_KEY, BTN_MIDDLE,
+ EV_KEY, BTN_SIDE,
+ EV_KEY, BTN_EXTRA,
+ EV_REL, REL_X,
+ EV_REL, REL_Y,
+ -1 , -1,
+};
+
+struct litest_test_device litest_logitech_trackball_device = {
+ .type = LITEST_LOGITECH_TRACKBALL,
+ .features = LITEST_RELATIVE | LITEST_BUTTON,
+ .shortname = "logitech trackball",
+ .setup = litest_logitech_trackball_setup,
+ .interface = NULL,
+
+ .name = "Logitech USB Trackball",
+ .id = &input_id,
+ .absinfo = NULL,
+ .events = events,
+};
diff --git a/test/litest.c b/test/litest.c
index 6d17a37..15fc87e 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -102,6 +102,7 @@ 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;
extern struct litest_test_device litest_ms_surface_cover_device;
+extern struct litest_test_device litest_logitech_trackball_device;
struct litest_test_device* devices[] = {
&litest_synaptics_clickpad_device,
@@ -125,6 +126,7 @@ struct litest_test_device* devices[] = {
&litest_wheel_only_device,
&litest_mouse_roccat_device,
&litest_ms_surface_cover_device,
+ &litest_logitech_trackball_device,
NULL,
};
diff --git a/test/litest.h b/test/litest.h
index e5a8030..611cdf7 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -56,6 +56,7 @@ enum litest_device_type {
LITEST_KEYBOARD_BLACKWIDOW = -20,
LITEST_WHEEL_ONLY = -21,
LITEST_MOUSE_ROCCAT = -22,
+ LITEST_LOGITECH_TRACKBALL = -23,
};
enum litest_device_feature {
diff --git a/test/pointer.c b/test/pointer.c
index 26d9930..1dde354 100644
--- a/test/pointer.c
+++ b/test/pointer.c
@@ -758,6 +758,26 @@ START_TEST(pointer_scroll_button)
}
END_TEST
+START_TEST(pointer_scroll_nowheel_defaults)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput_device *device = dev->libinput_device;
+ enum libinput_config_scroll_method method;
+ uint32_t button;
+
+ method = libinput_device_config_scroll_get_method(device);
+ ck_assert_int_eq(method, LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
+
+ method = libinput_device_config_scroll_get_default_method(device);
+ ck_assert_int_eq(method, LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
+
+ button = libinput_device_config_scroll_get_button(device);
+ ck_assert_int_eq(button, BTN_MIDDLE);
+ button = libinput_device_config_scroll_get_default_button(device);
+ ck_assert_int_eq(button, BTN_MIDDLE);
+}
+END_TEST
+
START_TEST(pointer_accel_defaults)
{
struct litest_device *dev = litest_current_device();
@@ -1243,6 +1263,7 @@ int main (int argc, char **argv) {
litest_add_no_device("pointer:button", pointer_seat_button_count);
litest_add("pointer:scroll", pointer_scroll_wheel, LITEST_WHEEL, LITEST_ANY);
litest_add("pointer:scroll", pointer_scroll_button, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
+ litest_add("pointer:scroll", pointer_scroll_nowheel_defaults, LITEST_RELATIVE|LITEST_BUTTON, LITEST_WHEEL);
litest_add("pointer:scroll", pointer_scroll_natural_defaults, LITEST_WHEEL, LITEST_ANY);
litest_add("pointer:scroll", pointer_scroll_natural_enable_config, LITEST_WHEEL, LITEST_ANY);
litest_add("pointer:scroll", pointer_scroll_natural_wheel, LITEST_WHEEL, LITEST_ANY);