summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2018-03-12 13:36:54 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2018-03-19 14:24:15 +1000
commit056a5eb64a9b0e9701bda131954c06bf6cfb2487 (patch)
treebacef9c4d74a24ac3ff7f80b94bd132b32a91894 /tools
parent6e4c83636a99acc6dedb413878bf535ca4f14f4a (diff)
tools: libinput-record: print a comment when the device is in a neutral state
Common problem: some touch sequence does something to confuse libinput but it cannot easily be captureed. The result is a long sequence of touche that need to be picked apart and isolated. Print an easy-to-search for message in the evdev output that signals that the device touch state is now neutral (i.e. no finger down). Same can be achieved by searching for BTN_TOOL_FINGER but that provides false positives for switching between one and two fingers. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/libinput-record.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/tools/libinput-record.c b/tools/libinput-record.c
index 5807cb75..d8ab4977 100644
--- a/tools/libinput-record.c
+++ b/tools/libinput-record.c
@@ -56,6 +56,7 @@ enum event_type {
NONE,
EVDEV,
LIBINPUT,
+ COMMENT,
};
struct event {
@@ -64,6 +65,7 @@ struct event {
union {
struct input_event evdev;
struct li_event libinput;
+ char comment[200];
} u;
};
@@ -76,6 +78,12 @@ struct record_device {
struct event *events;
size_t nevents;
size_t events_sz;
+
+ struct {
+ bool is_touch_device;
+ uint16_t slot_state;
+ uint16_t last_slot_state;
+ } touch;
};
struct record_context {
@@ -255,11 +263,12 @@ handle_evdev_frame(struct record_context *ctx, struct record_device *d)
struct libevdev *evdev = d->evdev;
struct input_event e;
size_t count = 0;
+ uint32_t last_time = 0;
+ struct event *event;
while (libevdev_next_event(evdev,
LIBEVDEV_READ_FLAG_NORMAL,
&e) == LIBEVDEV_READ_STATUS_SUCCESS) {
- struct event *event;
if (d->nevents == d->events_sz)
resize(d->events, d->events_sz);
@@ -270,10 +279,40 @@ handle_evdev_frame(struct record_context *ctx, struct record_device *d)
event->u.evdev = e;
count++;
+ if (d->touch.is_touch_device &&
+ e.type == EV_ABS &&
+ e.code == ABS_MT_TRACKING_ID) {
+ unsigned int slot = libevdev_get_current_slot(evdev);
+ assert(slot < sizeof(d->touch.slot_state) * 8);
+
+ if (e.value != -1)
+ d->touch.slot_state |= 1 << slot;
+ else
+ d->touch.slot_state &= ~(1 << slot);
+ }
+
+ last_time = event->time;
+
if (e.type == EV_SYN && e.code == SYN_REPORT)
break;
}
+ if (d->touch.slot_state != d->touch.last_slot_state) {
+ d->touch.last_slot_state = d->touch.slot_state;
+ if (d->nevents == d->events_sz)
+ resize(d->events, d->events_sz);
+
+ if (d->touch.slot_state == 0) {
+ event = &d->events[d->nevents++];
+ event->type = COMMENT;
+ event->time = last_time;
+ snprintf(event->u.comment,
+ sizeof(event->u.comment),
+ " # Touch device in neutral state\n");
+ count++;
+ }
+ }
+
return count;
}
@@ -681,6 +720,8 @@ print_cached_events(struct record_context *ctx,
else
iprintf(ctx, "libinput:\n");
break;
+ case COMMENT:
+ break;
default:
abort();
}
@@ -696,6 +737,9 @@ print_cached_events(struct record_context *ctx,
case LIBINPUT:
iprintf(ctx, "- %s\n", e->u.libinput.msg);
break;
+ case COMMENT:
+ iprintf(ctx, "%s", e->u.comment);
+ break;
default:
abort();
}
@@ -1502,6 +1546,9 @@ init_device(struct record_context *ctx, char *path)
libevdev_set_clock_id(d->evdev, CLOCK_MONOTONIC);
+ if (libevdev_get_num_slots(d->evdev) > 0)
+ d->touch.is_touch_device = true;
+
list_insert(&ctx->devices, &d->link);
ctx->ndevices++;