UPS: apcupsd clean sources
[tomato.git] / release / src / router / apcupsd / src / drivers / usb / bsd / hidutils.h
blob18cbaa4ebe1b106177719000dc9b8f69aabd6a70
1 /*
2 * hidutils.h
4 * Utility functions for interfacing with the libusbhid userspace
5 * HID parsing library.
6 */
8 /*
9 * Copyright (C) 2004-2005 Adam Kropelin
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of version 2 of the GNU General
13 * Public License as published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public
21 * License along with this program; if not, write to the Free
22 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
23 * MA 02111-1307, USA.
26 #ifndef _HIDUTILS_H
27 #define _HIDUTILS_H
29 #include "usbhid.h"
31 #define HID_KIND_INPUT (1 << hid_input)
32 #define HID_KIND_OUTPUT (1 << hid_output)
33 #define HID_KIND_FEATURE (1 << hid_feature)
34 #define HID_KIND_COLLECTION (1 << hid_collection)
35 #define HID_KIND_ENDCOLLECTION (1 << hid_endcollection)
36 #define HID_KIND_ALL (HID_KIND_INPUT | \
37 HID_KIND_OUTPUT | \
38 HID_KIND_FEATURE | \
39 HID_KIND_COLLECTION | \
40 HID_KIND_ENDCOLLECTION | \
41 HID_KIND_OUTPUT)
44 * Fetch the report descriptor from the device given an fd for the
45 * device's control endpoint. Descriptor length is written to the
46 * rlen out paramter and a pointer to a malloc'ed buffer containing
47 * the descriptor is returned. Returns NULL on failure.
49 unsigned char *hidu_fetch_report_descriptor(int fd, int *rlen);
52 * Locate an item matching the given parameters. If found, the
53 * item is copied to the supplied buffer. Returns true on success,
54 * false on failure. Any of usage, app, phys, logical, and kind
55 * may be set to -1 for "don't care".
57 int hidu_locate_item(report_desc_t rdesc, int usage, int app, int phys,
58 int logical, int kind, hid_item_t *outitem);
61 * Fetch a report from a device given an fd for the device's control
62 * endpoint, the populated item structure describing the report, a
63 * data buffer in which to store the result, and the report length.
64 * Returns actual report length (in bytes) on success and -1 on failure.
66 int hidu_get_report(int fd, hid_item_t *item, unsigned char *data, int len);
69 * Send a report to the device given an fd for the device's control
70 * endpoint, the populated item structure, the data to send, and the
71 * report length. Returns true on success, false on failure.
73 int hidu_set_report(int fd, hid_item_t *item, unsigned char *data, int len);
76 * Fetch a string descriptor from the device given an fd for the
77 * device's control endpoint and the string index. Returns a pointer
78 * to a static buffer containing the NUL-terminated string or NULL
79 * on failure.
81 const char *hidu_get_string(int fd, int index);
84 #endif