summaryrefslogtreecommitdiff
path: root/src/eventcomm.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2014-05-15 08:34:55 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2014-08-08 11:09:01 +1000
commita36edf8307ab9b5bffca103dd875623a66012c0b (patch)
tree9c383f0d82bfebcf3b2c30ae730b64a0e467a2aa /src/eventcomm.c
parentc1457c0f71e30c194180164320759849fa09bf9b (diff)
Use libevdev's per-device logging functions instead of the global handler
Per-device logging functions don't interfere with other drivers if they also use libevdev, so use those instead the global log handler if available. If not available, drop libevdev logging, I don't want to maintain the ifdef mess and the logging doesn't give us _that_ much benefit. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src/eventcomm.c')
-rw-r--r--src/eventcomm.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/src/eventcomm.c b/src/eventcomm.c
index 2ee072b..1f440b8 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -90,15 +90,18 @@ struct eventcomm_proto_data {
enum libevdev_read_flag read_flag;
};
+#ifdef HAVE_LIBEVDEV_DEVICE_LOG_FUNCS
static void
-libevdev_log_func(enum libevdev_log_priority priority,
+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(6, 0);
+_X_ATTRIBUTE_PRINTF(7, 0);
static void
-libevdev_log_func(enum libevdev_log_priority priority,
+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)
@@ -113,14 +116,7 @@ libevdev_log_func(enum libevdev_log_priority priority,
LogVMessageVerbSigSafe(X_NOTICE, verbosity, format, args);
}
-
-static void
-set_libevdev_log_handler(void)
-{
- /* be quiet, gcc *handwave* */
- libevdev_set_log_function((libevdev_log_func_t)libevdev_log_func, NULL);
- libevdev_set_log_priority(LIBEVDEV_LOG_DEBUG);
-}
+#endif
struct eventcomm_proto_data *
EventProtoDataAlloc(int fd)
@@ -128,7 +124,6 @@ EventProtoDataAlloc(int fd)
struct eventcomm_proto_data *proto_data;
int rc;
- set_libevdev_log_handler();
proto_data = calloc(1, sizeof(struct eventcomm_proto_data));
if (!proto_data)
@@ -137,12 +132,31 @@ EventProtoDataAlloc(int fd)
proto_data->st_to_mt_scale[0] = 1;
proto_data->st_to_mt_scale[1] = 1;
- rc = libevdev_new_from_fd(fd, &proto_data->evdev);
+ proto_data->evdev = libevdev_new();
+ if (!proto_data->evdev) {
+ rc = -1;
+ goto out;
+ }
+
+#ifdef HAVE_LIBEVDEV_DEVICE_LOG_FUNCS
+ libevdev_set_device_log_function(proto_data->evdev, libevdev_log_func,
+ LIBEVDEV_LOG_DEBUG, NULL);
+#endif
+
+ rc = libevdev_set_fd(proto_data->evdev, fd);
if (rc < 0) {
+ goto out;
+ }
+
+ proto_data->read_flag = LIBEVDEV_READ_FLAG_NORMAL;
+
+out:
+ if (rc < 0) {
+ if (proto_data && proto_data->evdev)
+ libevdev_free(proto_data->evdev);
free(proto_data);
proto_data = NULL;
- } else
- proto_data->read_flag = LIBEVDEV_READ_FLAG_NORMAL;
+ }
return proto_data;
}
@@ -218,8 +232,6 @@ EventDeviceOnHook(InputInfoPtr pInfo, SynapticsParameters * para)
struct eventcomm_proto_data *proto_data =
(struct eventcomm_proto_data *) priv->proto_data;
- set_libevdev_log_handler();
-
if (libevdev_get_fd(proto_data->evdev) != -1) {
struct input_event ev;
@@ -651,8 +663,6 @@ EventReadHwState(InputInfoPtr pInfo,
struct eventcomm_proto_data *proto_data = priv->proto_data;
Bool sync_cumulative = FALSE;
- set_libevdev_log_handler();
-
SynapticsResetTouchHwState(hw, FALSE);
/* Reset cumulative values if buttons were not previously pressed,