From: ian Date: Thu, 5 Jun 2008 23:07:06 +0000 (+0000) Subject: evdev-manip compiles and mostly works X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=e37b05768438b59bf6ac08c06d7e0bb36e2c3d32;p=trains.git evdev-manip compiles and mostly works --- diff --git a/hostside/evdev-manip.c b/hostside/evdev-manip.c index 6fa2c63..72ae4e5 100644 --- a/hostside/evdev-manip.c +++ b/hostside/evdev-manip.c @@ -43,10 +43,17 @@ static void pr_table_str(const InputEventStringInfo *strings, int nstrings, printf("%s %s", string->prefix, string->main); } +static void pr_time(struct timeval tv) { + printf("%ju.%06d", (uintmax_t)tv.tv_sec, (int)tv.tv_usec); +} + static void dump_event(Device *d, const struct input_event *ie) { const InputEventTypeInfo *t; printf("event "); + pr_time(ie->time); + + printf(" "); PR_TABLE_STR(ev, ie->type); printf(" "); @@ -77,7 +84,7 @@ static void process_device(Device *d) { int r, remain; char *p; - printf("event-group-start device %s\n",d->path); + printf("report-from device %s\n",d->path); for (;;) { for (p=(void*)&ie, remain=sizeof(ie); @@ -93,9 +100,9 @@ static void process_device(Device *d) { assert(r <= remain); } if (ie.type == EV_SYN) { - printf("synchronised %ju.%06d\n", - (uintmax_t)ie.time.tv_sec, - (int)ie.time.tv_usec); + printf("synch "); + pr_time(ie.time); + printf("\n"); break; } @@ -151,7 +158,7 @@ static void getdevice(const char *path) { r= ioctl(d->fd, EVIOCGID, &iid); if (r) diee("%s: failed to get id",path); printf("device %s bustype ", path); PR_TABLE_STR(bus, iid.bustype); - printf(" vendor %#x product #%x version %#x\n", + printf(" vendor %#x product %#x version %#x\n", iid.vendor, iid.product, iid.version); mflushstdout(); @@ -162,6 +169,8 @@ static void getdevice(const char *path) { int main(int argc, const char **argv) { const char *arg; + mode= &mode_dump; + while ((arg= *++argv)) { if (arg[0] != '-') { getdevice(arg);