[PATCH libinput 2/3] Add a rules file to assign LIBINPUT_DEVICE_GROUP
Peter Hutterer
peter.hutterer at who-t.net
Mon Feb 9 22:50:54 PST 2015
Ideally we could just take ATTRS{phys} but we can't select substrings to drop
into ENV so we re-assemble it manually.
Eventually this will likely end up in a RUN callout, but for now this will do.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Makefile.am | 2 +-
configure.ac | 10 ++++++++++
rules/80-libinput-tablet.rules | 15 +++++++++++++++
rules/Makefile.am | 4 ++++
4 files changed, 30 insertions(+), 1 deletion(-)
create mode 100644 rules/80-libinput-tablet.rules
create mode 100644 rules/Makefile.am
diff --git a/Makefile.am b/Makefile.am
index 05698ba..dfbc07d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = src doc test tools
+SUBDIRS = src doc test tools rules
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
diff --git a/configure.ac b/configure.ac
index f47c5a4..2420f86 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,6 +69,15 @@ fi
AC_SUBST(GCC_CFLAGS)
AC_SUBST(GCC_CXXFLAGS)
+AC_ARG_WITH(udev-rules-dir,
+ AS_HELP_STRING([--with-udev-rules-dir=DIR],
+ [Directory where udev expects its rules files
+ [[default=$libdir/udev/rules.d]]]),
+ [udevdir="$withval"],
+ [udevdir="$libdir/udev/rules.d"])
+UDEV_RULES_DIR=${udevdir}
+AC_SUBST(UDEV_RULES_DIR)
+
AC_ARG_ENABLE([documentation],
[AC_HELP_STRING([--enable-documentation],
[Enable building the documentation (default=auto)])],
@@ -159,6 +168,7 @@ AM_CONDITIONAL(BUILD_DOCS, [test "x$build_documentation" = "xyes"])
AC_CONFIG_FILES([Makefile
doc/Makefile
doc/libinput.doxygen
+ rules/Makefile
src/Makefile
src/libinput.pc
src/libinput-version.h
diff --git a/rules/80-libinput-tablet.rules b/rules/80-libinput-tablet.rules
new file mode 100644
index 0000000..8a8199f
--- /dev/null
+++ b/rules/80-libinput-tablet.rules
@@ -0,0 +1,15 @@
+ACTION!="add|change", GOTO="libinput_tablet_end"
+KERNEL!="event[0-9]*", GOTO="libinput_tablet_end"
+ENV{ID_INPUT_TABLET}!="1", GOTO="libinput_tablet_end"
+
+# ATTRS{phys} is mostly what we want, but without the trailing /inputX
+# udev doesn't let us substitute strings so we
+# re-build it similar to what the kernel does.
+# ATTRS{phys}=="usb-0000:00:14.0-2/input1"
+# results in a device group of "0000:00:14.0 2:
+SUBSYSTEMS=="usb", KERNELS=="usb2", \
+ ENV{LIBINPUT_DEVICE_GROUP}+="$attr{serial}"
+SUBSYSTEMS=="usb", DRIVERS=="usb", \
+ ENV{LIBINPUT_DEVICE_GROUP}+="$attr{devpath}"
+
+LABEL="libinput_tablet_end"
diff --git a/rules/Makefile.am b/rules/Makefile.am
new file mode 100644
index 0000000..5b39ac7
--- /dev/null
+++ b/rules/Makefile.am
@@ -0,0 +1,4 @@
+udevdir=$(UDEV_RULES_DIR)
+udev_DATA = 80-libinput-tablet.rules
+
+EXTRA_DIST = $(udev_DATA)
--
2.1.0
More information about the wayland-devel
mailing list