summaryrefslogtreecommitdiffstats
path: root/usr.bin/usbhidaction/usbhidaction.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/usbhidaction/usbhidaction.c')
-rw-r--r--usr.bin/usbhidaction/usbhidaction.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/usr.bin/usbhidaction/usbhidaction.c b/usr.bin/usbhidaction/usbhidaction.c
index c71a8fe..fd66b64 100644
--- a/usr.bin/usbhidaction/usbhidaction.c
+++ b/usr.bin/usbhidaction/usbhidaction.c
@@ -280,12 +280,11 @@ parse_conf(const char *conf, report_desc_t repd, int reportid, int ignore)
char *p;
int line;
char buf[SIZE], name[SIZE], value[SIZE], debounce[SIZE], action[SIZE];
- char usbuf[SIZE], coll[SIZE];
+ char usbuf[SIZE], coll[SIZE], *tmp;
struct command *cmd, *cmds;
struct hid_data *d;
struct hid_item h;
- int u, lo, hi, range;
-
+ int inst, cinst, u, lo, hi, range, t;
f = fopen(conf, "r");
if (f == NULL)
@@ -317,6 +316,12 @@ parse_conf(const char *conf, report_desc_t repd, int reportid, int ignore)
", syntax error: %s", conf, line, buf);
}
}
+ tmp = strchr(name, '#');
+ if (tmp != NULL) {
+ *tmp = 0;
+ inst = atoi(tmp + 1);
+ } else
+ inst = 0;
cmd = malloc(sizeof *cmd);
if (cmd == NULL)
@@ -361,6 +366,7 @@ parse_conf(const char *conf, report_desc_t repd, int reportid, int ignore)
}
coll[0] = 0;
+ cinst = 0;
for (d = hid_start_parse(repd, 1 << hid_input, reportid);
hid_get_item(d, &h); ) {
if (verbose > 2)
@@ -380,24 +386,29 @@ parse_conf(const char *conf, report_desc_t repd, int reportid, int ignore)
range = 0;
}
for (u = lo; u <= hi; u++) {
- snprintf(usbuf, sizeof usbuf, "%s:%s",
- hid_usage_page(HID_PAGE(u)),
- hid_usage_in_page(u));
- if (verbose > 2)
- printf("usage %s\n", usbuf);
- if (!strcasecmp(usbuf, name))
- goto foundhid;
if (coll[0]) {
snprintf(usbuf, sizeof usbuf,
"%s.%s:%s", coll+1,
- hid_usage_page(HID_PAGE(u)),
+ hid_usage_page(HID_PAGE(u)),
+ hid_usage_in_page(u));
+ } else {
+ snprintf(usbuf, sizeof usbuf,
+ "%s:%s",
+ hid_usage_page(HID_PAGE(u)),
hid_usage_in_page(u));
- if (verbose > 2)
- printf("usage %s\n",
- usbuf);
- if (!strcasecmp(usbuf, name))
- goto foundhid;
}
+ if (verbose > 2)
+ printf("usage %s\n", usbuf);
+ t = strlen(usbuf) - strlen(name);
+ if (t > 0) {
+ if (strcmp(usbuf + t, name))
+ continue;
+ if (usbuf[t - 1] != '.')
+ continue;
+ } else if (strcmp(usbuf, name))
+ continue;
+ if (inst == cinst++)
+ goto foundhid;
}
break;
case hid_collection:
OpenPOWER on IntegriCloud