Skip to content

Commit

Permalink
tools: libinput-record: print the list of quirks
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
whot committed Jun 26, 2018
1 parent 07e93f0 commit ea5edf0
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
62 changes: 62 additions & 0 deletions tools/libinput-record.c
Expand Up @@ -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;

Expand Down Expand Up @@ -1664,6 +1665,66 @@ print_udev_properties(struct record_context *ctx, struct record_device *dev)
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)
Expand Down Expand Up @@ -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);
}

Expand Down
6 changes: 6 additions & 0 deletions tools/libinput-record.man
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ea5edf0

Please sign in to comment.