Alps devices don't know if there is a physical middle button on the touchpad,
so they always report one.
Since a large number of touchpads only have two buttons, enable middle button
emulation by default. Those that really don't want it can play with
configuration options, everyone else has it working by default.
The hwdb entry uses "*Alps ..*" as name to also trigger the "litest Alps..."
devices.
https://bugzilla.redhat.com/show_bug.cgi?id=
1227992
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
return tp_click_get_default_method(tp);
}
+static inline void
+tp_init_middlebutton_emulation(struct tp_dispatch *tp,
+ struct evdev_device *device)
+{
+ bool enable_by_default,
+ want_config_option;
+
+ if (tp->buttons.is_clickpad)
+ return;
+
+ /* init middle button emulation on non-clickpads, but only if we
+ * don't have a middle button. Exception: ALPS touchpads don't know
+ * if they have a middle button, so we always want the option there
+ * and enabled by default.
+ */
+ if (!libevdev_has_event_code(device->evdev, EV_KEY, BTN_MIDDLE)) {
+ enable_by_default = true;
+ want_config_option = false;
+ } else if (device->model == EVDEV_MODEL_ALPS_TOUCHPAD) {
+ enable_by_default = true;
+ want_config_option = true;
+ } else
+ return;
+
+ evdev_init_middlebutton(tp->device,
+ enable_by_default,
+ want_config_option);
+}
+
int
tp_init_buttons(struct tp_dispatch *tp,
struct evdev_device *device)
tp_init_top_softbuttons(tp, device, 1.0);
- if (!tp->buttons.is_clickpad &&
- !libevdev_has_event_code(device->evdev, EV_KEY, BTN_MIDDLE))
- evdev_init_middlebutton(tp->device, true, false);
+ tp_init_middlebutton_emulation(tp, device);
tp_for_each_touch(tp, t) {
t->button.state = BUTTON_STATE_NONE;
{ "LIBINPUT_MODEL_CLEVO_W740SU", EVDEV_MODEL_CLEVO_W740SU },
{ "LIBINPUT_MODEL_APPLE_TOUCHPAD", EVDEV_MODEL_APPLE_TOUCHPAD },
{ "LIBINPUT_MODEL_WACOM_TOUCHPAD", EVDEV_MODEL_WACOM_TOUCHPAD },
+ { "LIBINPUT_MODEL_ALPS_TOUCHPAD", EVDEV_MODEL_ALPS_TOUCHPAD },
{ NULL, EVDEV_MODEL_DEFAULT },
};
const struct model_map *m = model_map;
EVDEV_MODEL_CLEVO_W740SU,
EVDEV_MODEL_APPLE_TOUCHPAD,
EVDEV_MODEL_WACOM_TOUCHPAD,
+ EVDEV_MODEL_ALPS_TOUCHPAD,
};
struct mt_slot {
struct libinput_device *device = dev->libinput_device;
enum libinput_config_middle_emulation_state state;
int available;
+ const char *name = libinput_device_get_name(dev->libinput_device);
+
+ if (streq(name, "litest AlpsPS/2 ALPS GlidePoint") ||
+ streq(name, "litest AlpsPS/2 ALPS DualPoint TouchPad"))
+ return;
available = libinput_device_config_middle_emulation_is_available(device);
ck_assert(!available);
}
END_TEST
+START_TEST(middlebutton_default_alps)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput_device *device = dev->libinput_device;
+ enum libinput_config_middle_emulation_state state;
+ int available;
+
+ available = libinput_device_config_middle_emulation_is_available(device);
+ ck_assert(available);
+
+ state = libinput_device_config_middle_emulation_get_enabled(
+ device);
+ ck_assert_int_eq(state, LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
+ state = libinput_device_config_middle_emulation_get_default_enabled(
+ device);
+ ck_assert_int_eq(state, LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
+}
+END_TEST
+
START_TEST(middlebutton_default_disabled)
{
struct litest_device *dev = litest_current_device();
litest_add("pointer:middlebutton", middlebutton_default_clickpad, LITEST_CLICKPAD, LITEST_ANY);
litest_add("pointer:middlebutton", middlebutton_default_touchpad, LITEST_TOUCHPAD, LITEST_CLICKPAD);
litest_add("pointer:middlebutton", middlebutton_default_disabled, LITEST_ANY, LITEST_BUTTON);
+ litest_add_for_device("pointer:middlebutton", middlebutton_default_alps, LITEST_ALPS_SEMI_MT);
litest_add_ranged("pointer:state", pointer_absolute_initial_state, LITEST_ABSOLUTE, LITEST_ANY, &axis_range);
}
#
# Sort by brand, model
+##########################################
+# ALPS
+##########################################
+libinput:name:*AlpsPS/2 ALPS DualPoint TouchPad:dmi:*
+libinput:name:*AlpsPS/2 ALPS GlidePoint:dmi:*
+ LIBINPUT_MODEL_ALPS_TOUCHPAD=1
+
##########################################
# Apple
##########################################