[PATCH libinput] evdev: enable button scrolling on the VirtualBox USB Tablet
Peter Hutterer
peter.hutterer at who-t.net
Tue May 29 06:41:27 UTC 2018
It's a generic tablet that maps whatever device actually interacts with
VirtualBox into evdev events. Since we can't rely on the host system to have
this feature we might as well make the guest slightly more usable.
So we need to at least make sure that button scrolling is available.
https://bugs.freedesktop.org/show_bug.cgi?id=106674
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
meson.build | 1 +
src/evdev-fallback.c | 3 ++
src/evdev.c | 1 +
src/evdev.h | 1 +
test/litest-device-virtualbox-tablet.c | 95 ++++++++++++++++++++++++++++++++++
test/litest.h | 1 +
test/test-device.c | 12 +++++
test/test-pointer.c | 5 ++
udev/90-libinput-model-quirks.hwdb | 6 +++
9 files changed, 125 insertions(+)
create mode 100644 test/litest-device-virtualbox-tablet.c
diff --git a/meson.build b/meson.build
index bb8af141..f76a7a8b 100644
--- a/meson.build
+++ b/meson.build
@@ -684,6 +684,7 @@ if get_option('tests')
'test/litest-device-xen-virtual-pointer.c',
'test/litest-device-vmware-virtual-usb-mouse.c',
'test/litest-device-yubikey.c',
+ 'test/litest-device-virtualbox-tablet.c',
'test/litest.c'
]
diff --git a/src/evdev-fallback.c b/src/evdev-fallback.c
index fa01faa4..c41a42cd 100644
--- a/src/evdev-fallback.c
+++ b/src/evdev-fallback.c
@@ -1480,6 +1480,9 @@ fallback_dispatch_create(struct libinput_device *libinput_device)
evdev_init_left_handed(device,
fallback_change_to_left_handed);
+ if (device->model_flags & EVDEV_MODEL_VIRTUALBOX_USB_TABLET)
+ device->scroll.want_button = 1;
+
if (device->scroll.want_button)
evdev_init_button_scroll(device,
fallback_change_scroll_method);
diff --git a/src/evdev.c b/src/evdev.c
index 2a7743e4..789daf9d 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1269,6 +1269,7 @@ evdev_read_model_flags(struct evdev_device *device)
MODEL(JUMPING_SEMI_MT),
MODEL(BOUNCING_KEYS),
MODEL(CYBORG_RAT),
+ MODEL(VIRTUALBOX_USB_TABLET),
MODEL(HP_STREAM11_TOUCHPAD),
MODEL(LENOVO_T450_TOUCHPAD),
MODEL(TOUCHPAD_VISIBLE_MARKER),
diff --git a/src/evdev.h b/src/evdev.h
index 0a7de392..1c0ce129 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -115,6 +115,7 @@ enum evdev_device_model {
EVDEV_MODEL_LENOVO_X220_TOUCHPAD_FW81 = (1 << 12),
EVDEV_MODEL_LENOVO_CARBON_X1_6TH = (1 << 13),
EVDEV_MODEL_CYBORG_RAT = (1 << 14),
+ EVDEV_MODEL_VIRTUALBOX_USB_TABLET = (1 << 15),
EVDEV_MODEL_HP_STREAM11_TOUCHPAD = (1 << 16),
EVDEV_MODEL_LENOVO_T450_TOUCHPAD= (1 << 17),
EVDEV_MODEL_TOUCHPAD_VISIBLE_MARKER = (1 << 18),
diff --git a/test/litest-device-virtualbox-tablet.c b/test/litest-device-virtualbox-tablet.c
new file mode 100644
index 00000000..6bf4993e
--- /dev/null
+++ b/test/litest-device-virtualbox-tablet.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright © 2018 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "config.h"
+
+#include "litest.h"
+#include "litest-int.h"
+#include <assert.h>
+
+static void touch_down(struct litest_device *d, unsigned int slot,
+ double x, double y)
+{
+ assert(slot == 0);
+
+ litest_event(d, EV_ABS, ABS_X, litest_scale(d, ABS_X, x));
+ litest_event(d, EV_ABS, ABS_Y, litest_scale(d, ABS_Y, y));
+ litest_event(d, EV_SYN, SYN_REPORT, 0);
+}
+
+static void touch_move(struct litest_device *d, unsigned int slot,
+ double x, double y)
+{
+ assert(slot == 0);
+
+ litest_event(d, EV_ABS, ABS_X, litest_scale(d, ABS_X, x));
+ litest_event(d, EV_ABS, ABS_Y, litest_scale(d, ABS_Y, y));
+ litest_event(d, EV_SYN, SYN_REPORT, 0);
+}
+
+static void touch_up(struct litest_device *d, unsigned int slot)
+{
+ assert(slot == 0);
+ litest_event(d, EV_SYN, SYN_REPORT, 0);
+}
+
+static struct litest_device_interface interface = {
+ .touch_down = touch_down,
+ .touch_move = touch_move,
+ .touch_up = touch_up,
+};
+
+static struct input_absinfo absinfo[] = {
+ { ABS_X, 0, 32767, 0, 0, 0 },
+ { ABS_Y, 0, 32767, 0, 0, 0 },
+ { .value = -1 },
+};
+
+static struct input_id input_id = {
+ .bustype = 0x03,
+ .vendor = 0x80ee,
+ .product = 0x21,
+};
+
+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_WHEEL,
+ EV_REL, REL_HWHEEL,
+ -1, -1,
+};
+
+TEST_DEVICE("virtualbox-tablet",
+ .type = LITEST_VIRTUALBOX_TABLET,
+ .features = LITEST_WHEEL | LITEST_BUTTON | LITEST_ABSOLUTE,
+ .interface = &interface,
+
+ .name = "VirtualBox USB Tablet",
+ .id = &input_id,
+ .events = events,
+ .absinfo = absinfo,
+)
+
diff --git a/test/litest.h b/test/litest.h
index 2315764b..c204c134 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -287,6 +287,7 @@ enum litest_device_type {
LITEST_MS_NANO_TRANSCEIVER_MOUSE,
LITEST_AIPTEK,
LITEST_TOUCHSCREEN_INVALID_RANGE,
+ LITEST_VIRTUALBOX_TABLET,
};
enum litest_device_feature {
diff --git a/test/test-device.c b/test/test-device.c
index 34aa9447..a62e062d 100644
--- a/test/test-device.c
+++ b/test/test-device.c
@@ -1476,6 +1476,17 @@ START_TEST(device_quirks_logitech_marble_mouse)
}
END_TEST
+START_TEST(device_quirks_virtualbox_tablet)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput_device *device = dev->libinput_device;
+ uint32_t methods;
+
+ methods = libinput_device_config_scroll_get_methods(device);
+ ck_assert(methods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
+}
+END_TEST
+
START_TEST(device_capability_at_least_one)
{
struct litest_device *dev = litest_current_device();
@@ -1642,6 +1653,7 @@ TEST_COLLECTION(device)
litest_add_for_device("device:quirks", device_quirks_cyborg_rat_mode_button, LITEST_CYBORG_RAT);
litest_add_for_device("device:quirks", device_quirks_apple_magicmouse, LITEST_MAGICMOUSE);
litest_add_for_device("device:quirks", device_quirks_logitech_marble_mouse, LITEST_LOGITECH_TRACKBALL);
+ litest_add_for_device("device:quirks", device_quirks_virtualbox_tablet, LITEST_VIRTUALBOX_TABLET);
litest_add("device:capability", device_capability_at_least_one, LITEST_ANY, LITEST_ANY);
litest_add("device:capability", device_capability_check_invalid, LITEST_ANY, LITEST_ANY);
diff --git a/test/test-pointer.c b/test/test-pointer.c
index d6ff4ffe..a0862503 100644
--- a/test/test-pointer.c
+++ b/test/test-pointer.c
@@ -1074,6 +1074,11 @@ START_TEST(pointer_scroll_button_noscroll)
uint32_t methods, button;
enum libinput_config_status status;
+ /* VirtualBox USB Tablet has a quirk to allow for button scrolling */
+ if (libevdev_get_id_vendor(dev->evdev) == 0x80EE &&
+ libevdev_get_id_product(dev->evdev) == 0x0021)
+ return;
+
methods = libinput_device_config_scroll_get_method(device);
ck_assert_int_eq((methods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN), 0);
button = libinput_device_config_scroll_get_button(device);
diff --git a/udev/90-libinput-model-quirks.hwdb b/udev/90-libinput-model-quirks.hwdb
index 06e48950..d57e38a7 100644
--- a/udev/90-libinput-model-quirks.hwdb
+++ b/udev/90-libinput-model-quirks.hwdb
@@ -345,6 +345,12 @@ libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnSystem76*pvrgalu1*
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnSystem76*pvrkudp1*
LIBINPUT_MODEL_SYSTEM76_KUDU=1
+##########################################
+# VirtualBox
+##########################################
+libinput:mouse:input:b0003v80EEp0021*
+ LIBINPUT_MODEL_VIRTUALBOX_USB_TABLET=1
+
##########################################
# Wacom
##########################################
--
2.14.3
More information about the wayland-devel
mailing list