summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2021-04-14 16:18:21 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2021-04-21 00:15:42 +0000
commitf92a388c7aefa8fc5f8b065dd6e291f04fc4c036 (patch)
treecbe78510f53f109ef3ec258c7f8f535da63969e1 /src
parent144f5ed93dc70873ee7d07b0acc00d1fe5560ead (diff)
downloadlibinput-f92a388c7aefa8fc5f8b065dd6e291f04fc4c036.tar.gz
touchpad: factor out clickpad assignment to a helper
No functional changes Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r--src/evdev-mt-touchpad-buttons.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c
index 4591270e..7d8933fe 100644
--- a/src/evdev-mt-touchpad-buttons.c
+++ b/src/evdev-mt-touchpad-buttons.c
@@ -935,31 +935,41 @@ tp_init_middlebutton_emulation(struct tp_dispatch *tp,
want_config_option);
}
-void
-tp_init_buttons(struct tp_dispatch *tp,
- struct evdev_device *device)
+static bool
+tp_guess_clickpad(const struct tp_dispatch *tp, struct evdev_device *device)
{
- struct tp_touch *t;
- const struct input_absinfo *absinfo_x, *absinfo_y;
- int i;
+ bool is_clickpad;
- tp->buttons.is_clickpad = libevdev_has_property(device->evdev,
- INPUT_PROP_BUTTONPAD);
- tp->buttons.has_topbuttons = libevdev_has_property(device->evdev,
- INPUT_PROP_TOPBUTTONPAD);
+ is_clickpad = libevdev_has_property(device->evdev, INPUT_PROP_BUTTONPAD);
if (libevdev_has_event_code(device->evdev, EV_KEY, BTN_MIDDLE) ||
libevdev_has_event_code(device->evdev, EV_KEY, BTN_RIGHT)) {
- if (tp->buttons.is_clickpad)
+ if (is_clickpad)
evdev_log_bug_kernel(device,
"clickpad advertising right button\n");
} else if (libevdev_has_event_code(device->evdev, EV_KEY, BTN_LEFT) &&
- !tp->buttons.is_clickpad &&
+ !is_clickpad &&
libevdev_get_id_vendor(device->evdev) != VENDOR_ID_APPLE) {
evdev_log_bug_kernel(device,
"non clickpad without right button?\n");
}
+ return is_clickpad;
+}
+
+void
+tp_init_buttons(struct tp_dispatch *tp,
+ struct evdev_device *device)
+{
+ struct tp_touch *t;
+ const struct input_absinfo *absinfo_x, *absinfo_y;
+ int i;
+
+ tp->buttons.is_clickpad = tp_guess_clickpad(tp, device);
+
+ tp->buttons.has_topbuttons = libevdev_has_property(device->evdev,
+ INPUT_PROP_TOPBUTTONPAD);
+
absinfo_x = device->abs.absinfo_x;
absinfo_y = device->abs.absinfo_y;