diff --git a/doc/device-configuration-via-udev.dox b/doc/device-configuration-via-udev.dox index c22aafab..e38b93f6 100644 --- a/doc/device-configuration-via-udev.dox +++ b/doc/device-configuration-via-udev.dox @@ -63,6 +63,9 @@ libinput_pointer_get_axis_source() for details.
POINTINGSTICK_CONST_ACCEL
A constant (linear) acceleration factor to apply to pointingstick deltas to normalize them. +
LIBINPUT_MODEL_*
+
This prefix is reserved as private API, do not use.. See @ref +model_specific_configuration for details.
@@ -98,4 +101,16 @@ ACTION=="add|change", KERNEL=="event[0-9]*", ENV{ID_VENDOR_ID}=="012a", \ ENV{ID_MODEL_ID}=="034b", ENV{ID_INPUT_TOUCHPAD}="", ENV{ID_INPUT_TABLET}="1" @endcode +@section model_specific_configuration Model-specific configuration + +libinput reserves the property prefix LIBINPUT_MODEL_ for +model-specific configuration. This prefix is reserved as private API, do +not use. + +The effect of this property may be to enable or disable certain +features on a specific device or set of devices, to change configuration +defaults or any other reason. The effects of setting this property, the +format of the property and the value of the property are subject to change +at any time. + */ diff --git a/src/evdev.c b/src/evdev.c index 964b3ba1..e3bba93e 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1422,6 +1422,27 @@ evdev_read_dpi_prop(struct evdev_device *device) return dpi; } +static inline enum evdev_device_model +evdev_read_model(struct evdev_device *device) +{ + const struct model_map { + const char *property; + enum evdev_device_model model; + } model_map[] = { + { NULL, EVDEV_MODEL_DEFAULT }, + }; + const struct model_map *m = model_map; + + while (m->property) { + if (!!udev_device_get_property_value(device->udev_device, + m->property)) + break; + m++; + } + + return m->model; +} + /* Return 1 if the given resolutions have been set, or 0 otherwise */ inline int evdev_fix_abs_resolution(struct evdev_device *device, @@ -1950,6 +1971,7 @@ evdev_device_create(struct libinput_seat *seat, device->scroll.wheel_click_angle = evdev_read_wheel_click_prop(device); device->dpi = evdev_read_dpi_prop(device); + device->model = evdev_read_model(device); /* at most 5 SYN_DROPPED log-messages per 30s */ ratelimit_init(&device->syn_drop_limit, 30ULL * 1000, 5); diff --git a/src/evdev.h b/src/evdev.h index 9f244534..edd40119 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -93,6 +93,10 @@ enum evdev_middlebutton_event { MIDDLEBUTTON_EVENT_ALL_UP, }; +enum evdev_device_model { + EVDEV_MODEL_DEFAULT, +}; + struct mt_slot { int32_t seat_slot; struct device_coords point; @@ -202,6 +206,8 @@ struct evdev_device { int dpi; /* HW resolution */ struct ratelimit syn_drop_limit; /* ratelimit for SYN_DROPPED logging */ + + enum evdev_device_model model; }; #define EVDEV_UNHANDLED_DEVICE ((struct evdev_device *) 1) diff --git a/udev/90-libinput-model-quirks.hwdb b/udev/90-libinput-model-quirks.hwdb new file mode 100644 index 00000000..02bb8f97 --- /dev/null +++ b/udev/90-libinput-model-quirks.hwdb @@ -0,0 +1,16 @@ +# Do not edit this file, it will be overwritten on update +# +# This file contains hwdb matches for libinput model-specific quirks. +# The contents of this file are a contract between libinput, udev rules and +# the hwdb. +# IT IS NOT A STABLE API AND SUBJECT TO CHANGE AT ANY TIME + +# The lookup keys are composed in: +# 90-libinput-model-quirks.rules +# +# Match string formats: +# libinput: +# libinput:name::dmi: + +# +# Sort by brand, model diff --git a/udev/90-libinput-model-quirks.rules b/udev/90-libinput-model-quirks.rules new file mode 100644 index 00000000..4b988748 --- /dev/null +++ b/udev/90-libinput-model-quirks.rules @@ -0,0 +1,25 @@ +# Do not edit this file, it will be overwritten on update +# +# This file contains lookup rules for libinput model-specific quirks. +# The contents of this file are a contract between libinput, udev rules and +# the hwdb. +# IT IS NOT A STABLE API AND SUBJECT TO CHANGE AT ANY TIME +# +# The hwdb database is in: +# 90-libinput-model-quirks.hwdb + +ACTION!="add|change", GOTO="libinput_model_quirks_end" +KERNEL!="event*", GOTO="libinput_model_quirks_end" + +# hwdb matches: +# +# libinput: +IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:", \ + GOTO="libinput_model_quirks_end" + +# libinput:name::dmi: +KERNELS=="input*", \ + IMPORT{builtin}="hwdb 'libinput:name:$attr{name}:$attr{[dmi/id]modalias}'", \ + GOTO="libinput_model_quirks_end" + +LABEL="libinput_model_quirks_end" diff --git a/udev/Makefile.am b/udev/Makefile.am index 3691172c..7d19809d 100644 --- a/udev/Makefile.am +++ b/udev/Makefile.am @@ -6,4 +6,10 @@ libinput_device_group_CFLAGS = $(LIBUDEV_CFLAGS) $(GCC_CFLAGS) libinput_device_group_LDADD = $(LIBUDEV_LIBS) udev_rulesdir=$(UDEV_DIR)/rules.d -dist_udev_rules_DATA = 80-libinput-device-groups.rules +dist_udev_rules_DATA = \ + 80-libinput-device-groups.rules \ + 90-libinput-model-quirks.rules + +udev_hwdbdir=$(UDEV_DIR)/hwdb.d +dist_udev_hwdb_DATA = \ + 90-libinput-model-quirks.hwdb