summaryrefslogtreecommitdiff
path: root/usr.bin/usbhidaction
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2011-07-30 13:22:44 +0000
committerAlexander Motin <mav@FreeBSD.org>2011-07-30 13:22:44 +0000
commit1bee2ec756f2ea5255f9f68dd58c1ceae1a2f56c (patch)
tree71e3c3510b7c799897cb17384eecaf618c0fe4f7 /usr.bin/usbhidaction
parentc86c3aa3d989e26dd7f07bef51bec950e95a7727 (diff)
downloadsrc-test-1bee2ec756f2ea5255f9f68dd58c1ceae1a2f56c.tar.gz
src-test-1bee2ec756f2ea5255f9f68dd58c1ceae1a2f56c.zip
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
Notes
Notes: svn path=/head/; revision=224511
Diffstat (limited to 'usr.bin/usbhidaction')
-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 142e3cc8a3a8e..c71a8fe7cec46 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) ||