Commit bfceb1bc authored by Peter Hutterer's avatar Peter Hutterer

eventcomm: Hook up the libevdev log handler

This is a bit problematic: libevdev only has one global log handler.
So if we have another driver use libevdev, we'll either overwrite that handler
or get overwritten, whichever comes first. So we need to re-set the handler
every time we get an event to make sure we log through our handler.
Likewise, if we ever drop the device, we need to unset the log handler back to
NULL because we may unload the module and our handler may disappear.

Use the lowest logging priority, let the server filter based on the verbosity
level instead.
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 6ad85679
......@@ -87,12 +87,46 @@ struct eventcomm_proto_data {
enum libevdev_read_flag read_flag;
};
static void
libevdev_log_func(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);
static void
libevdev_log_func(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);
}
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);
}
struct eventcomm_proto_data *
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)
return NULL;
......@@ -181,6 +215,8 @@ 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;
......@@ -224,6 +260,8 @@ EventDeviceOffHook(InputInfoPtr pInfo)
UninitializeTouch(pInfo);
libevdev_grab(proto_data->evdev, LIBEVDEV_UNGRAB);
libevdev_set_log_function(NULL, NULL);
libevdev_set_log_priority(LIBEVDEV_LOG_INFO); /* reset to default */
return Success;
}
......@@ -625,6 +663,8 @@ 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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment