blob: 2fa6a41b8445fa52d9174d779e22027b04625a1d [file] [log] [blame]
Nicholas Flintham1e3d3112013-04-10 10:48:38 +01001#ifndef _HIDDEV_H
2#define _HIDDEV_H
3
4/*
5 * Copyright (c) 1999-2000 Vojtech Pavlik
6 *
7 * Sponsored by SuSE
8 */
9
10/*
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 * Should you need to contact me, the author, you can do so either by
26 * e-mail - mail your message to <vojtech@suse.cz>, or by paper mail:
27 * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
28 */
29
30#include <linux/types.h>
31
32
33struct hiddev_event {
34 unsigned hid;
35 signed int value;
36};
37
38struct hiddev_devinfo {
39 __u32 bustype;
40 __u32 busnum;
41 __u32 devnum;
42 __u32 ifnum;
43 __s16 vendor;
44 __s16 product;
45 __s16 version;
46 __u32 num_applications;
47};
48
49struct hiddev_collection_info {
50 __u32 index;
51 __u32 type;
52 __u32 usage;
53 __u32 level;
54};
55
56#define HID_STRING_SIZE 256
57struct hiddev_string_descriptor {
58 __s32 index;
59 char value[HID_STRING_SIZE];
60};
61
62struct hiddev_report_info {
63 __u32 report_type;
64 __u32 report_id;
65 __u32 num_fields;
66};
67
68#define HID_REPORT_ID_UNKNOWN 0xffffffff
69#define HID_REPORT_ID_FIRST 0x00000100
70#define HID_REPORT_ID_NEXT 0x00000200
71#define HID_REPORT_ID_MASK 0x000000ff
72#define HID_REPORT_ID_MAX 0x000000ff
73
74#define HID_REPORT_TYPE_INPUT 1
75#define HID_REPORT_TYPE_OUTPUT 2
76#define HID_REPORT_TYPE_FEATURE 3
77#define HID_REPORT_TYPE_MIN 1
78#define HID_REPORT_TYPE_MAX 3
79
80struct hiddev_field_info {
81 __u32 report_type;
82 __u32 report_id;
83 __u32 field_index;
84 __u32 maxusage;
85 __u32 flags;
86 __u32 physical;
87 __u32 logical;
88 __u32 application;
89 __s32 logical_minimum;
90 __s32 logical_maximum;
91 __s32 physical_minimum;
92 __s32 physical_maximum;
93 __u32 unit_exponent;
94 __u32 unit;
95};
96
97#define HID_FIELD_CONSTANT 0x001
98#define HID_FIELD_VARIABLE 0x002
99#define HID_FIELD_RELATIVE 0x004
100#define HID_FIELD_WRAP 0x008
101#define HID_FIELD_NONLINEAR 0x010
102#define HID_FIELD_NO_PREFERRED 0x020
103#define HID_FIELD_NULL_STATE 0x040
104#define HID_FIELD_VOLATILE 0x080
105#define HID_FIELD_BUFFERED_BYTE 0x100
106
107struct hiddev_usage_ref {
108 __u32 report_type;
109 __u32 report_id;
110 __u32 field_index;
111 __u32 usage_index;
112 __u32 usage_code;
113 __s32 value;
114};
115
116#define HID_MAX_MULTI_USAGES 1024
117struct hiddev_usage_ref_multi {
118 struct hiddev_usage_ref uref;
119 __u32 num_values;
120 __s32 values[HID_MAX_MULTI_USAGES];
121};
122
123#define HID_FIELD_INDEX_NONE 0xffffffff
124
125
126#define HID_VERSION 0x010004
127
128
129#define HIDIOCGVERSION _IOR('H', 0x01, int)
130#define HIDIOCAPPLICATION _IO('H', 0x02)
131#define HIDIOCGDEVINFO _IOR('H', 0x03, struct hiddev_devinfo)
132#define HIDIOCGSTRING _IOR('H', 0x04, struct hiddev_string_descriptor)
133#define HIDIOCINITREPORT _IO('H', 0x05)
134#define HIDIOCGNAME(len) _IOC(_IOC_READ, 'H', 0x06, len)
135#define HIDIOCGREPORT _IOW('H', 0x07, struct hiddev_report_info)
136#define HIDIOCSREPORT _IOW('H', 0x08, struct hiddev_report_info)
137#define HIDIOCGREPORTINFO _IOWR('H', 0x09, struct hiddev_report_info)
138#define HIDIOCGFIELDINFO _IOWR('H', 0x0A, struct hiddev_field_info)
139#define HIDIOCGUSAGE _IOWR('H', 0x0B, struct hiddev_usage_ref)
140#define HIDIOCSUSAGE _IOW('H', 0x0C, struct hiddev_usage_ref)
141#define HIDIOCGUCODE _IOWR('H', 0x0D, struct hiddev_usage_ref)
142#define HIDIOCGFLAG _IOR('H', 0x0E, int)
143#define HIDIOCSFLAG _IOW('H', 0x0F, int)
144#define HIDIOCGCOLLECTIONINDEX _IOW('H', 0x10, struct hiddev_usage_ref)
145#define HIDIOCGCOLLECTIONINFO _IOWR('H', 0x11, struct hiddev_collection_info)
146#define HIDIOCGPHYS(len) _IOC(_IOC_READ, 'H', 0x12, len)
147
148#define HIDIOCGUSAGES _IOWR('H', 0x13, struct hiddev_usage_ref_multi)
149#define HIDIOCSUSAGES _IOW('H', 0x14, struct hiddev_usage_ref_multi)
150
151#define HIDDEV_FLAG_UREF 0x1
152#define HIDDEV_FLAG_REPORT 0x2
153#define HIDDEV_FLAGS 0x3
154
155
156
157#ifdef __KERNEL__
158
159
160struct hid_device;
161struct hid_usage;
162struct hid_field;
163struct hid_report;
164
165#ifdef CONFIG_USB_HIDDEV
166int hiddev_connect(struct hid_device *hid, unsigned int force);
167void hiddev_disconnect(struct hid_device *);
168void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
169 struct hid_usage *usage, __s32 value);
170void hiddev_report_event(struct hid_device *hid, struct hid_report *report);
171#else
172static inline int hiddev_connect(struct hid_device *hid,
173 unsigned int force)
174{ return -1; }
175static inline void hiddev_disconnect(struct hid_device *hid) { }
176static inline void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
177 struct hid_usage *usage, __s32 value) { }
178static inline void hiddev_report_event(struct hid_device *hid, struct hid_report *report) { }
179#endif
180
181#endif
182#endif