mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-30 01:20:21 +01:00
touchpad: mark ALPS touchpads for middle button emulation
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>
This commit is contained in:
parent
56660494ae
commit
aa46338e8a
5 changed files with 64 additions and 3 deletions
|
|
@ -678,6 +678,35 @@ tp_button_config_click_get_default_method(struct libinput_device *device)
|
|||
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)
|
||||
|
|
@ -734,9 +763,7 @@ tp_init_buttons(struct tp_dispatch *tp,
|
|||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -1516,6 +1516,7 @@ evdev_read_model(struct evdev_device *device)
|
|||
{ "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;
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ enum evdev_device_model {
|
|||
EVDEV_MODEL_CLEVO_W740SU,
|
||||
EVDEV_MODEL_APPLE_TOUCHPAD,
|
||||
EVDEV_MODEL_WACOM_TOUCHPAD,
|
||||
EVDEV_MODEL_ALPS_TOUCHPAD,
|
||||
};
|
||||
|
||||
struct mt_slot {
|
||||
|
|
|
|||
|
|
@ -1279,6 +1279,11 @@ START_TEST(middlebutton_default_touchpad)
|
|||
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);
|
||||
|
|
@ -1295,6 +1300,25 @@ START_TEST(middlebutton_default_touchpad)
|
|||
}
|
||||
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();
|
||||
|
|
@ -1360,6 +1384,7 @@ litest_setup_tests(void)
|
|||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,13 @@
|
|||
#
|
||||
# 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
|
||||
##########################################
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue