[PATCH evdev] Hook up libevdev's new device log function

Peter Hutterer peter.hutterer at who-t.net
Wed Jun 4 22:46:21 PDT 2014


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 configure.ac |  7 +++++++
 src/evdev.c  | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/configure.ac b/configure.ac
index 1325424..0db1dec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,6 +49,13 @@ PKG_CHECK_MODULES(UDEV, libudev)
 
 PKG_CHECK_MODULES(XI22, [inputproto >= 2.1.99.3] [xorg-server >= 1.11.99.901], HAVE_XI22="yes", HAVE_XI22="no")
 PKG_CHECK_MODULES(LIBEVDEV, [libevdev >= 0.4])
+SAVE_LIBS="$LIBS"
+LIBS="$LIBEVDEV_LIBS"
+AC_CHECK_LIB(evdev, libevdev_set_device_log_function,
+                  [AC_DEFINE(HAVE_LIBEVDEV_DEVICE_LOG_FUNCS, 1,
+                             [libevdev supports per-device log functions])],
+                  [])
+LIBS="$SAVE_LIBS"
 
 if test "x$HAVE_XI22" = xyes; then
         # Obtain compiler/linker options for mtdev
diff --git a/src/evdev.c b/src/evdev.c
index 30f809b..caa7d79 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2524,6 +2524,34 @@ EvdevUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
     xf86DeleteInput(pInfo, flags);
 }
 
+#ifdef HAVE_LIBEVDEV_DEVICE_LOG_FUNCS
+static void
+libevdev_log_func(const struct libevdev *dev,
+                  enum libevdev_log_priority priority,
+                  void *data,
+                  const char *file, int line, const char *func,
+                  const char *format, va_list args)
+_X_ATTRIBUTE_PRINTF(7, 0);
+
+static void
+libevdev_log_func(const struct libevdev *dev,
+                  enum libevdev_log_priority priority,
+                  void *data,
+                  const char *file, int line, const char *func,
+                  const char *format, va_list args)
+{
+    int verbosity;
+
+    switch(priority) {
+        case LIBEVDEV_LOG_ERROR: verbosity = 0; break;
+        case LIBEVDEV_LOG_INFO: verbosity = 4; break;
+        case LIBEVDEV_LOG_DEBUG: verbosity = 10; break;
+    }
+
+    LogVMessageVerbSigSafe(X_NOTICE, verbosity, format, args);
+}
+#endif
+
 static EvdevPtr
 EvdevAlloc(InputInfoPtr pInfo)
 {
@@ -2538,6 +2566,11 @@ EvdevAlloc(InputInfoPtr pInfo)
         free(pEvdev);
         return NULL;
     }
+#ifdef HAVE_LIBEVDEV_DEVICE_LOG_FUNCS
+    libevdev_set_device_log_function(pEvdev->dev,
+                                     libevdev_log_func,
+                                     LIBEVDEV_LOG_DEBUG, NULL);
+#endif
 
     /*
      * We initialize pEvdev->in_proximity to 1 so that device that doesn't use
-- 
1.9.3



More information about the xorg-devel mailing list