From: ian Date: Mon, 16 Jun 2008 00:31:29 +0000 (+0000) Subject: separate page and code X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=3b8e9637506a542390ac0e3e3f3043b1408b5611;p=trains.git separate page and code --- diff --git a/hostside/evdev-manip.c b/hostside/evdev-manip.c index 1634dbb..29e1263 100644 --- a/hostside/evdev-manip.c +++ b/hostside/evdev-manip.c @@ -14,11 +14,8 @@ * --label LABEL use LABEL instead of path in redacted output * * per-device options (apply to all subsequent): - * --elide|show-unchanged --elide-unchanged is default * --evdev subsequent devices are evdev * --hiddev subsequent devices are hiddev - * hiddev are application and field - * both in hex, page<<16 | usage * * per-evdev options (apply to all subsequent): * --[no-]grab --nograb is default @@ -27,6 +24,20 @@ * this part is in /proc/bus/usb/devices * and can thus be specified by caller * for evdev devices + * + * evdev ... are type and code, each split up into + * prefix and tail, eg EV_KEY KEY_EQUAL becomes EV KEY KEY EQUAL. + * If the type or code is not found in our number-to-string + * tables, the respective two are 0x and the value in hex. + * + * per-hiddev options (apply to all subsequent): + * --elide|show-unchanged --elide-unchanged is default + * + * hiddev ... are application and field. In each case, page + * and usage, both in hex, both at least two digits with 0x in + * from of page only. This matches what is shown in the USB HID + * usage tables specification which can be found at + * http://www.usb.org/developers/hidpage/ */ #include "common.h" @@ -401,10 +412,20 @@ static void hiddev_dump(Device *d, const struct hiddev_usage_ref *ur) { putchar('\n'); } +static void hiddev_redact_pageusage(unsigned long code, + char sb_buf[2][7], + const char *strs[2]) { + assert(code <= 0xffffffffUL); + sprintf(sb_buf[0], "%#04lx", code >> 16); + sprintf(sb_buf[1], "%02lx", code & 0xffff); + strs[0]= sb_buf[0]; + strs[1]= sb_buf[1]; +} + static void hiddev_redact(Device *d, const struct hiddev_usage_ref *ur) { HiddevField *f; - char sb_app[9], sb_usage[9]; - const char *strs[2]; + char sb_app[2][7], sb_usage[2][7]; + const char *strs[4]; if (ur->field_index == HID_FIELD_INDEX_NONE) return; @@ -413,14 +434,10 @@ static void hiddev_redact(Device *d, const struct hiddev_usage_ref *ur) { if (hiddev_elide(d, ur, f)) return; - assert(f->fi.application <= 0xffffffffUL); - assert(ur->usage_code <= 0xffffffffUL); - sprintf(sb_app, "%lx", (unsigned long)f->fi.application); - sprintf(sb_usage, "%lx", (unsigned long)ur->usage_code); + hiddev_redact_pageusage(f->fi.application, sb_app, &strs[0]); + hiddev_redact_pageusage(ur->usage_code, sb_usage, &strs[2]); - strs[0]= sb_app; - strs[1]= sb_usage; - mode->redacted(d, 2,strs, ur->value); + mode->redacted(d, 4,strs, ur->value); } static void hiddev_readable(Device *d) {