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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since f3b39b4 was f3b39b4, checked in by Matej Klonfar <maklf@…>, 15 years ago

doxygen and coding style update

  • Property mode set to 100644
File size: 4.4 KB
RevLine 
[9d05599]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
[74b1e40]29/** @addtogroup libusb
[9d05599]30 * @{
31 */
32/** @file
33 * USB HID report descriptor and report data parser
34 */
[74b1e40]35#ifndef LIBUSB_HIDPATH_H_
36#define LIBUSB_HIDPATH_H_
[9d05599]37
[faa44e58]38#include <usb/hid/hidparser.h>
[9d05599]39#include <stdint.h>
40#include <adt/list.h>
41
[74b1e40]42
43/*---------------------------------------------------------------------------*/
[f3b39b4]44/*
[74b1e40]45 * Flags of usage paths comparison modes.
46 *
47 */
[f3b39b4]48/** Wanted usage path must be exactly the same as the searched one. This
49 * option cannot be combined with the others.
[9d05599]50 */
[5f7b75a]51#define USB_HID_PATH_COMPARE_STRICT 0
[74b1e40]52
53/**
54 * Wanted usage path must be the suffix in the searched one.
55 */
[5f7b75a]56#define USB_HID_PATH_COMPARE_END 1
[74b1e40]57
58/**
[f3b39b4]59 * Only usage page are compared along the usage path. This option can be
60 * combined with others.
[74b1e40]61 */
[5f7b75a]62#define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY 2
[74b1e40]63
64/**
65 * Searched usage page must be prefix of the other one.
66 */
[5f7b75a]67#define USB_HID_PATH_COMPARE_BEGIN 4
[9d05599]68
[74b1e40]69/**
70 * Searched couple of usage page and usage can be anywhere in usage path.
71 * This option is deprecated.
72 */
73#define USB_HID_PATH_COMPARE_ANYWHERE 8
[9d05599]74
[74b1e40]75/*----------------------------------------------------------------------------*/
76/**
77 * Item of usage path structure. Last item of linked list describes one item
78 * in report, the others describe superior Collection tags. Usage and Usage
79 * page of report item can be changed due to data in report.
80 */
[9d05599]81typedef struct {
[74b1e40]82 /** Usage page of report item. Zero when usage page can be changed. */
[9d05599]83 uint32_t usage_page;
[74b1e40]84 /** Usage of report item. Zero when usage can be changed. */
[9d05599]85 uint32_t usage;
86
[74b1e40]87 /** Attribute of Collection tag in report descriptor*/
[9d05599]88 uint8_t flags;
[74b1e40]89
90 /** Linked list structure*/
[9d05599]91 link_t link;
92} usb_hid_report_usage_path_t;
93
[74b1e40]94
95/*---------------------------------------------------------------------------*/
96/**
97 * USB HID usage path structure.
98 * */
[9d05599]99typedef struct {
[74b1e40]100 /** Length of usage path */
[9d05599]101 int depth;
[74b1e40]102
[f3b39b4]103 /** Report id. Zero is reserved and means that report id is not used.
104 * */
[9d05599]105 uint8_t report_id;
106
[74b1e40]107 /** Linked list structure. */
[9d05599]108 link_t link; /* list */
109
[74b1e40]110 /** Head of the list of usage path items. */
111 link_t head;
[9d05599]112
113} usb_hid_report_path_t;
114
[74b1e40]115/*---------------------------------------------------------------------------*/
[9d05599]116usb_hid_report_path_t *usb_hid_report_path(void);
117
118void usb_hid_report_path_free(usb_hid_report_path_t *path);
119
[f3b39b4]120int usb_hid_report_path_set_report_id(usb_hid_report_path_t *usage_path,
121 uint8_t report_id);
[9d05599]122
123int usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path,
[f3b39b4]124 int32_t usage_page, int32_t usage);
[9d05599]125
126void usb_hid_report_remove_last_item(usb_hid_report_path_t *usage_path);
127
128void usb_hid_report_null_last_item(usb_hid_report_path_t *usage_path);
129
130void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path,
[f3b39b4]131 int32_t tag, int32_t data);
[9d05599]132
[f3b39b4]133int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path,
134 usb_hid_report_path_t *path, int flags);
[9d05599]135
[f3b39b4]136usb_hid_report_path_t *usb_hid_report_path_clone(
137 usb_hid_report_path_t *usage_path);
[9d05599]138
139void usb_hid_print_usage_path(usb_hid_report_path_t *path);
140
141#endif
142/**
143 * @}
144 */
Note: See TracBrowser for help on using the repository browser.