source: mainline/uspace/lib/usbhid/include/usb/hid/hidpath.h

Last change on this file was d1582b50, checked in by Jiri Svoboda <jiri@…>, 5 years ago

Fix spacing in single-line comments using latest ccheck

This found incorrectly formatted section comments (with blocks of
asterisks or dashes). I strongly believe against using section comments
but I am not simply removing them since that would probably be
controversial.

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 * Copyright (c) 2011 Matej Klonfar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libusb
30 * @{
31 */
32/** @file
33 * USB HID report descriptor and report data parser
34 */
35#ifndef LIBUSB_HIDPATH_H_
36#define LIBUSB_HIDPATH_H_
37
38#include <errno.h>
39#include <usb/hid/hidparser.h>
40#include <stdint.h>
41#include <adt/list.h>
42
43/*
44 * Flags of usage paths comparison modes.
45 *
46 */
47/** Wanted usage path must be exactly the same as the searched one. This
48 * option cannot be combined with the others.
49 */
50#define USB_HID_PATH_COMPARE_STRICT 0
51
52/**
53 * Wanted usage path must be the suffix in the searched one.
54 */
55#define USB_HID_PATH_COMPARE_END 1
56
57/**
58 * Only usage page are compared along the usage path. This option can be
59 * combined with others.
60 */
61#define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY 2
62
63/**
64 * Searched usage page must be prefix of the other one.
65 */
66#define USB_HID_PATH_COMPARE_BEGIN 4
67
68/**
69 * Searched couple of usage page and usage can be anywhere in usage path.
70 * This option is deprecated.
71 */
72#define USB_HID_PATH_COMPARE_ANYWHERE 8
73
74/**
75 * Item of usage path structure. Last item of linked list describes one item
76 * in report, the others describe superior Collection tags. Usage and Usage
77 * page of report item can be changed due to data in report.
78 */
79typedef struct {
80 /** Usage page of report item. Zero when usage page can be changed. */
81 uint32_t usage_page;
82 /** Usage of report item. Zero when usage can be changed. */
83 uint32_t usage;
84
85 /** Attribute of Collection tag in report descriptor */
86 uint8_t flags;
87
88 /** Link to usb_hid_report_path_t.items list */
89 link_t rpath_items_link;
90} usb_hid_report_usage_path_t;
91
92/**
93 * USB HID usage path structure.
94 */
95typedef struct {
96 /** Length of usage path */
97 int depth;
98
99 /** Report id. Zero is reserved and means that report id is not used.
100 */
101 uint8_t report_id;
102
103 /** Link to usb_hid_report_path_t.collection_paths list. */
104 link_t cpath_link;
105
106 /** List of usage path items. */
107 list_t items; /* of usb_hid_report_usage_path_t */
108} usb_hid_report_path_t;
109
110usb_hid_report_path_t *usb_hid_report_path(void);
111
112void usb_hid_report_path_free(usb_hid_report_path_t *path);
113
114errno_t usb_hid_report_path_set_report_id(usb_hid_report_path_t *usage_path,
115 uint8_t report_id);
116
117errno_t usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path,
118 int32_t usage_page, int32_t usage);
119
120void usb_hid_report_remove_last_item(usb_hid_report_path_t *usage_path);
121
122void usb_hid_report_null_last_item(usb_hid_report_path_t *usage_path);
123
124void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path,
125 int32_t tag, int32_t data);
126
127int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path,
128 usb_hid_report_path_t *path, int flags);
129
130usb_hid_report_path_t *usb_hid_report_path_clone(
131 usb_hid_report_path_t *usage_path);
132
133void usb_hid_print_usage_path(usb_hid_report_path_t *path);
134
135#endif
136/**
137 * @}
138 */
Note: See TracBrowser for help on using the repository browser.