diff --git a/lib/libusbhid/libusbhid.h b/lib/libusbhid/libusbhid.h index 105d8cf124d6..dd9c650cedb8 100644 --- a/lib/libusbhid/libusbhid.h +++ b/lib/libusbhid/libusbhid.h @@ -36,7 +36,11 @@ typedef struct report_desc *report_desc_t; typedef struct hid_data *hid_data_t; typedef enum hid_kind { - hid_input, hid_output, hid_feature, hid_collection, hid_endcollection + hid_input = 0, + hid_output = 1, + hid_feature = 2, + hid_collection, + hid_endcollection } hid_kind_t; typedef struct hid_item { @@ -90,11 +94,11 @@ int hid_report_size(report_desc_t d, unsigned int id, enum hid_kind k); int hid_locate(report_desc_t d, unsigned int usage, enum hid_kind k, hid_item_t *h); /* Conversion to/from usage names, usage.c: */ -int hid_parse_usage_page(const char *name); -int hid_parse_usage_in_page(const char *name); const char *hid_usage_page(int i); const char *hid_usage_in_page(unsigned int u); void hid_init(const char *file); +int hid_parse_usage_in_page(const char *name); +int hid_parse_usage_page(const char *name); /* Extracting/insertion of data, data.c: */ int hid_get_data(const void *p, const hid_item_t *h); diff --git a/lib/libusbhid/parse.c b/lib/libusbhid/parse.c index 124218f57c2a..d8c64625bfee 100644 --- a/lib/libusbhid/parse.c +++ b/lib/libusbhid/parse.c @@ -74,6 +74,7 @@ hid_clear_local(hid_item_t *c) c->string_minimum = 0; c->string_maximum = 0; c->set_delimiter = 0; + c->report_size = 0; } hid_data_t diff --git a/lib/libusbhid/usage.c b/lib/libusbhid/usage.c index 00facf5c31bc..8e6bfcaa10de 100644 --- a/lib/libusbhid/usage.c +++ b/lib/libusbhid/usage.c @@ -96,7 +96,7 @@ hid_init(const char *hidname) no = -1; else if (sscanf(line, " 0x%x %[^\n]", &no, name) != 2 && sscanf(line, " %d %[^\n]", &no, name) != 2) - errx(1, "file %s, line %d, syntax error\n", + errx(1, "file %s, line %d, syntax error", hidname, lineno); for (p = name; *p; p++) if (isspace(*p) || *p == '.') @@ -106,7 +106,7 @@ hid_init(const char *hidname) err(1, "strdup"); if (isspace(line[0])) { if (!curpage) - errx(1, "file %s, line %d, syntax error\n", + errx(1, "file %s, line %d, syntax error", hidname, lineno); if (curpage->pagesize >= curpage->pagesizemax) { curpage->pagesizemax += 10; @@ -160,7 +160,7 @@ hid_usage_page(int i) int k; if (!pages) - errx(1, "no hid table\n"); + errx(1, "no hid table"); for (k = 0; k < npages; k++) if (pages[k].usage == i) @@ -185,8 +185,9 @@ hid_usage_in_page(unsigned int u) for (j = 0; j < pages[k].pagesize; j++) { us = pages[k].page_contents[j].usage; if (us == -1) { - sprintf(b, "%s %d", - pages[k].page_contents[j].name, i); + sprintf(b, + fmtcheck(pages[k].page_contents[j].name, "%d"), + i); return b; } if (us == i) @@ -203,7 +204,7 @@ hid_parse_usage_page(const char *name) int k; if (!pages) - errx(1, "no hid table\n"); + errx(1, "no hid table"); for (k = 0; k < npages; k++) if (strcmp(pages[k].name, name) == 0) @@ -215,10 +216,11 @@ hid_parse_usage_page(const char *name) int hid_parse_usage_in_page(const char *name) { - const char *sep = strchr(name, ':'); + const char *sep; int k, j; unsigned int l; + sep = strchr(name, ':'); if (sep == NULL) return -1; l = sep - name; diff --git a/lib/libusbhid/usbhid.h b/lib/libusbhid/usbhid.h index 105d8cf124d6..dd9c650cedb8 100644 --- a/lib/libusbhid/usbhid.h +++ b/lib/libusbhid/usbhid.h @@ -36,7 +36,11 @@ typedef struct report_desc *report_desc_t; typedef struct hid_data *hid_data_t; typedef enum hid_kind { - hid_input, hid_output, hid_feature, hid_collection, hid_endcollection + hid_input = 0, + hid_output = 1, + hid_feature = 2, + hid_collection, + hid_endcollection } hid_kind_t; typedef struct hid_item { @@ -90,11 +94,11 @@ int hid_report_size(report_desc_t d, unsigned int id, enum hid_kind k); int hid_locate(report_desc_t d, unsigned int usage, enum hid_kind k, hid_item_t *h); /* Conversion to/from usage names, usage.c: */ -int hid_parse_usage_page(const char *name); -int hid_parse_usage_in_page(const char *name); const char *hid_usage_page(int i); const char *hid_usage_in_page(unsigned int u); void hid_init(const char *file); +int hid_parse_usage_in_page(const char *name); +int hid_parse_usage_page(const char *name); /* Extracting/insertion of data, data.c: */ int hid_get_data(const void *p, const hid_item_t *h);