2 * Copyright 2010, Michael Lotz, mmlr@mlotz.ch.
3 * Distributed under the terms of the MIT License.
6 #include "HIDCollection.h"
18 main(int argc
, char *argv
[])
21 printf("usage: %s <hid_descriptor_file>\n", argv
[0]);
25 BFile
file(argv
[1], B_READ_ONLY
);
26 if (!file
.IsReadable()) {
27 printf("can't open file \"%s\" for reading\n", argv
[1]);
31 off_t descriptorLength
;
32 file
.GetSize(&descriptorLength
);
34 uint8
*reportDescriptor
= (uint8
*)malloc(descriptorLength
);
35 if (reportDescriptor
== NULL
) {
36 printf("failed to allocate buffer of %lld bytes\n", descriptorLength
);
40 ssize_t read
= file
.Read(reportDescriptor
, descriptorLength
);
41 if (read
!= descriptorLength
) {
42 printf("failed to read file of %lld bytes: %s\n", descriptorLength
,
47 HIDParser
parser(NULL
);
48 status_t result
= parser
.ParseReportDescriptor(reportDescriptor
,
51 free(reportDescriptor
);
53 printf("failed to parse descriptor: %s\n", strerror(result
));
57 parser
.PrintToStream();