Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Enoch_Modules/i386/include/IOKit/hidsystem/IOHIDDescriptorParser.h

1/*
2 * @APPLE_LICENSE_HEADER_START@
3 *
4 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23#ifndef __IOHIDDescriptorParser__
24#define __IOHIDDescriptorParser__
25
26#include <TargetConditionals.h>
27#include <IOKit/IOTypes.h>
28#include <IOKit/hidsystem/IOHIDUsageTables.h>
29#if !TARGET_OS_EMBEDDED
30 #include <IOKit/ndrvsupport/IOMacOSTypes.h>
31#endif
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#if TARGET_OS_EMBEDDED
38/* Types and enums required by these functions but not in IOTypes.h */
39
40typedef UInt8Byte;
41typedef SInt8SignedByte;
42typedef unsigned longFourCharCode;
43typedef FourCharCodeOSType;
44typedef UInt32ByteCount;
45
46enum {
47noErr= 0
48};
49#endif
50
51/* End missing types and enums */
52
53enum
54{
55kHIDSuccess= 0,
56
57/* HID assigned error numbers are -13949 .. -13900 */
58kHIDBaseError= -13950,
59
60kHIDNullStateErr,
61kHIDBufferTooSmallErr,
62kHIDValueOutOfRangeErr,
63kHIDUsageNotFoundErr,
64kHIDNotValueArrayErr,
65kHIDInvalidPreparsedDataErr,
66kHIDIncompatibleReportErr,
67kHIDBadLogPhysValuesErr,
68kHIDInvalidReportTypeErr,
69kHIDInvalidReportLengthErr,
70kHIDNullPointerErr,
71kHIDBadParameterErr,
72kHIDNotEnoughMemoryErr,
73kHIDEndOfDescriptorErr,
74kHIDUsagePageZeroErr,
75kHIDBadLogicalMinimumErr,
76kHIDBadLogicalMaximumErr,
77kHIDInvertedLogicalRangeErr,
78kHIDInvertedPhysicalRangeErr,
79kHIDUnmatchedUsageRangeErr,
80kHIDInvertedUsageRangeErr,
81kHIDUnmatchedStringRangeErr,
82kHIDUnmatchedDesignatorRangeErr,
83kHIDReportSizeZeroErr,
84kHIDReportCountZeroErr,
85kHIDReportIDZeroErr,
86kHIDInvalidRangePageErr,
87
88//
89// HID device driver errors
90//
91
92kHIDDeviceNotReady = -13910, // The device is still initializing, try again later
93kHIDVersionIncompatibleErr,
94};
95
96// types of HID reports (input, output, feature)
97enum
98{
99kHIDInputReport= 1,
100kHIDOutputReport,
101kHIDFeatureReport,
102kHIDUnknownReport=255
103};
104
105// flags passed to HIDOpenReportDescriptor
106enum
107{
108kHIDFlag_StrictErrorChecking = 0x00000001
109};
110
111typedef UInt32HIDReportType;
112typedef UInt32HIDUsage;
113
114typedef void *HIDPreparsedDataRef;
115
116/*!
117 @typedef HIDUsageAndPage
118 @abstract The HIDUsageAndPage data structure is used by HID clients when obtaining status of buttons to hold the usage page and usage of a button that is down.
119 @discussion Clients use the HIDUSageAndPage structure with the HIDGetButtonsEx function to obtain both the usage page and usage identifiers of each button that is down.
120 @field usage Specifies the usage identifier within the usage page specified by usagePage of a button that is down.
121 @field usagePage Specifies the usage page identifier of a button that is down.
122 */
123struct HIDUsageAndPage
124{
125HIDUsageusage;
126HIDUsageusagePage;
127};
128typedef struct HIDUsageAndPage HIDUsageAndPage, *HIDUsageAndPagePtr;
129
130/*!
131 @typedef HIDCaps
132 @abstract The HIDCaps data structure is used by HID clients to hold the capabilities of a HID device.
133 @discussion This structure holds the parsed capabilities and data maximums returned for a device by the HIDGetCaps function.
134 @field usage Specifies the specific class of functionality that this device provides. This value is dependent and specific to the value provided in the usagePage field. For example, a keyboard could have a usagePage of kHIDUsagePage_Generic and a usage of kHIDUsage_Generic_Keyboard.
135 @field usagePage Specifies the usage page identifier for this top level collection.
136 @field inputReportByteLength Specifies the maximum length, in bytes, of an input report for this device, including the report ID which is unilaterally prepended to the device data.
137 @field outputReportByteLength Specifies the maximum length, in bytes, of an output report for this device, including the report ID which is unilaterally prepended to the device data.
138 @field featureReportByteLength Specifies the maximum length, in bytes, of a feature report for this device, including the report ID which is unilaterally prepended to the device data.
139 @field numberCollectionNodes Specifies the number of HIDCollectionNode structures that are returned for this top level collection by the HIDGetConnectionNodes function.
140 @field numberInputButtonCaps Specifies the number of input buttons.
141 @field numberInputValueCaps Specifies the number of input values.
142 @field numberOutputButtonCaps Specifies the number of output buttons.
143 @field numberOutputValueCaps Specifies the number of output values
144 @field numberFeatureButtonCaps Specifies the number of feature buttons.
145 @field numberFeatureValueCaps Specifies the number of feature values.
146 */
147struct HIDCaps
148{
149HIDUsageusage;
150HIDUsageusagePage;
151ByteCountinputReportByteLength;
152ByteCountoutputReportByteLength;
153ByteCountfeatureReportByteLength;
154UInt32numberCollectionNodes;
155UInt32numberInputButtonCaps;
156UInt32numberInputValueCaps;
157UInt32numberOutputButtonCaps;
158UInt32numberOutputValueCaps;
159UInt32numberFeatureButtonCaps;
160UInt32numberFeatureValueCaps;
161};
162typedef struct HIDCaps HIDCaps, * HIDCapsPtr;
163
164struct HIDCapabilities {
165 HIDUsage usage;
166 HIDUsage usagePage;
167 ByteCount inputReportByteLength;
168 ByteCount outputReportByteLength;
169 ByteCount featureReportByteLength;
170 UInt32 numberCollectionNodes;
171 UInt32 numberInputButtonCaps;
172 UInt32 numberInputValueCaps;
173 UInt32 numberOutputButtonCaps;
174 UInt32 numberOutputValueCaps;
175 UInt32 numberFeatureButtonCaps;
176 UInt32 numberFeatureValueCaps;
177};
178typedef struct HIDCapabilities HIDCapabilities, * HIDCapabilitiesPtr;
179
180
181struct HIDCollectionNode
182{
183HIDUsagecollectionUsage;
184HIDUsagecollectionUsagePage;
185UInt32parent;
186UInt32numberOfChildren;
187UInt32nextSibling;
188UInt32firstChild;
189};
190typedef struct HIDCollectionNode HIDCollectionNode, * HIDCollectionNodePtr;
191
192struct HIDButtonCaps
193{
194HIDUsageusagePage;
195UInt32reportID;
196UInt32bitField;
197UInt32collection;
198HIDUsagecollectionUsage;
199HIDUsagecollectionUsagePage;
200BooleanisRange;
201BooleanisStringRange;
202BooleanisDesignatorRange;
203BooleanisAbsolute;
204 SInt32 startBit;// Added esb 9-29-99
205
206union
207{
208struct
209{
210HIDUsageusageMin;
211HIDUsageusageMax;
212UInt32stringMin;
213UInt32stringMax;
214UInt32designatorMin;
215UInt32designatorMax;
216} range;
217struct
218{
219HIDUsageusage;
220HIDUsagereserved1;
221UInt32stringIndex;
222UInt32reserved2;
223UInt32designatorIndex;
224UInt32reserved3;
225} notRange;
226} u;
227};
228typedef struct HIDButtonCaps HIDButtonCaps, * HIDButtonCapsPtr;
229
230struct HIDButtonCapabilities
231{
232HIDUsageusagePage;
233UInt32reportID;
234UInt32bitField;
235UInt32collection;
236HIDUsagecollectionUsage;
237HIDUsagecollectionUsagePage;
238BooleanisRange;
239BooleanisStringRange;
240BooleanisDesignatorRange;
241BooleanisAbsolute;
242
243 SInt32 unitExponent;// Added KH 1/25/01
244 SInt32 units;// Added KH 1/25/01
245// UInt32 reserved;// Not added KH 1/25/01
246 SInt32 startBit;// Added esb 9-29-99
247 UInt32 pbVersion;// Added KH 1/25/01
248
249union
250{
251struct
252{
253HIDUsageusageMin;
254HIDUsageusageMax;
255UInt32stringMin;
256UInt32stringMax;
257UInt32designatorMin;
258UInt32designatorMax;
259} range;
260struct
261{
262HIDUsageusage;
263HIDUsagereserved1;
264UInt32stringIndex;
265UInt32reserved2;
266UInt32designatorIndex;
267UInt32reserved3;
268} notRange;
269} u;
270};
271typedef struct HIDButtonCapabilities HIDButtonCapabilities, * HIDButtonCapabilitiesPtr;
272
273struct HIDValueCaps
274{
275HIDUsageusagePage;
276UInt32reportID;
277UInt32bitField;
278UInt32collection;
279HIDUsagecollectionUsage;
280HIDUsagecollectionUsagePage;
281
282BooleanisRange;
283BooleanisStringRange;
284BooleanisDesignatorRange;
285BooleanisAbsolute;
286
287 UInt32startBit;// Added by esb 9-28-99
288UInt32bitSize;
289UInt32reportCount;
290
291SInt32logicalMin;
292SInt32logicalMax;
293SInt32physicalMin;
294SInt32physicalMax;
295
296union
297{
298struct
299{
300HIDUsageusageMin;
301HIDUsageusageMax;
302UInt32stringMin;
303UInt32stringMax;
304UInt32designatorMin;
305UInt32designatorMax;
306} range;
307struct
308{
309HIDUsageusage;
310HIDUsagereserved1;
311UInt32stringIndex;
312UInt32reserved2;
313UInt32designatorIndex;
314UInt32reserved3;
315} notRange;
316} u;
317};
318typedef struct HIDValueCaps HIDValueCaps, * HIDValueCapsPtr;
319
320struct HIDValueCapabilities
321{
322HIDUsageusagePage;
323UInt32reportID;
324UInt32bitField;
325UInt32collection;
326HIDUsagecollectionUsage;
327HIDUsagecollectionUsagePage;
328
329BooleanisRange;
330BooleanisStringRange;
331BooleanisDesignatorRange;
332BooleanisAbsolute;
333
334UInt32bitSize;
335UInt32reportCount;
336
337SInt32logicalMin;
338SInt32logicalMax;
339SInt32physicalMin;
340SInt32physicalMax;
341
342 SInt32 unitExponent;// Added KH 1/25/01
343 SInt32 units;// Added KH 1/25/01
344// UInt32 reserved;// Not added KH 1/25/01
345 SInt32 startBit;// Added esb 9-29-99// Moved here KH 1/25/01
346 UInt32 pbVersion;// Added KH 1/25/01
347
348union
349{
350struct
351{
352HIDUsageusageMin;
353HIDUsageusageMax;
354UInt32stringMin;
355UInt32stringMax;
356UInt32designatorMin;
357UInt32designatorMax;
358} range;
359struct
360{
361HIDUsageusage;
362HIDUsagereserved1;
363UInt32stringIndex;
364UInt32reserved2;
365UInt32designatorIndex;
366UInt32reserved3;
367} notRange;
368} u;
369};
370typedef struct HIDValueCapabilities HIDValueCapabilities, * HIDValueCapabilitiesPtr;
371
372/*!
373 @function HIDOpenReportDescriptor
374 @abstract The HIDOpenReportDescriptor function allocates the memory the parser needs to handle the given report descriptor, and then parses the report descriptor.
375 @discussion When the parsed information is no longer needed, clients should call the HIDCloseReportDescriptor function.
376 @param hidReportDescriptor Contains a pointer to the actual HID report descriptor from the USB device's firmware
377 @param descriptorLength The length of the HID report descriptor
378 @param preparsedDataRef Preparsed data reference to be used for subsequent function calls
379 @param flags Flags for this runction are kHIDFlag_StrictErrorChecking = 0x00000001
380 @result OSStatus Returns an error code if an error was encountered or noErr on success.
381 */
382
383extern
384OSStatus
385HIDOpenReportDescriptor (void *hidReportDescriptor,
386ByteCountdescriptorLength,
387HIDPreparsedDataRef *preparsedDataRef,
388UInt32flags);
389
390/*!
391 @function HIDCloseReportDescriptor
392 @abstract Disposes of the memory the parser allocated for the HIDOpenReportDescriptor function.
393 @param hidReportDescriptor Contains a pointer to the actual HID report descriptor from the USB device's firmware
394 @param preparsedDataRef Preparsed data reference for the report that is returned by the HIDOpenReportDescriptor function. After making a call to the HIDCloseReportDescriptor function, the preparsedDataRef is invalid and should not be used.
395 @result OSStatus Returns an error code if an error was encountered or noErr on success.
396 */
397
398extern
399OSStatus
400HIDCloseReportDescriptor (HIDPreparsedDataRefpreparsedDataRef);
401
402/*!
403 @function HIDGetButtonCaps
404 @abstract Returns the button capabilities structures for a HID device based on the given preparsed data.
405 @param reportType Specifies the type of report for which to retrieve the scaled value. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport
406 @param buttonCaps Points to a caller-allocated buffer that will contain, on return, an array of HIDButtonCaps structures. The structures contain information for all buttons that meet the search criteria
407 @param buttonCapsSize Contains the size of the buttonCaps array passed in to the function and is set to the number of elements actually placed in the array after the call completes.
408 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
409 @result OSStatus Returns an error code if an error was encountered or noErr on success.
410 */
411
412extern
413OSStatus
414HIDGetButtonCaps (HIDReportTypereportType,
415HIDButtonCapsPtrbuttonCaps,
416UInt32*buttonCapsSize,
417HIDPreparsedDataRefpreparsedDataRef);
418
419/*!
420 @function HIDGetButtonCapabilities
421 @abstract Returns the button capabilities structures for a HID device based on the given preparsed data.
422 @param reportType Specifies the type of report for which to retrieve the scaled value. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport
423 @param buttonCaps Points to a caller-allocated buffer that will contain, on return, an array of HIDButtonCapabilities structures. The structures contain information for all buttons that meet the search criteria
424 @param buttonCapsSize Contains the size of the buttonCaps array passed in to the function and is set to the number of elements actually placed in the array after the call completes.
425 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
426 @result OSStatus Returns an error code if an error was encountered or noErr on success.
427 */
428
429extern
430OSStatus
431HIDGetButtonCapabilities (HIDReportTypereportType,
432HIDButtonCapabilitiesPtrbuttonCaps,
433UInt32*buttonCapsSize,
434HIDPreparsedDataRefpreparsedDataRef);
435
436/*!
437 @function HIDGetCaps
438 @abstract Returns the capabilities of a HID device based on the given preparsed data.
439 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
440 @param capabilities Points to a caller allocated buffer, that upon return contains the parsed capability information for this HID device.
441 @result OSStatus Returns an error code if an error was encountered or noErr on success.
442 */
443
444extern
445OSStatus
446HIDGetCaps (HIDPreparsedDataRefpreparsedDataRef,
447HIDCapsPtrcapabilities);
448
449/*!
450 @function HIDGetCapabilities
451 @abstract Returns the capabilities of a HID device based on the given preparsed data.
452 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
453 @param capabilities Points to a caller allocated buffer, that upon return contains the parsed capability information for this HID device.
454 @result OSStatus Returns an error code if an error was encountered or noErr on success.
455 */
456
457extern
458OSStatus
459HIDGetCapabilities (HIDPreparsedDataRefpreparsedDataRef,
460HIDCapabilitiesPtrcapabilities);
461
462/*!
463 @function HIDGetCollectionNodes
464 @abstract Returns an array of HIDCollectionNode structures that describe the relationships and layout of the link collections within this top level collection.
465 @discussion The length of the buffer required, in array elements, for an entire collection node array is found in the HIDCaps structure member numberCollectionNodes. You obtain the HIDCaps information by calling the HIDGetCaps function. For information on the relationships of link collections described by the data returned from this routine, see the descripton of the HIDCollectionNode structure.
466 @param collectionNodes Points to a caller-allocated array of HIDCollectionNode structures in which this routine returns an entry for each collection within the top level collection. A collection is a group of corresponding HID descriptors containing input, output, and feature items that have some common relationship to one another. For example, a pointer collection contains items for x and y position data, and button data.
467 @param collectionNodesSize On input, specifies the length in array elements of the buffer provided at collectionNodes. On output, this parameter is set to the number of entries in the collectionNodes array that were initialized.
468 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
469 @result OSStatus Returns an error code if an error was encountered or noErr on success.
470 */
471
472extern
473OSStatus
474HIDGetCollectionNodes (HIDCollectionNodePtrcollectionNodes,
475UInt32 *collectionNodesSize,
476HIDPreparsedDataRefpreparsedDataRef);
477
478/*!
479 @function HIDGetScaledUsageValue
480 @abstract The HIDGetScaledUsageValue function returns the capabilities for all buttons for a given top level collection.
481 @discussion Clients who which to obtain all capabilities for a usage that contains multiple data items for a single usage that corresponds to a HID byte array, must call the HIDGetUsageValueArray function.
482 @param reportType Specifies the type of report for which to retrieve the scaled value. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
483 @param usagePage Specifies the usage page of the value to be retrieved.
484 @param collection Optionally specifies the link collection identifier of the value to be retrieved.
485 @param usage Specifies the usage of the scaled value to be retrieved.
486 @param usageValue Points to a variable, that on return from this routine holds the scaled value retrieved from the device report.
487 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
488 @param report Points to the caller-allocated buffer that contains the device report data
489 @param reportLength Specifies the length, in bytes, of the report data provided at report
490 @result OSStatus Returns an error code if an error was encountered or noErr on success.
491 */
492
493extern
494OSStatus
495HIDGetScaledUsageValue (HIDReportTypereportType,
496HIDUsageusagePage,
497UInt32collection,
498HIDUsageusage,
499SInt32 *usageValue,
500HIDPreparsedDataRefpreparsedDataRef,
501void *report,
502ByteCountreportLength);
503
504/*!
505 @function HIDGetSpecificButtonCaps
506 @abstract Retrieves the capabilities for all buttons in a specific type of report that meet the search criteria.
507 @discussion The HIDGetSpecificButtonCaps function retrieves capability data for buttons that meet a given search criteria, as opposed to the HIDGetButtonCaps function which returns the capability data for all buttons on the device. Calling this routine specifying zero for usagePage, usage and collection is equivalent to calling the HIDGetButtonCaps function.
508 @param reportType Specifies the type of report for which to retrieve the button capabilities. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
509 @param usagePage Specifies a usage page identifier to use as a search criteria. If this parameter is non-zero, then only buttons that specify this usage page will be retrieved.
510 @param collection Specifies a link collection identifier to use as a search criteria. If this parameter is non-zero, then only buttons that are part of the specified link collection are retrieved.
511 @param usage Specifies a usage identifier to use as a search criteria. If this parameter is non-zero, then only buttons that match the value specified are retrieved.
512 @param buttonCaps Points to a caller-allocated buffer that will contain, on return, an array of HIDButtonCaps structures. The structures contain information for all buttons that meet the search criteria.
513 @param buttonCapsLength On input, specifies the length, in array elements, of the buffer provided in the buttonCaps parameter. On output, this parameter is set to the actual number of elements that were returned by the function call, in the buffer provided in the buttonCaps parameter, if the routine completed without error. The correct length necessary to retrieve the button capabilities can be found in the capability data returned for the device by the HIDGetCaps function.
514 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
515 @result OSStatus Returns an error code if an error was encountered or noErr on success.
516 */
517
518extern
519OSStatus
520HIDGetSpecificButtonCaps (HIDReportTypereportType,
521HIDUsageusagePage,
522UInt32collection,
523HIDUsageusage,
524HIDButtonCapsPtrbuttonCaps,
525UInt32 *buttonCapsSize,
526HIDPreparsedDataRefpreparsedDataRef);
527
528/*!
529 @function HIDGetSpecificButtonCapabilities
530 @abstract Retrieves the capabilities for all buttons in a specific type of report that meet the search criteria.
531 @discussion The HIDGetSpecificButtonCapabilities function retrieves capability data for buttons that meet a given search criteria, as opposed to the HIDGetButtonCapabilities function which returns the capability data for all buttons on the device. Calling this routine specifying zero for usagePage, usage and collection is equivalent to calling the HIDGetButtonCapabilities function.
532 @param reportType Specifies the type of report for which to retrieve the button capabilities. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
533 @param usagePage Specifies a usage page identifier to use as a search criteria. If this parameter is non-zero, then only buttons that specify this usage page will be retrieved.
534 @param collection Specifies a link collection identifier to use as a search criteria. If this parameter is non-zero, then only buttons that are part of the specified link collection are retrieved.
535 @param usage Specifies a usage identifier to use as a search criteria. If this parameter is non-zero, then only buttons that match the value specified are retrieved.
536 @param buttonCaps Points to a caller-allocated buffer that will contain, on return, an array of HIDButtonCapabilities structures. The structures contain information for all buttons that meet the search criteria.
537 @param buttonCapsLength On input, specifies the length, in array elements, of the buffer provided in the buttonCaps parameter. On output, this parameter is set to the actual number of elements that were returned by the function call, in the buffer provided in the buttonCaps parameter, if the routine completed without error. The correct length necessary to retrieve the button capabilities can be found in the capability data returned for the device by the HIDGetCaps function.
538 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
539 @result OSStatus Returns an error code if an error was encountered or noErr on success.
540 */
541
542extern
543OSStatus
544HIDGetSpecificButtonCapabilities (HIDReportTypereportType,
545HIDUsageusagePage,
546UInt32collection,
547HIDUsageusage,
548HIDButtonCapabilitiesPtrbuttonCaps,
549UInt32 *buttonCapsSize,
550HIDPreparsedDataRefpreparsedDataRef);
551
552/*!
553 @function HIDGetSpecificValueCaps
554 @abstract Retrieves the capabilities for all values in a specific type of report that meet the search criteria.
555 @discussion The HIDGetSpecificValueCaps function retrieves capability data for values that meet given search criteria, as opposed to the HIDGetValueCaps function, which returns the capability data for all values on the device. Calling this routine with a value of zero for usagePage, usage and collection parameters is equivalent to calling the HIDGetValueCaps function.
556 @param reportType Specifies the type of report for which to retrieve the value capabilities. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport or kHIDFeatureReport.
557 @param usagePage Specifies a usage page identifier to use as a search criteria. If this parameter is non-zero, then only values that specify this usage page will be retrieved.
558 @param collection Specifies a link collection identifier to use as a search criteria. If this parameter is non-zero, then only values that are part of this link collection will be retrieved.
559 @param usage Specifies a usage identifier to use as a search criteria. If this parameter is non-zero, then only values that specify this usage will be retrieved.
560 @param valueCaps Points to a caller-allocated buffer that will contain, on return, an array of HIDValueCaps structures that contain information for all values that meet the search criteria.
561 @param valueCapsSize Specifies the length on input, in array elements, of the buffer provided in the valueCaps parameter. On output, this parameter is set to the actual number of elements that were returned by this function call, in the buffer provided in the valueCaps parameter, if the routine completed without error. The correct length necessary to retrieve the value capabilities can be found in the capability data returned for the device from the HIDGetCaps function.
562 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
563 @result OSStatus Returns an error code if an error was encountered or noErr on success.
564 */
565
566extern
567OSStatus
568HIDGetSpecificValueCaps (HIDReportTypereportType,
569HIDUsageusagePage,
570UInt32collection,
571HIDUsageusage,
572HIDValueCapsPtrvalueCaps,
573UInt32 *valueCapsSize,
574HIDPreparsedDataRefpreparsedDataRef);
575
576/*!
577 @function HIDGetSpecificValueCapabilities
578 @abstract Retrieves the capabilities for all values in a specific type of report that meet the search criteria.
579 @discussion The HIDGetSpecificValueCapabilities function retrieves capability data for values that meet given search criteria, as opposed to the HIDGetValueCapabilities function, which returns the capability data for all values on the device. Calling this routine with a value of zero for usagePage, usage and collection parameters is equivalent to calling the HIDGetValueCapabilities function.
580 @param reportType Specifies the type of report for which to retrieve the value capabilities. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport or kHIDFeatureReport.
581 @param usagePage Specifies a usage page identifier to use as a search criteria. If this parameter is non-zero, then only values that specify this usage page will be retrieved.
582 @param collection Specifies a link collection identifier to use as a search criteria. If this parameter is non-zero, then only values that are part of this link collection will be retrieved.
583 @param usage Specifies a usage identifier to use as a search criteria. If this parameter is non-zero, then only values that specify this usage will be retrieved.
584 @param valueCaps Points to a caller-allocated buffer that will contain, on return, an array of HIDValueCapabilities structures that contain information for all values that meet the search criteria.
585 @param valueCapsSize Specifies the length on input, in array elements, of the buffer provided in the valueCaps parameter. On output, this parameter is set to the actual number of elements that were returned by this function call, in the buffer provided in the valueCaps parameter, if the routine completed without error. The correct length necessary to retrieve the value capabilities can be found in the capability data returned for the device from the HIDGetCaps function.
586 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
587 @result OSStatus Returns an error code if an error was encountered or noErr on success.
588 */
589
590extern
591OSStatus
592HIDGetSpecificValueCapabilities (HIDReportTypereportType,
593HIDUsageusagePage,
594UInt32collection,
595HIDUsageusage,
596HIDValueCapabilitiesPtrvalueCaps,
597UInt32 *valueCapsSize,
598HIDPreparsedDataRefpreparsedDataRef);
599
600/*!
601 @function HIDGetButtonsOnPage
602 @abstract Retrieves the button stat information for buttons on a specified usage page.
603 @param reportType Specifies the type of report, provided in the report parameter, from which to retrieve the buttons. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport or kHIDFeatureReport.
604 @param usagePage Specifies the usage page of the buttons for which to retrieve the current state.
605 @param collection Optionally specifies the link collection identifier used to retrieve only specific button states. If this value is non-zero, only the buttons that are part of the given collection are returned.
606 @param usageList On return, points to a caller-allocated buffer that contains the usages of all the buttons that are perssed and belong to the usage page specified in the usagePage parameter.
607 @param usageListSize Is the size, in array elements, of the buffer provided in the usageList parameter. On return, this parameter contains the number of button states that were set by this routine. If the error kHIDBufferTooSmallErr was returned, this parameter contains the number of array elements required to hold all button data requested. The maximum number of buttons that can ever be returned for a given type of report can be obtained by calling the HIDMaxUsageListLength function.
608 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
609 @param report Points to the caller-allocated buffer that contains the device report data
610 @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter
611 @result OSStatus Returns an error code if an error was encountered or noErr on success.
612 */
613
614extern
615OSStatus
616HIDGetButtonsOnPage (HIDReportTypereportType,
617HIDUsageusagePage,
618UInt32collection,
619HIDUsage *usageList,
620UInt32 *usageListSize,
621HIDPreparsedDataRefpreparsedDataRef,
622void *report,
623ByteCountreportLength);
624
625/*!
626 @function HIDGetButtons
627 @abstract The HIDGetButtons function takes a report from a HID device and gets the current state of the buttons in that report.
628 @param reportType Specifies the type of report, provided in the report parameter, from which to retrieve the buttons. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport or kHIDFeatureReport
629 @param collection Optionally specifies the link collection identifier used to retrieve only specific button states. If this value is non-zero, only the buttons that are part of the given collection are returned.
630 @param usageList On return, points to a caller-allocated buffer that contains the usages of all the buttons that are pressed.
631 @param usageListSize Is the size, in array elements, of the buffer provided in the usageList parameter. On return, this parameter contains the number of button states that were set by this routine. If the error kHIDBufferToSmallErr was returned, this parameter contains the number of array elements required to hold all button data requested. The maximum number of buttons that can ever be returned for a given type of report can be obtained by calling the HIDMaxUsageListLength function.
632 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
633 @param report Points to the caller-allocated buffer that contains the device report data.
634 @param reportLength Specifies the length, in bytes, of the report data provided in the report parameter.
635 @result OSStatus Returns an error code if an error was encountered or noErr on success.
636 */
637
638extern
639OSStatus
640HIDGetButtons (HIDReportTypereportType,
641UInt32collection,
642HIDUsageAndPagePtrusageList,
643UInt32 *usageListSize,
644HIDPreparsedDataRefpreparsedDataRef,
645void *report,
646ByteCountreportLength);
647
648extern
649OSStatus
650HIDGetNextButtonInfo (HIDReportType reportType,
651 HIDUsage usagePage,
652 HIDUsage usage,
653 UInt32 * collection,
654 UInt8 * reportID,
655 HIDPreparsedDataRef preparsedDataRef);
656
657extern
658OSStatus
659HIDGetNextUsageValueInfo (HIDReportType reportType,
660 HIDUsage usagePage,
661 HIDUsage usage,
662 UInt32 * collection,
663 UInt8 * reportID,
664 HIDPreparsedDataRef preparsedDataRef);
665
666extern
667OSStatus
668HIDGetReportLength (HIDReportType reportType,
669 UInt8 reportID,
670 ByteCount * reportLength,
671 HIDPreparsedDataRef preparsedDataRef);
672
673/*!
674 @function HIDGetUsageValue
675 @abstract The HIDGetUsageValue function returns a value from a device data report given a selected search criteria.
676 @discussion The HIDGetUsageValue function does not sign the value. To have the sign bit automatically applied, use the HIDGetScaledUsageValue function instead. For manually assigning the sign bit, the position of the sign bit can be found in the HIDValueCaps structure for this value. Clients who wish to obtain all data for a usage that contains multiple data items for a single usage, corresponding to a HID byte array, must call the HIDGetUsageValueArray function instead.
677 @param reportType Specifies the type of report, provided in report, from which to retrieve the value. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
678 @param usagePage Specifies the usage page of the value to retrieve.
679 @param collection Optionally specifies the link collection identifier of the value to be retrieved.
680 @param usage Specifies the usage of the value to be retrieved.
681 @param usageValue Points to a variable, that on return from this routine holds the value retrieved from the device report.
682 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
683 @param report Points to the caller-allocated buffer that contains the device report data.
684 @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter.
685 @result OSStatus Returns an error code if an error was encountered or noErr on success.
686 */
687
688extern
689OSStatus
690HIDGetUsageValue (HIDReportTypereportType,
691HIDUsageusagePage,
692UInt32collection,
693HIDUsageusage,
694SInt32 *usageValue,
695HIDPreparsedDataRefpreparsedDataRef,
696void *report,
697ByteCountreportLength);
698
699/*!
700 @function HIDGetUsageValueArray
701 @abstract The HIDGetUsageValueArray function returns a value from a device data report given a selected search criteria.
702 @discussion When the HIDGetUsageValueArray function retrieves the data, it fills in the buffer in little-endian order beginning with the least significant bit of the data for this usage. The data is filled in without regard to byte alignment and is shifted such that the least significant bit is placed as the 1st bit of the given buffer.
703 @param reportType Specifies the type of report, provided in report, from which to retrieve the value. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
704 @param usagePage Specifies the usage page of the data to be retrieved.
705 @param collection Optionally specifies the link collection identifier of the data to be retrieved.
706 @param usage Specifies the usage identifier of the value to be retrieved.
707 @param usageValueBuffer Points to a caller-allocated buffer that contains, on output, the data from the device. The correct length for this buffer can be found by multiplying the reportCount and bitSize fields of the HIDValueCaps structure for the value and rounding the resulting value up to the nearest byte.
708 @param usageValueBufferSize Specifies the size, in bytes, of the buffer in the usageValueBuffer parameter.
709 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
710 @param report Points to the caller-allocated buffer that contains the device report data.
711 @param reportLength Specifies the size, in bytes, of the report data provided in report.
712 @result OSStatus Returns an error code if an error was encountered or noErr on success.
713 */
714
715extern
716OSStatus
717HIDGetUsageValueArray (HIDReportTypereportType,
718HIDUsageusagePage,
719UInt32collection,
720HIDUsageusage,
721Byte *usageValueBuffer,
722ByteCountusageValueBufferSize,
723HIDPreparsedDataRefpreparsedDataRef,
724void *report,
725ByteCountreportLength);
726
727/*!
728 @function HIDGetValueCaps
729 @abstract The HIDGetValueCaps function retrieves the capabilities for all values for a specified top level collection.
730 @discussion The HIDGetValueCaps function retrieves the capability data for all values in a top level collection without regard for the usage, usage page or collection of the value. To retrieve value capabilities for a specific usage, usage page or collection, use the HIDGetSpecificValueCaps function.
731 @param reportType Specifies the type of report for which to retrieve the value capabilities. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
732 @param valueCaps On return, points to a caller-allocated buffer that contains an array of HIDValueCaps structures containing information for all values in the top level collection.
733 @param valueCapsSize On input, specifies the size in array elements of the buffer provided in the valueCaps parameter. On output, this parameter is set to the actual number of elements that were returned in the buffer provided in the valueCaps parameter, if the function completed without error. The correct length necessary to retrieve the value capabilities can be found in the capability data returned for the device by the HIDGetCaps function.
734 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
735 @result OSStatus Returns an error code if an error was encountered or noErr on success.
736 */
737
738extern
739OSStatus
740HIDGetValueCaps (HIDReportTypereportType,
741HIDValueCapsPtrvalueCaps,
742UInt32 *valueCapsSize,
743HIDPreparsedDataRefpreparsedDataRef);
744
745/*!
746 @function HIDGetValueCapabilities
747 @abstract The HIDGetValueCapabilities function retrieves the capabilities for all values for a specified top level collection.
748 @discussion The HIDGetValueCapabilities function retrieves the capability data for all values in a top level collection without regard for the usage, usage page or collection of the value. To retrieve value capabilities for a specific usage, usage page or collection, use the HIDGetSpecificValueCapabilities function.
749 @param reportType Specifies the type of report for which to retrieve the value capabilities. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
750 @param valueCaps On return, points to a caller-allocated buffer that contains an array of HIDValueCapabilities structures containing information for all values in the top level collection.
751 @param valueCapsSize On input, specifies the size in array elements of the buffer provided in the valueCaps parameter. On output, this parameter is set to the actual number of elements that were returned in the buffer provided in the valueCaps parameter, if the function completed without error. The correct length necessary to retrieve the value capabilities can be found in the capability data returned for the device by the HIDGetCapabilities function.
752 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
753 @result OSStatus Returns an error code if an error was encountered or noErr on success.
754 */
755
756extern
757OSStatus
758HIDGetValueCapabilities (HIDReportTypereportType,
759HIDValueCapabilitiesPtrvalueCaps,
760UInt32 *valueCapsSize,
761HIDPreparsedDataRefpreparsedDataRef);
762
763extern
764OSStatus
765HIDInitReport (HIDReportType reportType,
766 UInt8 reportID,
767 HIDPreparsedDataRef preparsedDataRef,
768 void * report,
769 ByteCount reportLength);
770
771/*!
772 @function HIDMaxUsageListLength
773 @abstract The HIDMaxUsageListLength function returns the maximum number of buttons that can be returned from a given report type for the top level collection.
774 @param reportType Specifies the type of report for which to get a maximum usage count. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
775 @param usagePage Optionally specifies the usage page identifier to use as a search criteria. If this parameter is zero, the function returns the number of buttons for the entire top-level collection regardless of the actual value of the usage page.
776 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
777 @result OSStatus Returns an error code if an error was encountered or noErr on success.
778 */
779
780extern
781UInt32
782HIDMaxUsageListLength (HIDReportTypereportType,
783HIDUsageusagePage,
784HIDPreparsedDataRefpreparsedDataRef);
785
786/*!
787 @function HIDSetScaledUsageValue
788 @abstract The HIDSetScaledUsageValue function takes a signed physical (scaled) number and converts it to the logical, or device representation and inserts it in a given report.
789 @discussion The HIDSetScaledUsageValue function automatically handles the setting of the signed bit in the data to be sent to the device.
790 @param reportType Specifies the type of report. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
791 @param usagePage Specifies the usage page identifier of the value to be set in the report.
792 @param collection Optionally specifies the link collection identifier to distinguish between values that have the same usage page and usage identifiers. If this parameter is zero, it will be ignored.
793 @param usage Specifies the usage identifier of the value to be set in the report.
794 @param usageValue Specifies the physical, or scaled, value to be set in the value for the given report.
795 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
796 @param report Points to the caller-allocated buffer that contains the device report data.
797 @param Specifies the length, in bytes of the report data specified in the report parameter.
798 @result OSStatus Returns an error code if an error was encountered or noErr on success.
799 */
800
801extern
802OSStatus
803HIDSetScaledUsageValue (HIDReportTypereportType,
804HIDUsageusagePage,
805UInt32collection,
806HIDUsageusage,
807SInt32usageValue,
808HIDPreparsedDataRefpreparsedDataRef,
809void *report,
810ByteCountreportLength);
811
812/*!
813 @function HIDSetButtons
814 @abstract The HIDSetButtons function takes a report from a HID device and returns the current state of the buttons in that report.
815 @param reportType Specifies the type of repor. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
816 @param usagePage Specifies the usage page identifier of the value to be set in the report.
817 @param collection Optionally specifies the link collection identifier to distinguish between buttons. If this parameter is zero, it is ignored.
818 @param usageList Points to a caller-allocated buffer that contains an array of button data to be set in the report in the report parameter.
819 @param usageListSize Specifies the size, in array elements, of the buffer provided in the usageList parameter. If an error is returned by a call to this function, the usageListLength parameter contains the location in the array provided in the usageList parameter where the error was encountered. All array entries encountered prior to the error location were successfully set in the report provided in the report parameter.
820 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
821 @param report Points to the caller-allocated buffer that contains the device report data.
822 @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter.
823 @result OSStatus Returns an error code if an error was encountered or noErr on success.
824 */
825
826extern
827OSStatus
828HIDSetButtons (HIDReportTypereportType,
829HIDUsageusagePage,
830UInt32collection,
831HIDUsage *usageList,
832UInt32 *usageListSize,
833HIDPreparsedDataRefpreparsedDataRef,
834void *report,
835ByteCountreportLength);
836
837/*!
838 @function HIDSetUsageValue
839 @abstract The HIDSetUsageValue function sets a value in a give report.
840 @discussion The HIDSetUsageVlaue function does not automatically handle the sign bit. Clients must either manually set the sign bit, at the position provided in the HIDValueCaps structure for this value, or call the HIDSetScaledUsageValue function.
841 @param reportType Specifies the type of report. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
842 @param usagePage Specifies the usage page identifier of the value to be set in the report.
843 @param collection Optionally specifies the link collection identifier to distinguish between values that have the same usage page and usage identifiers. If this parameter is zero, it is ignored.
844 @param usage Specifies the usage identifier of the value to be set in the report.
845 @param usageValue Specifies the data that is to be set in the value for the given report.
846 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
847 @param report Points to the caller-allocated buffer that contains the device report data.
848 @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter.
849 @result OSStatus Returns an error code if an error was encountered or noErr on success.
850 */
851
852extern
853OSStatus
854HIDSetUsageValue (HIDReportTypereportType,
855HIDUsageusagePage,
856UInt32collection,
857HIDUsageusage,
858SInt32usageValue,
859HIDPreparsedDataRefpreparsedDataRef,
860void *report,
861ByteCountreportLength);
862
863/*!
864 @function HIDSetUsageValueArray
865 @abstract The HIDSetUsageValueArray function sets an array of values in a given report.
866 @discussion The HIDSetUsageValue function does not automatically handle the sign bit. Clients must either manually set the sign bit, at the position provided in the HIDValueCaps structure for this value, or call the HIDSetScaledUsageValue function.
867 @param reportType Specifies the type of report. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
868 @param usagePage Specifies the usage page identifier of the value to be set in the report.
869 @param collection Optionally specifies the link collection identifier to distinguish between values that have the same usage page and usage identifiers. If this parameter is zero, it is ignored.
870 @param usage Specifies the usage identifier of the value to be set in the report.
871 @param usageValueBuffer Points to a caller-allocated buffer that contains, on output, the data from the device. The correct length for this buffer can be found by multiplying the reportCount and bitSize fields of the HIDValueCaps structure for this value and rounding the resulting value up to the nearest byte.
872 @param usageValueBufferLength Specifies the size, in bytes, of the buffer in the usageValueBuffer parameter.
873 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
874 @param report Points to the caller-allocated buffer that contains the device report data.
875 @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter.
876 @result OSStatus Returns an error code if an error was encountered or noErr on success.
877 */
878
879extern
880OSStatus
881HIDSetUsageValueArray (HIDReportTypereportType,
882HIDUsageusagePage,
883UInt32collection,
884HIDUsageusage,
885Byte *usageValueBuffer,
886ByteCountusageValueBufferLength,
887HIDPreparsedDataRefpreparsedDataRef,
888void *report,
889ByteCountreportLength);
890
891/*!
892 @function HIDUsageListDifference
893 @abstract The HIDUsageListDifference function compares and provides the differences between two lists of buttons.
894 @param previousUsageList Points to the older button list to be used for comparison.
895 @param currentUsageList Points to the newer button list to be used for comparison.
896 @param breakUsageList On return, points to a caller-allocated buffer that contains the buttons set in the older list, specified in the previousUsageList parameter, but not set in the new list, specified in the currentUsageList parameter.
897 @param makeUsageList On return, points to a caller-allocated buffer that contains the buttons set in the new list, specified in the currentUsageList parameter, but not set in the old list, specified in the previousUsageList parameter.
898 @param usageListsLength Specifies the length, in array elements, of the buffers provided in the currentUsageList and previousUssageList parameters.
899 @result OSStatus Returns an error code if an error was encountered or noErr on success.
900 */
901
902extern
903OSStatus
904HIDUsageListDifference (HIDUsage *previousUsageList,
905HIDUsage *currentUsageList,
906HIDUsage *breakUsageList,
907HIDUsage *makeUsageList,
908UInt32usageListsSize);
909
910/*!
911 @function HIDSetButton
912 @abstract The HIDSetButton function takes a report from a HID device and sets the current state of the specified button in that report.
913 @param reportType Specifies the type of report. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
914 @param usagePage Specifies the usage page identifier of the value to be set in the report.
915 @param collection Optionally specifies the link collection identifier to distinguish between buttons. If this parameter is zero, it is ignored.
916 @param usage Points to a caller-allocated buffer that contains the button data to be set in the report in the report parameter.
917 @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
918 @param report Points to the caller-allocated buffer that contains the device report data.
919 @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter.
920 @result OSStatus Returns an error code if an error was encountered or noErr on success.
921 */
922
923extern
924OSStatus
925HIDSetButton (HIDReportTypereportType,
926HIDUsageusagePage,
927UInt32collection,
928HIDUsageusage,
929HIDPreparsedDataRefpreparsedDataRef,
930void *report,
931ByteCountreportLength);
932
933
934#ifdef __cplusplus
935}
936#endif
937
938
939#endif
940

Archive Download this file

Revision: 2238