udev: re-instate the model-quirks callout
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 10 Sep 2018 05:16:49 +0000 (15:16 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 10 Sep 2018 05:57:27 +0000 (15:57 +1000)
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 <peter.hutterer@who-t.net>
meson.build
test/litest-device-touchscreen-fuzz.c
test/litest.c
test/test-touch.c
udev/90-libinput-model-quirks.rules.in [new file with mode: 0644]

index 80d8a74..ea3a964 100644 (file)
@@ -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'
index 77577a7..97369ee 100644 (file)
@@ -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 },
index 82c3378..1efe609 100644 (file)
@@ -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 *
index dbfbc9c..9b98cff 100644 (file)
@@ -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 (file)
index 0000000..926a6c3
--- /dev/null
@@ -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"
+