5 * $Id: hiddev.h,v 1.1.1.1 2005/04/11 02:51:02 jack Exp $
7 * Copyright (c) 1999-2000 Vojtech Pavlik
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@suse.cz>, or by paper mail:
29 * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
33 * The event structure itself
41 struct hiddev_devinfo {
49 unsigned num_applications;
52 #define HID_STRING_SIZE 256
53 struct hiddev_string_descriptor {
55 char value[HID_STRING_SIZE];
58 struct hiddev_report_info {
64 /* To do a GUSAGE/SUSAGE, fill in at least usage_code, report_type and
65 * report_id. Set report_id to REPORT_ID_UNKNOWN if the rest of the fields
66 * are unknown. Otherwise use a usage_ref struct filled in from a previous
67 * successful GUSAGE/SUSAGE call to save time. To actually send a value
68 * to the device, perform a SUSAGE first, followed by a SREPORT. If an
69 * INITREPORT is done, a GREPORT isn't necessary before a GUSAGE.
71 #define HID_REPORT_ID_UNKNOWN 0xffffffff
72 #define HID_REPORT_ID_FIRST 0x00000100
73 #define HID_REPORT_ID_NEXT 0x00000200
74 #define HID_REPORT_ID_MASK 0x000000ff
75 #define HID_REPORT_ID_MAX 0x000000ff
77 #define HID_REPORT_TYPE_INPUT 1
78 #define HID_REPORT_TYPE_OUTPUT 2
79 #define HID_REPORT_TYPE_FEATURE 3
80 #define HID_REPORT_TYPE_MIN 1
81 #define HID_REPORT_TYPE_MAX 3
83 struct hiddev_field_info {
89 unsigned physical; /* physical usage for this field */
90 unsigned logical; /* logical usage for this field */
91 unsigned application; /* application usage for this field */
92 __s32 logical_minimum;
93 __s32 logical_maximum;
94 __s32 physical_minimum;
95 __s32 physical_maximum;
96 unsigned unit_exponent;
100 /* Fill in report_type, report_id and field_index to get the information on a
103 #define HID_FIELD_CONSTANT 0x001
104 #define HID_FIELD_VARIABLE 0x002
105 #define HID_FIELD_RELATIVE 0x004
106 #define HID_FIELD_WRAP 0x008
107 #define HID_FIELD_NONLINEAR 0x010
108 #define HID_FIELD_NO_PREFERRED 0x020
109 #define HID_FIELD_NULL_STATE 0x040
110 #define HID_FIELD_VOLATILE 0x080
111 #define HID_FIELD_BUFFERED_BYTE 0x100
113 struct hiddev_usage_ref {
114 unsigned report_type;
116 unsigned field_index;
117 unsigned usage_index;
127 #define HID_VERSION 0x010002
130 * IOCTLs (0x00 - 0x7f)
133 #define HIDIOCGVERSION _IOR('H', 0x01, int)
134 #define HIDIOCAPPLICATION _IO('H', 0x02)
135 #define HIDIOCGDEVINFO _IOR('H', 0x03, struct hiddev_devinfo)
136 #define HIDIOCGSTRING _IOR('H', 0x04, struct hiddev_string_descriptor)
137 #define HIDIOCINITREPORT _IO('H', 0x05)
138 #define HIDIOCGNAME(len) _IOC(_IOC_READ, 'H', 0x06, len)
139 #define HIDIOCGREPORT _IOW('H', 0x07, struct hiddev_report_info)
140 #define HIDIOCSREPORT _IOW('H', 0x08, struct hiddev_report_info)
141 #define HIDIOCGREPORTINFO _IOWR('H', 0x09, struct hiddev_report_info)
142 #define HIDIOCGFIELDINFO _IOWR('H', 0x0A, struct hiddev_field_info)
143 #define HIDIOCGUSAGE _IOWR('H', 0x0B, struct hiddev_usage_ref)
144 #define HIDIOCSUSAGE _IOW('H', 0x0C, struct hiddev_usage_ref)
145 #define HIDIOCGUCODE _IOWR('H', 0x0D, struct hiddev_usage_ref)
147 /* To traverse the input report descriptor info for a HID device, perform the
150 * rinfo.report_type = HID_REPORT_TYPE_INPUT;
151 * rinfo.report_id = HID_REPORT_ID_FIRST;
152 * ret = ioctl(fd, HIDIOCGREPORTINFO, &rinfo);
155 * for (i = 0; i < rinfo.num_fields; i++) {
156 * finfo.report_type = rinfo.report_type;
157 * finfo.report_id = rinfo.report_id;
158 * finfo.field_index = i;
159 * ioctl(fd, HIDIOCGFIELDINFO, &finfo);
160 * for (j = 0; j < finfo.maxusage; j++) {
161 * uref.field_index = i;
162 * uref.usage_index = j;
163 * ioctl(fd, HIDIOCGUCODE, &uref);
164 * ioctl(fd, HIDIOCGUSAGE, &uref);
167 * uref.report_id |= HID_REPORT_ID_NEXT;
168 * ret = ioctl(fd, HIDIOCGREPORTINFO, &uref);
176 * In-kernel definitions.
179 #ifdef CONFIG_USB_HIDDEV
180 int hiddev_connect(struct hid_device *);
181 void hiddev_disconnect(struct hid_device *);
182 void hiddev_hid_event(struct hid_device *, unsigned int usage, int value);
183 int __init hiddev_init(void);
184 void __exit hiddev_exit(void);
186 static inline int hiddev_connect(struct hid_device *hid) { return -1; }
187 static inline void hiddev_disconnect(struct hid_device *hid) { }
188 static inline void hiddev_hid_event(struct hid_device *hid, unsigned int usage, int value) { }
189 static inline int hiddev_init(void) { return 0; }
190 static inline void hiddev_exit(void) { }