tools: libinput-record: print the list of quirks

Now that all device quirks are in the quirks subsystem we have to print those
instead of just the udev devices.

Since libinput-record is there to record system devices, the system-installed
quirk list is used (without any commandline overrides right now). This is
useful to capture misconfigurations or missing quirks on the host system.

Fixes https://gitlab.freedesktop.org/libinput/libinput/issues/58

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2018-06-22 16:39:01 +10:00
parent 07e93f077e
commit ea5edf09c4
2 changed files with 68 additions and 0 deletions

View file

@ -43,6 +43,7 @@
#include "libinput-util.h"
#include "libinput-version.h"
#include "libinput-git-version.h"
#include "shared.h"
static const int FILE_VERSION_NUMBER = 1;
@ -1664,6 +1665,66 @@ out:
udev_unref(udev);
}
static void
quirks_log_handler(struct libinput *this_is_null,
enum libinput_log_priority priority,
const char *format,
va_list args)
{
}
static void
list_print(void *userdata, const char *val)
{
struct record_context *ctx = userdata;
iprintf(ctx, "- %s\n", val);
}
static inline void
print_device_quirks(struct record_context *ctx, struct record_device *dev)
{
struct udev *udev = NULL;
struct udev_device *udev_device = NULL;
struct stat st;
struct quirks_context *quirks;
const char *data_path = LIBINPUT_DATA_DIR;
const char *override_file = LIBINPUT_DATA_OVERRIDE_FILE;
if (stat(dev->devnode, &st) < 0)
return;
quirks = quirks_init_subsystem(data_path,
override_file,
quirks_log_handler,
NULL,
QLOG_CUSTOM_LOG_PRIORITIES);
if (!quirks) {
fprintf(stderr,
"Failed to initialize the device quirks. "
"Please see the above errors "
"and/or re-run with --verbose for more details\n");
return;
}
udev = udev_new();
if (!udev)
goto out;
udev_device = udev_device_new_from_devnum(udev, 'c', st.st_rdev);
if (!udev_device)
goto out;
iprintf(ctx, "quirks:\n");
indent_push(ctx);
tools_list_device_quirks(quirks, udev_device, list_print, ctx);
indent_pop(ctx);
out:
udev_device_unref(udev_device);
udev_unref(udev);
}
static inline void
print_libinput_description(struct record_context *ctx,
struct record_device *dev)
@ -1719,6 +1780,7 @@ print_device_description(struct record_context *ctx, struct record_device *dev)
print_evdev_description(ctx, dev);
print_udev_properties(ctx, dev);
print_device_quirks(ctx, dev);
print_libinput_description(ctx, dev);
}

View file

@ -149,6 +149,9 @@ devices:
properties:
- ID_INPUT_MOUSE=1
- ID_INPUT=1
quirks:
- ModelAppleTouchpad=1
- AttrSizeHint=32x32
events:
- evdev:
- [ 0, 0, 3, 57, 1420] # EV_ABS / ABS_MT_TRACKING_ID 1420
@ -253,6 +256,9 @@ A list of udev properties in the \fBkey=value\fR format. This is not the
complete list of properties assigned to the device but a subset that is
relevant to libinput. These properties may include properties set on a
parent device.
.TP 8
.B quirks: list of strings
A list of device quirks the \fBkey=value\fR format.
.SS events
A list of the recorded events. The list contains dictionaries