summaryrefslogtreecommitdiffstats
path: root/usr.bin/usbhidaction/usbhidaction.c
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2011-07-30 13:22:44 +0000
committermav <mav@FreeBSD.org>2011-07-30 13:22:44 +0000
commitad37555d422d0e4b4662a53f1df5fe77c6a7a841 (patch)
tree71e3c3510b7c799897cb17384eecaf618c0fe4f7 /usr.bin/usbhidaction/usbhidaction.c
parent443209104b215fe51c5924578a81a05e0ecd3309 (diff)
downloadFreeBSD-src-ad37555d422d0e4b4662a53f1df5fe77c6a7a841.zip
FreeBSD-src-ad37555d422d0e4b4662a53f1df5fe77c6a7a841.tar.gz
MFprojects/hid:
- Fix usbhidctl and usbhidaction to handle HID devices with multiple report ids, such as multimedia keyboards. - Add collection type and report id to the `usbhidctl -r` output. They are important for proper device understanding and debugging. - Fix usbhidaction tool to properly handle items having report_count more then 1. Approved by: re (kib) MFC after: 2 weeks
Diffstat (limited to 'usr.bin/usbhidaction/usbhidaction.c')
-rw-r--r--usr.bin/usbhidaction/usbhidaction.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/usr.bin/usbhidaction/usbhidaction.c b/usr.bin/usbhidaction/usbhidaction.c
index 142e3cc..c71a8fe 100644
--- a/usr.bin/usbhidaction/usbhidaction.c
+++ b/usr.bin/usbhidaction/usbhidaction.c
@@ -92,12 +92,12 @@ main(int argc, char **argv)
char buf[100];
char devnamebuf[PATH_MAX];
struct command *cmd;
- int reportid;
+ int reportid = -1;
demon = 1;
ignore = 0;
dieearly = 0;
- while ((ch = getopt(argc, argv, "c:def:ip:t:v")) != -1) {
+ while ((ch = getopt(argc, argv, "c:def:ip:r:t:v")) != -1) {
switch(ch) {
case 'c':
conf = optarg;
@@ -117,6 +117,9 @@ main(int argc, char **argv)
case 'p':
pidfile = optarg;
break;
+ case 'r':
+ reportid = atoi(optarg);
+ break;
case 't':
table = optarg;
break;
@@ -146,14 +149,13 @@ main(int argc, char **argv)
fd = open(dev, O_RDWR);
if (fd < 0)
err(1, "%s", dev);
- reportid = hid_get_report_id(fd);
repd = hid_get_report_desc(fd);
if (repd == NULL)
err(1, "hid_get_report_desc() failed");
commands = parse_conf(conf, repd, reportid, ignore);
- sz = (size_t)hid_report_size(repd, hid_input, reportid);
+ sz = (size_t)hid_report_size(repd, hid_input, -1);
if (verbose)
printf("report size %zu\n", sz);
@@ -198,7 +200,23 @@ main(int argc, char **argv)
}
#endif
for (cmd = commands; cmd; cmd = cmd->next) {
- val = hid_get_data(buf, &cmd->item);
+ if (cmd->item.report_ID != 0 &&
+ buf[0] != cmd->item.report_ID)
+ continue;
+ if (cmd->item.flags & HIO_VARIABLE)
+ val = hid_get_data(buf, &cmd->item);
+ else {
+ uint32_t pos = cmd->item.pos;
+ for (i = 0; i < cmd->item.report_count; i++) {
+ val = hid_get_data(buf, &cmd->item);
+ if (val == cmd->value)
+ break;
+ cmd->item.pos += cmd->item.report_size;
+ }
+ cmd->item.pos = pos;
+ val = (i < cmd->item.report_count) ?
+ cmd->value : -1;
+ }
if (cmd->value != val && cmd->anyvalue == 0)
goto next;
if ((cmd->debounce == 0) ||
OpenPOWER on IntegriCloud