+ int found = 0;
+ int i, ret, fd;
+
+ fd = open(name, O_RDWR);
+ if (fd == -1) {
+ if (report_errors) {
+ fprintf(stderr, "open %s: ", name);
+ perror(NULL);
+ }
+ return -1;
+ }
+
+ memset(&info, 0, sizeof(info));
+ ret = ioctl(fd, HIDIOCGRAWINFO, &info);
+ if (ret != 0) {
+ perror("HIDIOCGRAWINFO");
+ goto out;
+ }
+
+ if (info.vendor != 0x1b1c)
+ goto out;
+
+ for (i = 0; i < sizeof(products) / sizeof(products[0]); i++) {
+ if (info.product == products[i]) {
+ found = 1;
+ break;
+ }
+ }
+
+out:
+ if (!found) {
+ if (report_errors)
+ fprintf(stderr, "unexpected device: %04hx:%04hx\n",
+ info.vendor, info.product);
+ close(fd);
+ fd = -1;
+ }
+ return fd;
+}
+
+int main(int argc, char *argv[])
+{