2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
28 Contains: xxx put contents here xxx
30 Version: xxx put version here xxx
32 Copyright: © 1999 by Apple Computer, Inc., all rights reserved.
36 DRI: xxx put dri here xxx
38 Other Contact: xxx put other contact here xxx
40 Technology: xxx put technology here xxx
46 Change History (most recent first):
48 <5> 11/1/99 BWS [2405720] We need a better check for 'bit padding' items,
49 rather than just is constant. We will check to make sure the
50 item is constant, and has no usage, or zero usage. This means we
51 need to pass an additional parameter to some internal functions
52 <4> 4/7/99 BWS Add flags to report items (for reverse)
53 <3> 3/19/99 BWS Build stub library
54 <2> 3/17/99 BWS [2314839] Add flags field to HIDPreparsedData, is set in
55 HIDOpenReportDescriptor
56 <1> 3/5/99 BWS first checked in
60 #include <IOKit/hidsystem/IOHIDDescriptorParser.h>
62 /* the following constants are from the USB HID Specification (www.usb.org)*/
64 /*------------------------------------------------------------------------------*/
68 /* --------------------------------------------------------- */
69 /* | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | */
70 /* | Tag | Type | Size | */
71 /* --------------------------------------------------------- */
72 /*------------------------------------------------------------------------------*/
74 kHIDItemSizeMask
= 0x03,
75 kHIDItemTagMask
= 0xF0,
77 kHIDItemTypeMask
= 0x0C,
78 kHIDItemTypeShift
= 2,
79 kHIDLongItemHeader
= 0xFE
82 /*------------------------------------------------------------------------------*/
84 /* HID Item Type Definitions */
86 /*------------------------------------------------------------------------------*/
94 /*------------------------------------------------------------------------------*/
96 /* HID Item Tag Definitions - Main Items */
98 /*------------------------------------------------------------------------------*/
102 kHIDTagCollection
= 0x0A,
103 kHIDTagFeature
= 0x0B,
104 kHIDTagEndCollection
= 0x0C
107 /*------------------------------------------------------------------------------*/
109 /* HID Item Tag Definitions - Globals */
111 /*------------------------------------------------------------------------------*/
113 kHIDTagUsagePage
= 0,
114 kHIDTagLogicalMinimum
= 1,
115 kHIDTagLogicalMaximum
= 2,
116 kHIDTagPhysicalMinimum
= 3,
117 kHIDTagPhysicalMaximum
= 4,
118 kHIDTagUnitExponent
= 5,
120 kHIDTagReportSize
= 7,
122 kHIDTagReportCount
= 9,
127 /*------------------------------------------------------------------------------*/
129 /* HID Item Tag Definitions - Locals */
131 /*------------------------------------------------------------------------------*/
134 kHIDTagUsageMinimum
= 1,
135 kHIDTagUsageMaximum
= 2,
136 kHIDTagDesignatorIndex
= 3,
137 kHIDTagDesignatorMinimum
= 4,
138 kHIDTagDesignatorMaximum
= 5,
139 kHIDTagStringIndex
= 7,
140 kHIDTagStringMinimum
= 8,
141 kHIDTagStringMaximum
= 9,
142 kHIDTagSetDelimiter
= 0x0A
145 /*------------------------------------------------------------------------------*/
147 /* HID Main Item Header Bit Definitions */
149 /*------------------------------------------------------------------------------*/
151 kHIDDataBufferedBytes
= 0x0100,
152 kHIDDataVolatileBit
= 0x80,
153 kHIDDataVolatile
= 0x80,
154 kHIDDataNullStateBit
= 0x40,
155 kHIDDataNullState
= 0x40,
156 kHIDDataNoPreferredBit
= 0x20,
157 kHIDDataNoPreferred
= 0x20,
158 kHIDDataNonlinearBit
= 0x10,
159 kHIDDataNonlinear
= 0x10,
160 kHIDDataWrapBit
= 0x08,
162 kHIDDataRelativeBit
= 0x04,
163 kHIDDataRelative
= 0x04,
164 kHIDDataAbsolute
= 0x00,
165 kHIDDataVariableBit
= 0x02,
166 kHIDDataVariable
= 0x02,
167 kHIDDataArrayBit
= 0x02,
168 kHIDDataArray
= 0x00,
169 kHIDDataConstantBit
= 0x01,
170 kHIDDataConstant
= 0x01
173 /*------------------------------------------------------------------------------*/
175 /* HID Collection Data Definitions */
177 /*------------------------------------------------------------------------------*/
179 kHIDPhysicalCollection
= 0x00,
180 kHIDApplicationCollection
= 0x01
183 /*------------------------------------------------------------------------------*/
185 /* HIDLibrary private defs */
187 /*------------------------------------------------------------------------------*/
200 UInt32 unsignedValue
;
202 typedef struct HIDItem HIDItem
;
204 struct HIDGlobalItems
207 SInt32 logicalMinimum
;
208 SInt32 logicalMaximum
;
209 SInt32 physicalMinimum
;
210 SInt32 physicalMaximum
;
213 ByteCount reportSize
;
218 typedef struct HIDGlobalItems HIDGlobalItems
;
220 struct HIDReportSizes
223 SInt32 inputBitCount
;
224 SInt32 outputBitCount
;
225 SInt32 featureBitCount
;
227 typedef struct HIDReportSizes HIDReportSizes
;
233 SInt32 firstUsageItem
;
234 SInt32 usageItemCount
;
235 SInt32 firstReportItem
;
236 SInt32 reportItemCount
;
242 typedef struct HIDCollection HIDCollection
;
246 kHIDReportItemFlag_Reversed
= 0x00000001
252 HIDGlobalItems globals
;
256 SInt32 firstUsageItem
;
257 SInt32 usageItemCount
;
258 SInt32 firstStringItem
;
259 SInt32 stringItemCount
;
260 SInt32 firstDesigItem
;
261 SInt32 desigItemCount
;
264 typedef struct HIDReportItem HIDReportItem
;
266 struct HIDP_UsageItem
275 typedef struct HIDP_UsageItem HIDP_UsageItem
;
285 typedef struct HIDStringItem HIDStringItem
;
286 typedef HIDStringItem HIDDesignatorItem
;
288 struct HIDPreparsedData
290 OSType hidTypeIfValid
;
291 HIDCollection
* collections
;
292 UInt32 collectionCount
;
293 HIDReportItem
* reportItems
;
294 UInt32 reportItemCount
;
295 HIDReportSizes
* reports
;
297 HIDP_UsageItem
* usageItems
;
298 UInt32 usageItemCount
;
299 HIDStringItem
* stringItems
;
300 UInt32 stringItemCount
;
301 HIDDesignatorItem
* desigItems
;
302 UInt32 desigItemCount
;
305 ByteCount numBytesAllocated
;
307 typedef struct HIDPreparsedData HIDPreparsedData
;
308 typedef HIDPreparsedData
* HIDPreparsedDataPtr
;
312 HIDCheckReport (HIDReportType reportType
,
313 HIDPreparsedDataRef preparsedDataRef
,
314 HIDReportItem
* reportItem
,
316 ByteCount reportLength
);
321 HIDGetData (void * report
,
322 ByteCount reportLength
,
330 HIDPostProcessRIValue (HIDReportItem
* reportItem
,
335 HIDPreProcessRIValue (HIDReportItem
* reportItem
,
340 HIDHasUsage (HIDPreparsedDataRef preparsedDataRef
,
341 HIDReportItem
* reportItem
,
349 HIDIsButton (HIDReportItem
* reportItem
,
350 HIDPreparsedDataRef preparsedDataRef
);
354 HIDIsVariable (HIDReportItem
* reportItem
,
355 HIDPreparsedDataRef preparsedDataRef
);
359 HIDPutData (void * report
,
360 ByteCount reportLength
,
367 HIDScaleUsageValueIn (HIDReportItem
* reportItem
,
369 SInt32
* scaledValue
);
373 HIDScaleUsageValueOut (HIDReportItem
* reportItem
,
375 SInt32
* scaledValue
);
379 HIDUsageAndPageFromIndex (HIDPreparsedDataRef preparsedDataRef
,
380 HIDReportItem
* reportItem
,
382 HIDUsageAndPage
* usageAndPage
);
386 HIDUsageInRange (HIDP_UsageItem
* usageItem
,