From f8efb19e182a8a9cb335eb80f0a94665ccd0fdbd Mon Sep 17 00:00:00 2001 From: augustss Date: Sat, 29 Dec 2001 21:23:24 +0000 Subject: [PATCH] Print items with a usage range in a comprehensible way. Also print all items in an array. --- usr.bin/usbhidctl/usbhid.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/usr.bin/usbhidctl/usbhid.c b/usr.bin/usbhidctl/usbhid.c index 1d4b7ff86992..bc84b43349a9 100644 --- a/usr.bin/usbhidctl/usbhid.c +++ b/usr.bin/usbhidctl/usbhid.c @@ -1,4 +1,4 @@ -/* $NetBSD: usbhid.c,v 1.20 2001/12/28 17:49:32 augustss Exp $ */ +/* $NetBSD: usbhid.c,v 1.21 2001/12/29 21:23:24 augustss Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -467,19 +467,30 @@ varop_display(struct hid_item *item, struct Susbvar *var, u_int32_t const *collist, size_t collen, u_char *buf) { size_t colitem; + int val, i; - for (colitem = 0; colitem < collen; colitem++) { + for (i = 0; i < item->report_count; i++) { + for (colitem = 0; colitem < collen; colitem++) { + if (var->mflags & MATCH_SHOWPAGENAME) + printf("%s:", + hid_usage_page(HID_PAGE(collist[colitem]))); + printf("%s.", hid_usage_in_page(collist[colitem])); + } if (var->mflags & MATCH_SHOWPAGENAME) - printf("%s:", - hid_usage_page(HID_PAGE(collist[colitem]))); - printf("%s.", hid_usage_in_page(collist[colitem])); + printf("%s:", hid_usage_page(HID_PAGE(item->usage))); + val = hid_get_data(buf, item); + item->pos += item->report_size; + if (item->usage_minimum != 0 || item->usage_maximum != 0) { + val += item->usage_minimum; + printf("%s=1", hid_usage_in_page(val)); + } else { + printf("%s=%d%s", hid_usage_in_page(item->usage), + val, item->flags & HIO_CONST ? " (const)" : ""); + } + if (item->report_count > 1) + printf(" [%d]", i); + printf("\n"); } - - if (var->mflags & MATCH_SHOWPAGENAME) - printf("%s:", hid_usage_page(HID_PAGE(item->usage))); - printf("%s=%d%s\n", hid_usage_in_page(item->usage), - hid_get_data(buf, item), - (item->flags & HIO_CONST) ? " (const)" : ""); return 0; }