2 * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 #define _DIAGASSERT(e) assert(e)
29 typedef struct report_desc
*report_desc_t
;
31 typedef struct hid_data
*hid_data_t
;
33 typedef enum hid_kind
{
34 hid_input
, hid_output
, hid_feature
, hid_collection
, hid_endcollection
37 typedef struct hid_item
{
54 int designator_minimum
;
55 int designator_maximum
;
65 /* Absolute data position (bits) */
68 struct hid_item
*next
;
71 #define HID_PAGE(u) ((u) >> 16)
72 #define HID_USAGE(u) ((u) & 0xffff)
74 /* Obtaining a report descriptor, descr.c: */
75 report_desc_t hid_get_report_desc
__P((int file
));
76 void hid_dispose_report_desc
__P((report_desc_t
));
78 /* Parsing of a HID report descriptor, parse.c: */
79 hid_data_t hid_start_parse
__P((report_desc_t d
, int kindset
));
80 void hid_end_parse
__P((hid_data_t s
));
81 int hid_get_item
__P((hid_data_t s
, hid_item_t
*h
));
82 int hid_report_size
__P((report_desc_t d
, enum hid_kind k
, int *idp
));
83 int hid_locate
__P((report_desc_t d
, unsigned int usage
, enum hid_kind k
, hid_item_t
*h
));
85 /* Conversion to/from usage names, usage.c: */
86 char *hid_usage_page
__P((int i
));
87 char *hid_usage_in_page
__P((unsigned int u
));
88 void hid_init
__P((char *file
));
90 /* Extracting/insertion of data, data.c: */
91 int hid_get_data
__P((void *p
, hid_item_t
*h
));
92 void hid_set_data
__P((void *p
, hid_item_t
*h
, int data
));