From e09c822fd1747dd3b51218d2b241170da38aae5b Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 10 Sep 2018 15:16:49 +1000 Subject: [PATCH] udev: re-instate the model-quirks callout This was removed accidentally as part of a9ef4ba1f33bf8 and then completely dropped in 870ddce9e47a89 when the hwdb was deprecated completely. The model quirks call is also the one that reads and sets the LIBINPUT_FUZZ property, effectively making that code a noop. Fixes #138 Signed-off-by: Peter Hutterer --- meson.build | 11 +++++++++++ test/litest-device-touchscreen-fuzz.c | 4 ++-- test/litest.c | 5 +++++ test/test-touch.c | 26 ++++++++++++++++++++++++++ udev/90-libinput-model-quirks.rules.in | 12 ++++++++++++ 5 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 udev/90-libinput-model-quirks.rules.in diff --git a/meson.build b/meson.build index 80d8a746..ea3a9643 100644 --- a/meson.build +++ b/meson.build @@ -165,6 +165,11 @@ configure_file(input : 'udev/80-libinput-device-groups.rules.in', install : true, install_dir : dir_udev_rules, configuration : udev_rules_config) +configure_file(input : 'udev/90-libinput-model-quirks.rules.in', + output : '90-libinput-model-quirks.rules', + install : true, + install_dir : dir_udev_rules, + configuration : udev_rules_config) litest_udev_rules_config = configuration_data() litest_udev_rules_config.set('UDEV_TEST_PATH', meson.build_root() + '/') @@ -172,6 +177,10 @@ litest_groups_rules_file = configure_file(input : 'udev/80-libinput-device-group output : '80-libinput-device-groups-litest.rules', install : false, configuration : litest_udev_rules_config) +litest_model_quirks_file = configure_file(input : 'udev/90-libinput-model-quirks.rules.in', + output : '90-libinput-model-quirks-litest.rules', + install : false, + configuration : litest_udev_rules_config) ############ libepoll-shim (BSD) ############ @@ -760,6 +769,8 @@ if get_option('tests') join_paths(meson.build_root(), '80-libinput-test-device.rules')) config_h.set_quoted('LIBINPUT_DEVICE_GROUPS_RULES_FILE', join_paths(meson.build_root(), '80-libinput-device-groups.rules')) + config_h.set_quoted('LIBINPUT_MODEL_QUIRKS_UDEV_RULES_FILE', + join_paths(meson.build_root(), '90-libinput-model-quirks.rules')) def_no_main = '-DLITEST_NO_MAIN' def_disable_backtrace = '-DLITEST_DISABLE_BACKTRACE_LOGGING' diff --git a/test/litest-device-touchscreen-fuzz.c b/test/litest-device-touchscreen-fuzz.c index 77577a7f..97369eef 100644 --- a/test/litest-device-touchscreen-fuzz.c +++ b/test/litest-device-touchscreen-fuzz.c @@ -52,10 +52,10 @@ static struct litest_device_interface interface = { static struct input_absinfo absinfo[] = { { ABS_X, 0, 1500, 10, 0, 0 }, - { ABS_Y, 0, 2500, 10, 0, 0 }, + { ABS_Y, 0, 2500, 12, 0, 0 }, { ABS_MT_SLOT, 0, 9, 0, 0, 0 }, { ABS_MT_POSITION_X, 0, 1500, 10, 0, 0 }, - { ABS_MT_POSITION_Y, 0, 2500, 10, 0, 0 }, + { ABS_MT_POSITION_Y, 0, 2500, 12, 0, 0 }, { ABS_MT_PRESSURE, 0, 255, 0, 0, 0 }, { ABS_MT_TRACKING_ID, 0, 65535, 0, 0, 0 }, { .value = -1 }, diff --git a/test/litest.c b/test/litest.c index 82c33781..1efe6094 100644 --- a/test/litest.c +++ b/test/litest.c @@ -1138,6 +1138,11 @@ litest_install_model_quirks(struct list *created_files_list) LIBINPUT_DEVICE_GROUPS_RULES_FILE, warning); list_insert(created_files_list, &file->link); + + file = litest_copy_file(UDEV_MODEL_QUIRKS_RULE_FILE, + LIBINPUT_MODEL_QUIRKS_UDEV_RULES_FILE, + warning); + list_insert(created_files_list, &file->link); } static char * diff --git a/test/test-touch.c b/test/test-touch.c index dbfbc9c1..9b98cff1 100644 --- a/test/test-touch.c +++ b/test/test-touch.c @@ -911,6 +911,31 @@ START_TEST(touch_fuzz) } END_TEST +START_TEST(touch_fuzz_property) +{ + struct litest_device *dev = litest_current_device(); + struct udev_device *d; + const char *prop; + int fuzz; + + ck_assert_int_eq(libevdev_get_abs_fuzz(dev->evdev, ABS_X), 0); + ck_assert_int_eq(libevdev_get_abs_fuzz(dev->evdev, ABS_Y), 0); + + d = libinput_device_get_udev_device(dev->libinput_device); + prop = udev_device_get_property_value(d, "LIBINPUT_FUZZ_00"); + ck_assert_notnull(prop); + ck_assert(safe_atoi(prop, &fuzz)); + ck_assert_int_eq(fuzz, 10); /* device-specific */ + + prop = udev_device_get_property_value(d, "LIBINPUT_FUZZ_01"); + ck_assert_notnull(prop); + ck_assert(safe_atoi(prop, &fuzz)); + ck_assert_int_eq(fuzz, 12); /* device-specific */ + + udev_device_unref(d); +} +END_TEST + START_TEST(touch_release_on_unplug) { struct litest_device *dev; @@ -1308,6 +1333,7 @@ TEST_COLLECTION(touch) litest_add("touch:time", touch_time_usec, LITEST_TOUCH, LITEST_TOUCHPAD); litest_add_for_device("touch:fuzz", touch_fuzz, LITEST_MULTITOUCH_FUZZ_SCREEN); + litest_add_for_device("touch:fuzz", touch_fuzz_property, LITEST_MULTITOUCH_FUZZ_SCREEN); litest_add_no_device("touch:release", touch_release_on_unplug); diff --git a/udev/90-libinput-model-quirks.rules.in b/udev/90-libinput-model-quirks.rules.in new file mode 100644 index 00000000..926a6c3f --- /dev/null +++ b/udev/90-libinput-model-quirks.rules.in @@ -0,0 +1,12 @@ +# Do not edit this file, it will be overwritten on update +# +# This file contains lookup rules for libinput model-specific quirks. +# IT IS NOT A STABLE API AND SUBJECT TO CHANGE AT ANY TIME + +ACTION!="add|change", GOTO="libinput_model_quirks_end" +KERNEL!="event*", GOTO="libinput_model_quirks_end" + +IMPORT{program}="@UDEV_TEST_PATH@libinput-model-quirks %S%p" + +LABEL="libinput_model_quirks_end" +