* --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 <str> are application and field
- * both in hex, page<<16 | usage
*
* per-evdev options (apply to all subsequent):
* --[no-]grab --nograb is default
* this part is in /proc/bus/usb/devices
* and can thus be specified by caller
* for evdev devices
+ *
+ * evdev <str>... 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 <strs> are 0x and the value in hex.
+ *
+ * per-hiddev options (apply to all subsequent):
+ * --elide|show-unchanged --elide-unchanged is default
+ *
+ * hiddev <str>... 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"
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;
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) {