Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 src/evdev-mt-touchpad.c                      | 164 ++++++++++++++-------------
 src/evdev.c                                  | 155 +++++++++++++++++--------
 test/litest-device-alps-dualpoint.c          |  15 +--
 test/litest-device-apple-appletouch.c        |  15 +--
 test/litest-device-gpio-keys.c               |   9 +-
 test/litest-device-huion-pentablet.c         |  15 +--
 test/litest-device-lid-switch-surface3.c     |   9 +-
 test/litest-device-lid-switch.c              |   9 +-
 test/litest-device-synaptics-i2c.c           |  15 +--
 test/litest-device-synaptics-x1-carbon-3rd.c |  15 +--
 test/litest-device-waltop-tablet.c           |  15 +--
 test/test-switch.c                           |  13 +--
 test/test-tablet.c                           |  18 +--
 13 files changed, 252 insertions(+), 215 deletions(-)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index dd575510..85095b08 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -28,6 +28,7 @@
 #include <stdbool.h>
 #include <limits.h>
 
+#include "quirks.h"
 #include "evdev-mt-touchpad.h"
 
 #define DEFAULT_TRACKPOINT_ACTIVITY_TIMEOUT ms2us(300)
@@ -2835,16 +2836,25 @@ tp_dwt_config_get_default(struct libinput_device 
*device)
 static inline bool
 tp_is_tpkb_combo_below(struct evdev_device *device)
 {
-       const char *prop;
+       struct quirks_context *quirks;
+       struct quirks *q;
+       char *prop;
        enum tpkbcombo_layout layout = TPKBCOMBO_LAYOUT_UNKNOWN;
+       int rc = false;
 
-       prop = udev_device_get_property_value(device->udev_device,
-                                             "LIBINPUT_ATTR_TPKBCOMBO_LAYOUT");
-       if (!prop)
+       quirks = evdev_libinput_context(device)->quirks;
+       q = quirks_fetch_for_device(quirks, device->udev_device);
+       if (!q)
                return false;
 
-       return parse_tpkbcombo_layout_poperty(prop, &layout) &&
-               layout == TPKBCOMBO_LAYOUT_BELOW;
+       if (quirks_get_string(q, QUIRK_ATTR_TPKBCOMBO_LAYOUT, &prop)) {
+               rc = parse_tpkbcombo_layout_poperty(prop, &layout) &&
+                       layout == TPKBCOMBO_LAYOUT_BELOW;
+       }
+
+       quirks_unref(q);
+
+       return rc;
 }
 
 static inline bool
@@ -2911,19 +2921,20 @@ static int
 tp_read_palm_pressure_prop(struct tp_dispatch *tp,
                           const struct evdev_device *device)
 {
-       struct udev_device *udev_device = device->udev_device;
-       const char *prop;
-       int threshold;
        const int default_palm_threshold = 130;
+       uint32_t threshold = default_palm_threshold;
+       struct quirks_context *quirks;
+       struct quirks *q;
 
-       prop = udev_device_get_property_value(udev_device,
-                             "LIBINPUT_ATTR_PALM_PRESSURE_THRESHOLD");
-       if (!prop)
-               return default_palm_threshold;
+       quirks = evdev_libinput_context(device)->quirks;
+       q = quirks_fetch_for_device(quirks, device->udev_device);
+       if (!q)
+               return threshold;
 
-       threshold = parse_palm_pressure_property(prop);
+       quirks_get_uint32(q, QUIRK_ATTR_PALM_PRESSURE_THRESHOLD, &threshold);
+       quirks_unref(q);
 
-       return threshold > 0 ? threshold : default_palm_threshold;
+       return threshold;
 }
 
 static inline void
@@ -2947,24 +2958,26 @@ static inline void
 tp_init_palmdetect_size(struct tp_dispatch *tp,
                        struct evdev_device *device)
 {
-       const char *prop;
-       int threshold;
+       struct quirks_context *quirks;
+       struct quirks *q;
+       uint32_t threshold;
 
-       prop = udev_device_get_property_value(device->udev_device,
-                                             
"LIBINPUT_ATTR_PALM_SIZE_THRESHOLD");
-       if (!prop)
+       quirks = evdev_libinput_context(device)->quirks;
+       q = quirks_fetch_for_device(quirks, device->udev_device);
+       if (!q)
                return;
 
-       threshold = parse_palm_size_property(prop);
-       if (threshold == 0) {
-               evdev_log_bug_client(device,
-                                    "palm: ignoring invalid threshold %s\n",
-                                    prop);
-               return;
+       if (quirks_get_uint32(q, QUIRK_ATTR_PALM_SIZE_THRESHOLD, &threshold)) {
+               if (threshold == 0) {
+                       evdev_log_bug_client(device,
+                                            "palm: ignoring invalid threshold 
%d\n",
+                                            threshold);
+               } else {
+                       tp->palm.use_size = true;
+                       tp->palm.size_threshold = threshold;
+               }
        }
-
-       tp->palm.use_size = true;
-       tp->palm.size_threshold = threshold;
+       quirks_unref(q);
 }
 
 static inline void
@@ -3039,25 +3052,6 @@ tp_init_sendevents(struct tp_dispatch *tp,
                            tp_keyboard_timeout, tp);
 }
 
-static int
-tp_read_thumb_pressure_prop(struct tp_dispatch *tp,
-                           const struct evdev_device *device)
-{
-       struct udev_device *udev_device = device->udev_device;
-       const char *prop;
-       int threshold;
-       const int default_thumb_threshold = 0;
-
-       prop = udev_device_get_property_value(udev_device,
-                             "LIBINPUT_ATTR_THUMB_PRESSURE_THRESHOLD");
-       if (!prop)
-               return default_thumb_threshold;
-
-       threshold = parse_thumb_pressure_property(prop);
-
-       return threshold > 0 ? threshold : default_thumb_threshold;
-}
-
 static void
 tp_init_thumb(struct tp_dispatch *tp)
 {
@@ -3066,7 +3060,9 @@ tp_init_thumb(struct tp_dispatch *tp)
        double w = 0.0, h = 0.0;
        struct device_coords edges;
        struct phys_coords mm = { 0.0, 0.0 };
-       int threshold;
+       uint32_t threshold;
+       struct quirks_context *quirks;
+       struct quirks *q;
 
        if (!tp->buttons.is_clickpad)
                return;
@@ -3095,11 +3091,13 @@ tp_init_thumb(struct tp_dispatch *tp)
        if (!abs)
                goto out;
 
-       threshold = tp_read_thumb_pressure_prop(tp, device);
-       if (threshold == 0)
-               goto out;
-
-       tp->thumb.threshold = threshold;
+       quirks = evdev_libinput_context(device)->quirks;
+       q = quirks_fetch_for_device(quirks, device->udev_device);
+       if (quirks_get_uint32(q,
+                             QUIRK_ATTR_THUMB_PRESSURE_THRESHOLD,
+                             &threshold))
+               tp->thumb.threshold = threshold;
+       quirks_unref(q);
 
 out:
        evdev_log_debug(device,
@@ -3197,7 +3195,9 @@ tp_init_pressure(struct tp_dispatch *tp,
 {
        const struct input_absinfo *abs;
        unsigned int code;
-       const char *prop;
+       struct quirks_context *quirks;
+       struct quirks *q;
+       struct quirk_range r;
        int hi, lo;
 
        code = tp->has_mt ? ABS_MT_PRESSURE : ABS_PRESSURE;
@@ -3209,20 +3209,16 @@ tp_init_pressure(struct tp_dispatch *tp,
        abs = libevdev_get_abs_info(device->evdev, code);
        assert(abs);
 
-       prop = udev_device_get_property_value(device->udev_device,
-                                             "LIBINPUT_ATTR_PRESSURE_RANGE");
-       if (prop) {
-               if (!parse_range_property(prop, &hi, &lo)) {
-                       evdev_log_bug_client(device,
-                                    "discarding invalid pressure range '%s'\n",
-                                    prop);
-                       return;
-               }
+       quirks = evdev_libinput_context(device)->quirks;
+       q = quirks_fetch_for_device(quirks, device->udev_device);
+       if (q && quirks_get_range(q, QUIRK_ATTR_PRESSURE_RANGE, &r)) {
+               hi = r.upper;
+               lo = r.lower;
 
                if (hi == 0 && lo == 0) {
                        evdev_log_info(device,
                               "pressure-based touch detection disabled\n");
-                       return;
+                       goto out;
                }
        } else {
                unsigned int range = abs->maximum - abs->minimum;
@@ -3232,12 +3228,13 @@ tp_init_pressure(struct tp_dispatch *tp,
                lo = abs->minimum + 0.10 * range;
        }
 
+
        if (hi > abs->maximum || hi < abs->minimum ||
            lo > abs->maximum || lo < abs->minimum) {
                evdev_log_bug_libinput(device,
                               "discarding out-of-bounds pressure range 
%d:%d\n",
                               hi, lo);
-               return;
+               goto out;
        }
 
        tp->pressure.use_pressure = true;
@@ -3248,14 +3245,19 @@ tp_init_pressure(struct tp_dispatch *tp,
                        "using pressure-based touch detection (%d:%d)\n",
                        lo,
                        hi);
+out:
+       quirks_unref(q);
 }
 
 static bool
 tp_init_touch_size(struct tp_dispatch *tp,
                   struct evdev_device *device)
 {
-       const char *prop;
+       struct quirks_context *quirks;
+       struct quirks *q;
+       struct quirk_range r;
        int lo, hi;
+       int rc = false;
 
        if (!libevdev_has_event_code(device->evdev,
                                     EV_ABS,
@@ -3263,28 +3265,25 @@ tp_init_touch_size(struct tp_dispatch *tp,
                return false;
        }
 
-       prop = udev_device_get_property_value(device->udev_device,
-                                             "LIBINPUT_ATTR_TOUCH_SIZE_RANGE");
-       if (!prop)
-               return false;
+       quirks = evdev_libinput_context(device)->quirks;
+       q = quirks_fetch_for_device(quirks, device->udev_device);
+       if (q && quirks_get_range(q, QUIRK_ATTR_TOUCH_SIZE_RANGE, &r)) {
+               hi = r.upper;
+               lo = r.lower;
+       } else {
+               goto out;
+       }
 
        if (libevdev_get_num_slots(device->evdev) < 5) {
                evdev_log_bug_libinput(device,
                               "Expected 5+ slots for touch size detection\n");
-               return false;
-       }
-
-       if (!parse_range_property(prop, &hi, &lo)) {
-               evdev_log_bug_client(device,
-                                    "discarding invalid touch size range 
'%s'\n",
-                                    prop);
-               return false;
+               goto out;
        }
 
        if (hi == 0 && lo == 0) {
                evdev_log_info(device,
                               "touch size based touch detection disabled\n");
-               return false;
+               goto out;
        }
 
        /* Thresholds apply for both major or minor */
@@ -3296,7 +3295,10 @@ tp_init_touch_size(struct tp_dispatch *tp,
                        "using size-based touch detection (%d:%d)\n",
                        hi, lo);
 
-       return true;
+       rc = true;
+out:
+       quirks_unref(q);
+       return rc;
 }
 
 static int
diff --git a/src/evdev.c b/src/evdev.c
index e93dda6b..9fb11d83 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -43,6 +43,7 @@
 #include "evdev.h"
 #include "filter.h"
 #include "libinput-private.h"
+#include "quirks.h"
 
 #if HAVE_LIBWACOM
 #include <libwacom/libwacom.h>
@@ -410,7 +411,9 @@ static void
 evdev_tag_keyboard(struct evdev_device *device,
                   struct udev_device *udev_device)
 {
-       const char *prop;
+       struct quirks_context *quirks;
+       struct quirks *q;
+       char *prop;
        int code;
 
        if (!libevdev_has_event_type(device->evdev, EV_KEY))
@@ -423,10 +426,9 @@ evdev_tag_keyboard(struct evdev_device *device,
                        return;
        }
 
-       /* This should eventually become ID_INPUT_KEYBOARD_INTEGRATION */
-       prop = udev_device_get_property_value(udev_device,
-                                             
"LIBINPUT_ATTR_KEYBOARD_INTEGRATION");
-       if (prop) {
+       quirks = evdev_libinput_context(device)->quirks;
+       q = quirks_fetch_for_device(quirks, device->udev_device);
+       if (q && quirks_get_string(q, QUIRK_ATTR_KEYBOARD_INTEGRATION, &prop)) {
                if (streq(prop, "internal")) {
                        evdev_tag_keyboard_internal(device);
                } else if (streq(prop, "external")) {
@@ -438,6 +440,8 @@ evdev_tag_keyboard(struct evdev_device *device,
                }
        }
 
+       quirks_unref(q);
+
        device->tags |= EVDEV_TAG_KEYBOARD;
 }
 
@@ -796,12 +800,16 @@ evdev_is_fake_mt_device(struct evdev_device *device)
 enum switch_reliability
 evdev_read_switch_reliability_prop(struct evdev_device *device)
 {
-       const char *prop;
        enum switch_reliability r;
+       struct quirks_context *quirks;
+       struct quirks *q;
+       char *prop;
 
-       prop = udev_device_get_property_value(device->udev_device,
-                                             
"LIBINPUT_ATTR_LID_SWITCH_RELIABILITY");
-       if (!parse_switch_reliability_property(prop, &r)) {
+       quirks = evdev_libinput_context(device)->quirks;
+       q = quirks_fetch_for_device(quirks, device->udev_device);
+       if (!q || !quirks_get_string(q, QUIRK_ATTR_LID_SWITCH_RELIABILITY, 
&prop)) {
+               r = RELIABILITY_UNKNOWN;
+       } else if (!parse_switch_reliability_property(prop, &r)) {
                evdev_log_error(device,
                                "%s: switch reliability set to unknown value 
'%s'\n",
                                device->devname,
@@ -811,6 +819,8 @@ evdev_read_switch_reliability_prop(struct evdev_device 
*device)
                evdev_log_info(device, "will write switch open events\n");
        }
 
+       quirks_unref(q);
+
        return r;
 }
 
@@ -1169,22 +1179,17 @@ evdev_read_wheel_tilt_props(struct evdev_device *device)
 static inline int
 evdev_get_trackpoint_range(struct evdev_device *device)
 {
+       struct quirks_context *quirks;
+       struct quirks *q;
        const char *prop;
-       int range = DEFAULT_TRACKPOINT_RANGE;
+       uint32_t range = DEFAULT_TRACKPOINT_RANGE;
 
        if (!(device->tags & EVDEV_TAG_TRACKPOINT))
                return DEFAULT_TRACKPOINT_RANGE;
 
-       prop = udev_device_get_property_value(device->udev_device,
-                                             "LIBINPUT_ATTR_TRACKPOINT_RANGE");
-       if (prop) {
-               if (!safe_atoi(prop, &range) || range < 0.0) {
-                       evdev_log_error(device,
-                                       "trackpoint range property is present 
but invalid, "
-                                       "using %d instead\n",
-                                       DEFAULT_TRACKPOINT_RANGE);
-                       range = DEFAULT_TRACKPOINT_RANGE;
-               }
+       quirks = evdev_libinput_context(device)->quirks;
+       q = quirks_fetch_for_device(quirks, device->udev_device);
+       if (q && quirks_get_uint32(q, QUIRK_ATTR_TRACKPOINT_RANGE, &range)) {
                goto out;
        }
 
@@ -1215,6 +1220,8 @@ evdev_get_trackpoint_range(struct evdev_device *device)
        }
 
 out:
+       quirks_unref(q);
+
        if (range == 0) {
                evdev_log_bug_libinput(device, "trackpoint range is zero\n");
                range = DEFAULT_TRACKPOINT_RANGE;
@@ -1256,12 +1263,11 @@ static inline uint32_t
 evdev_read_model_flags(struct evdev_device *device)
 {
        const struct model_map {
-               const char *property;
+               enum quirk quirk;
                enum evdev_device_model model;
        } model_map[] = {
-#define MODEL(name) { "LIBINPUT_MODEL_" #name, EVDEV_MODEL_##name }
+#define MODEL(name) { QUIRK_MODEL_##name, EVDEV_MODEL_##name }
                MODEL(LENOVO_X230),
-               MODEL(LENOVO_X220_TOUCHPAD_FW81),
                MODEL(CHROMEBOOK),
                MODEL(SYSTEM76_BONOBO),
                MODEL(SYSTEM76_GALAGO),
@@ -1290,29 +1296,62 @@ evdev_read_model_flags(struct evdev_device *device)
                MODEL(LENOVO_CARBON_X1_6TH),
                MODEL(LENOVO_SCROLLPOINT),
 #undef MODEL
-               { "ID_INPUT_TRACKBALL", EVDEV_MODEL_TRACKBALL },
-               { NULL, EVDEV_MODEL_DEFAULT },
+               { 0, 0 },
        };
        const struct model_map *m = model_map;
        uint32_t model_flags = 0;
        uint32_t all_model_flags = 0;
+       struct quirks_context *quirks;
+       struct quirks *q;
+
+       quirks = evdev_libinput_context(device)->quirks;
+       q = quirks_fetch_for_device(quirks, device->udev_device);
+
+       while (q && m->quirk) {
+               bool is_set;
 
-       while (m->property) {
                /* Check for flag re-use */
-               if (strneq("LIBINPUT_MODEL_", m->property, 15)) {
-                       assert((all_model_flags & m->model) == 0);
-                       all_model_flags |= m->model;
-               }
+               assert((all_model_flags & m->model) == 0);
+               all_model_flags |= m->model;
 
-               if (parse_udev_flag(device,
-                                   device->udev_device,
-                                   m->property)) {
-                       evdev_log_debug(device, "tagged as %s\n", m->property);
-                       model_flags |= m->model;
+               if (quirks_get_bool(q, m->quirk, &is_set)) {
+                       if (is_set) {
+                               evdev_log_debug(device,
+                                               "tagged as %s\n",
+                                               quirk_get_name(m->quirk));
+                               model_flags |= m->model;
+                       } else {
+                               evdev_log_debug(device,
+                                               "untagged as %s\n",
+                                               quirk_get_name(m->quirk));
+                               model_flags &= ~m->model;
+                       }
                }
+
                m++;
        }
 
+       quirks_unref(q);
+
+       if (parse_udev_flag(device,
+                           device->udev_device,
+                           "ID_INPUT_TRACKBALL")) {
+               evdev_log_debug(device, "tagged as trackball\n");
+               model_flags |= EVDEV_MODEL_TRACKBALL;
+       }
+
+       /**
+        * Device is 6 years old at the time of writing this and this was
+        * one of the few udev properties that wasn't reserved for private
+        * usage, so we need to keep this for backwards compat.
+        */
+       if (parse_udev_flag(device,
+                           device->udev_device,
+                           "LIBINPUT_MODEL_LENOVO_X220_TOUCHPAD_FW81")) {
+               evdev_log_debug(device, "tagged as trackball\n");
+               model_flags |= EVDEV_MODEL_LENOVO_X220_TOUCHPAD_FW81;
+       }
+
        return model_flags;
 }
 
@@ -1321,16 +1360,25 @@ evdev_read_attr_res_prop(struct evdev_device *device,
                         size_t *xres,
                         size_t *yres)
 {
-       struct udev_device *udev;
-       const char *res_prop;
+       struct quirks_context *quirks;
+       struct quirks *q;
+       struct quirk_dimensions dim;
+       bool rc = false;
 
-       udev = device->udev_device;
-       res_prop = udev_device_get_property_value(udev,
-                                                  
"LIBINPUT_ATTR_RESOLUTION_HINT");
-       if (!res_prop)
+       quirks = evdev_libinput_context(device)->quirks;
+       q = quirks_fetch_for_device(quirks, device->udev_device);
+       if (!q)
                return false;
 
-       return parse_dimension_property(res_prop, xres, yres);
+       rc = quirks_get_dimensions(q, QUIRK_ATTR_RESOLUTION_HINT, &dim);
+       if (rc) {
+               *xres = dim.x;
+               *yres = dim.y;
+       }
+
+       quirks_unref(q);
+
+       return rc;
 }
 
 static inline bool
@@ -1338,16 +1386,25 @@ evdev_read_attr_size_prop(struct evdev_device *device,
                          size_t *size_x,
                          size_t *size_y)
 {
-       struct udev_device *udev;
-       const char *size_prop;
+       struct quirks_context *quirks;
+       struct quirks *q;
+       struct quirk_dimensions dim;
+       bool rc = false;
 
-       udev = device->udev_device;
-       size_prop = udev_device_get_property_value(udev,
-                                                  "LIBINPUT_ATTR_SIZE_HINT");
-       if (!size_prop)
+       quirks = evdev_libinput_context(device)->quirks;
+       q = quirks_fetch_for_device(quirks, device->udev_device);
+       if (!q)
                return false;
 
-       return parse_dimension_property(size_prop, size_x, size_y);
+       rc = quirks_get_dimensions(q, QUIRK_ATTR_SIZE_HINT, &dim);
+       if (rc) {
+               *size_x = dim.x;
+               *size_y = dim.y;
+       }
+
+       quirks_unref(q);
+
+       return rc;
 }
 
 /* Return 1 if the device is set to the fake resolution or 0 otherwise */
diff --git a/test/litest-device-alps-dualpoint.c 
b/test/litest-device-alps-dualpoint.c
index 7e68ec61..b9943001 100644
--- a/test/litest-device-alps-dualpoint.c
+++ b/test/litest-device-alps-dualpoint.c
@@ -103,15 +103,10 @@ static struct input_absinfo absinfo[] = {
        { .value = -1 }
 };
 
-static const char udev_rule[] =
-"ACTION==\"remove\", GOTO=\"touchpad_end\"\n"
-"KERNEL!=\"event*\", GOTO=\"touchpad_end\"\n"
-"ENV{ID_INPUT_TOUCHPAD}==\"\", GOTO=\"touchpad_end\"\n"
-"\n"
-"ATTRS{name}==\"litest AlpsPS/2 ALPS DualPoint TouchPad\","
-"    ENV{LIBINPUT_MODEL_TOUCHPAD_VISIBLE_MARKER}=\"1\"\n"
-"\n"
-"LABEL=\"touchpad_end\"";
+static const char quirk_file[] =
+"[litest ALPS Touchpad]\n"
+"MatchName=litest AlpsPS/2 ALPS DualPoint TouchPad\n"
+"ModelTouchpadVisibleMarker=1\n";
 
 TEST_DEVICE("alps-dualpoint",
        .type = LITEST_ALPS_DUALPOINT,
@@ -122,5 +117,5 @@ TEST_DEVICE("alps-dualpoint",
        .id = &input_id,
        .events = events,
        .absinfo = absinfo,
-       .udev_rule = udev_rule,
+       .quirk_file = quirk_file,
 )
diff --git a/test/litest-device-apple-appletouch.c 
b/test/litest-device-apple-appletouch.c
index fa13e8e5..c7a9e4f1 100644
--- a/test/litest-device-apple-appletouch.c
+++ b/test/litest-device-apple-appletouch.c
@@ -83,15 +83,10 @@ static struct input_absinfo absinfo[] = {
        { .value = -1 }
 };
 
-static const char udev_rule[] =
-"ACTION==\"remove\", GOTO=\"touchpad_end\"\n"
-"KERNEL!=\"event*\", GOTO=\"touchpad_end\"\n"
-"ENV{ID_INPUT_TOUCHPAD}==\"\", GOTO=\"touchpad_end\"\n"
-"\n"
-"ATTRS{name}==\"litest appletouch\","
-"    ENV{LIBINPUT_MODEL_APPLE_TOUCHPAD_ONEBUTTON}=\"1\"\n"
-"\n"
-"LABEL=\"touchpad_end\"";
+static const char quirk_file[] =
+"[litest ALPS Touchpad]\n"
+"MatchName=litest appletouch\n"
+"ModelAppleTouchpadOneButton=1\n";
 
 TEST_DEVICE("appletouch",
        .type = LITEST_APPLETOUCH,
@@ -102,5 +97,5 @@ TEST_DEVICE("appletouch",
        .id = &input_id,
        .events = events,
        .absinfo = absinfo,
-       .udev_rule = udev_rule,
+       .quirk_file = quirk_file,
 )
diff --git a/test/litest-device-gpio-keys.c b/test/litest-device-gpio-keys.c
index 67993912..ee226de1 100644
--- a/test/litest-device-gpio-keys.c
+++ b/test/litest-device-gpio-keys.c
@@ -47,11 +47,15 @@ static const char udev_rule[] =
 "KERNEL!=\"event*\", GOTO=\"switch_end\"\n"
 "\n"
 "ATTRS{name}==\"litest gpio-keys*\",\\\n"
-"    ENV{ID_INPUT_SWITCH}=\"1\",\\\n"
-"    ENV{LIBINPUT_ATTR_LID_SWITCH_RELIABILITY}=\"reliable\"\n"
+"    ENV{ID_INPUT_SWITCH}=\"1\"\n"
 "\n"
 "LABEL=\"switch_end\"";
 
+static const char quirk_file[] =
+"[litest gpio quirk]\n"
+"MatchName=litest gpio-keys\n"
+"AttrLidSwitchReliability=reliable\n";
+
 TEST_DEVICE("gpio-keys",
        .type = LITEST_GPIO_KEYS,
        .features = LITEST_SWITCH,
@@ -63,4 +67,5 @@ TEST_DEVICE("gpio-keys",
        .absinfo = NULL,
 
        .udev_rule = udev_rule,
+       .quirk_file = quirk_file,
 )
diff --git a/test/litest-device-huion-pentablet.c 
b/test/litest-device-huion-pentablet.c
index 053212b9..26b8adfb 100644
--- a/test/litest-device-huion-pentablet.c
+++ b/test/litest-device-huion-pentablet.c
@@ -88,15 +88,10 @@ static int events[] = {
        -1, -1,
 };
 
-static const char udev_rule[] =
-"ACTION==\"remove\", GOTO=\"huion_end\"\n"
-"KERNEL!=\"event*\", GOTO=\"huion_end\"\n"
-"ENV{ID_INPUT_TABLET}==\"\", GOTO=\"huion_end\"\n"
-"\n"
-"ATTRS{name}==\"litest HUION PenTablet Pen\","
-"    ENV{LIBINPUT_MODEL_TABLET_NO_PROXIMITY_OUT}=\"1\"\n"
-"\n"
-"LABEL=\"huion_end\"";
+static const char quirk_file[] =
+"[litest HUION tablet]\n"
+"MatchName=litest HUION PenTablet Pen\n"
+"ModelTabletNoProximityOut=1\n";
 
 TEST_DEVICE("huion-tablet",
        .type = LITEST_HUION_TABLET,
@@ -107,5 +102,5 @@ TEST_DEVICE("huion-tablet",
        .id = &input_id,
        .events = events,
        .absinfo = absinfo,
-       .udev_rule = udev_rule,
+       .quirk_file = quirk_file,
 )
diff --git a/test/litest-device-lid-switch-surface3.c 
b/test/litest-device-lid-switch-surface3.c
index a0df1696..8d72b672 100644
--- a/test/litest-device-lid-switch-surface3.c
+++ b/test/litest-device-lid-switch-surface3.c
@@ -43,11 +43,15 @@ static const char udev_rule[] =
 "KERNEL!=\"event*\", GOTO=\"switch_end\"\n"
 "\n"
 "ATTRS{name}==\"litest Lid Switch Surface3*\",\\\n"
-"    ENV{ID_INPUT_SWITCH}=\"1\",\\\n"
-"    ENV{LIBINPUT_ATTR_LID_SWITCH_RELIABILITY}=\"write_open\"\n"
+"    ENV{ID_INPUT_SWITCH}=\"1\"\n"
 "\n"
 "LABEL=\"switch_end\"";
 
+static const char quirk_file[] =
+"[litest Surface Lid]\n"
+"MatchName=litest Lid Switch Surface3\n"
+"AttrLidSwitchReliability=write_open\n";
+
 TEST_DEVICE("lid-switch-surface3",
        .type = LITEST_LID_SWITCH_SURFACE3,
        .features = LITEST_SWITCH,
@@ -59,4 +63,5 @@ TEST_DEVICE("lid-switch-surface3",
        .absinfo = NULL,
 
        .udev_rule = udev_rule,
+       .quirk_file = quirk_file,
 )
diff --git a/test/litest-device-lid-switch.c b/test/litest-device-lid-switch.c
index 5c141cb3..e7b4e7c9 100644
--- a/test/litest-device-lid-switch.c
+++ b/test/litest-device-lid-switch.c
@@ -42,11 +42,15 @@ static const char udev_rule[] =
 "KERNEL!=\"event*\", GOTO=\"switch_end\"\n"
 "\n"
 "ATTRS{name}==\"litest Lid Switch\",\\\n"
-"    ENV{ID_INPUT_SWITCH}=\"1\",\\\n"
-"    ENV{LIBINPUT_ATTR_LID_SWITCH_RELIABILITY}=\"reliable\"\n"
+"    ENV{ID_INPUT_SWITCH}=\"1\"\n"
 "\n"
 "LABEL=\"switch_end\"";
 
+static const char quirk_file[] =
+"[litest Lid Switch]\n"
+"MatchName=litest Lid Switch\n"
+"AttrLidSwitchReliability=reliable\n";
+
 TEST_DEVICE("lid-switch",
        .type = LITEST_LID_SWITCH,
        .features = LITEST_SWITCH,
@@ -58,4 +62,5 @@ TEST_DEVICE("lid-switch",
        .absinfo = NULL,
 
        .udev_rule = udev_rule,
+       .quirk_file = quirk_file,
 )
diff --git a/test/litest-device-synaptics-i2c.c 
b/test/litest-device-synaptics-i2c.c
index d32e0a50..ce2d905b 100644
--- a/test/litest-device-synaptics-i2c.c
+++ b/test/litest-device-synaptics-i2c.c
@@ -79,15 +79,10 @@ static struct input_absinfo absinfo[] = {
        { .value = -1 }
 };
 
-static const char udev_rule[] =
-"ACTION==\"remove\", GOTO=\"touchpad_end\"\n"
-"KERNEL!=\"event*\", GOTO=\"touchpad_end\"\n"
-"ENV{ID_INPUT_TOUCHPAD}==\"\", GOTO=\"touchpad_end\"\n"
-"\n"
-"ATTRS{name}==\"litest DLL0704:01 06CB:76AD Touchpad\","
-"    ENV{LIBINPUT_MODEL_TOUCHPAD_VISIBLE_MARKER}=\"1\"\n"
-"\n"
-"LABEL=\"touchpad_end\"";
+static const char quirk_file[] =
+"[litest Synaptics i2c Touchpad]\n"
+"MatchName=litest DLL0704:01 06CB:76AD Touchpad\n"
+"ModelTouchpadVisibleMarker=1\n";
 
 TEST_DEVICE("synaptics-i2c",
        .type = LITEST_SYNAPTICS_I2C,
@@ -98,5 +93,5 @@ TEST_DEVICE("synaptics-i2c",
        .id = &input_id,
        .events = events,
        .absinfo = absinfo,
-       .udev_rule = udev_rule,
+       .quirk_file = quirk_file,
 )
diff --git a/test/litest-device-synaptics-x1-carbon-3rd.c 
b/test/litest-device-synaptics-x1-carbon-3rd.c
index 73fac59a..b3efe47a 100644
--- a/test/litest-device-synaptics-x1-carbon-3rd.c
+++ b/test/litest-device-synaptics-x1-carbon-3rd.c
@@ -105,15 +105,10 @@ static struct input_absinfo absinfo[] = {
        { .value = -1 }
 };
 
-static const char udev_rule[] =
-"ACTION==\"remove\", GOTO=\"touchpad_end\"\n"
-"KERNEL!=\"event*\", GOTO=\"touchpad_end\"\n"
-"ENV{ID_INPUT_TOUCHPAD}==\"\", GOTO=\"touchpad_end\"\n"
-"\n"
-"ATTRS{name}==\"litest SynPS/2 Synaptics TouchPad X1C3rd\","
-"    ENV{LIBINPUT_MODEL_LENOVO_T450_TOUCHPAD}=\"1\"\n"
-"\n"
-"LABEL=\"touchpad_end\"";
+static const char quirk_file[] =
+"[litest Synaptics X1 Carbon 3rd Touchpad]\n"
+"MatchName=litest SynPS/2 Synaptics TouchPad X1C3rd\n"
+"ModelLenovoT450Touchpad=1\n";
 
 TEST_DEVICE("synaptics-carbon3rd",
        .type = LITEST_SYNAPTICS_TRACKPOINT_BUTTONS,
@@ -124,5 +119,5 @@ TEST_DEVICE("synaptics-carbon3rd",
        .id = &input_id,
        .events = events,
        .absinfo = absinfo,
-       .udev_rule = udev_rule,
+       .quirk_file = quirk_file,
 )
diff --git a/test/litest-device-waltop-tablet.c 
b/test/litest-device-waltop-tablet.c
index 96052e27..7aa69d99 100644
--- a/test/litest-device-waltop-tablet.c
+++ b/test/litest-device-waltop-tablet.c
@@ -220,15 +220,10 @@ static int events[] = {
        -1, -1,
 };
 
-static const char udev_rule[] =
-"ACTION==\"remove\", GOTO=\"waltop_end\"\n"
-"KERNEL!=\"event*\", GOTO=\"waltop_end\"\n"
-"ENV{ID_INPUT_TABLET}==\"\", GOTO=\"waltop_end\"\n"
-"\n"
-"ATTRS{name}==\"litest          WALTOP     Batteryless Tablet*\",\\\n"
-"    ENV{LIBINPUT_ATTR_SIZE_HINT}=\"200x200\"\n"
-"\n"
-"LABEL=\"waltop_end\"";
+static const char quirk_file[] =
+"[litest Waltop Tablet]\n"
+"MatchName=litest          WALTOP     Batteryless Tablet*\n"
+"AttrSizeHint=200x200\n";
 
 TEST_DEVICE("waltop-tablet",
        .type = LITEST_WALTOP,
@@ -239,5 +234,5 @@ TEST_DEVICE("waltop-tablet",
        .id = &input_id,
        .events = events,
        .absinfo = absinfo,
-       .udev_rule = udev_rule,
+       .quirk_file = quirk_file,
 )
diff --git a/test/test-switch.c b/test/test-switch.c
index 74cb43e0..043a8e3a 100644
--- a/test/test-switch.c
+++ b/test/test-switch.c
@@ -143,16 +143,15 @@ END_TEST
 static bool
 lid_switch_is_reliable(struct litest_device *dev)
 {
-       struct udev_device *udev_device;
-       const char *prop;
+       char *prop;
        bool is_reliable = false;
 
-       udev_device = libinput_device_get_udev_device(dev->libinput_device);
-       prop = udev_device_get_property_value(udev_device,
-                                             
"LIBINPUT_ATTR_LID_SWITCH_RELIABILITY");
+       if (quirks_get_string(dev->quirks,
+                             QUIRK_ATTR_LID_SWITCH_RELIABILITY,
+                             &prop)) {
+               is_reliable = streq(prop, "reliable");
+       }
 
-       is_reliable = prop && streq(prop, "reliable");
-       udev_device_unref(udev_device);
 
        return is_reliable;
 }
diff --git a/test/test-tablet.c b/test/test-tablet.c
index 92c52ae8..1638b20d 100644
--- a/test/test-tablet.c
+++ b/test/test-tablet.c
@@ -293,19 +293,13 @@ END_TEST
 static inline bool
 tablet_has_proxout_quirk(struct litest_device *dev)
 {
-       struct udev_device *udev_device;
-       bool has_quirk;
+       bool is_set = false;
+       if (!quirks_get_bool(dev->quirks,
+                            QUIRK_MODEL_TABLET_NO_PROXIMITY_OUT,
+                            &is_set))
+               return false;
 
-       udev_device = libinput_device_get_udev_device(dev->libinput_device);
-
-       has_quirk = !!udev_device_get_property_value(udev_device,
-                          "LIBINPUT_MODEL_TABLET_NO_PROXIMITY_OUT");
-       if (!has_quirk)
-               has_quirk = !libevdev_has_event_code(dev->evdev, EV_KEY, 
BTN_TOOL_PEN);
-
-       udev_device_unref(udev_device);
-
-       return has_quirk;
+       return is_set;
 }
 
 START_TEST(tip_up_prox_out)
-- 
2.14.4

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to