|
|
1.1 root 1: /*
2: * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
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.
11: *
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
18: * under the License.
19: *
20: * @APPLE_LICENSE_HEADER_END@
21: */
22: #ifndef __IOHIDDescriptorParser__
23: #define __IOHIDDescriptorParser__
24:
25: #include <IOKit/IOTypes.h>
26: #include <IOKit/hidsystem/IOHIDUsageTables.h>
27:
28: #ifdef __cplusplus
29: extern "C" {
30: #endif
31:
32: /* Types and enums required by these functions but not in IOTypes.h */
33:
34: typedef UInt8 Byte;
35: typedef SInt8 SignedByte;
36: typedef unsigned long FourCharCode;
37: typedef FourCharCode OSType;
38: typedef UInt32 ByteCount;
39:
40: enum {
41: noErr = 0
42: };
43:
44: /* End missing types and enums */
45:
46: enum
47: {
48: kHIDSuccess = 0,
49:
50: /* HID assigned error numbers are -13949 .. -13900 */
51: kHIDBaseError = -13950,
52:
53: kHIDNullStateErr,
54: kHIDBufferTooSmallErr,
55: kHIDValueOutOfRangeErr,
56: kHIDUsageNotFoundErr,
57: kHIDNotValueArrayErr,
58: kHIDInvalidPreparsedDataErr,
59: kHIDIncompatibleReportErr,
60: kHIDBadLogPhysValuesErr,
61: kHIDInvalidReportTypeErr,
62: kHIDInvalidReportLengthErr,
63: kHIDNullPointerErr,
64: kHIDBadParameterErr,
65: kHIDNotEnoughMemoryErr,
66: kHIDEndOfDescriptorErr,
67: kHIDUsagePageZeroErr,
68: kHIDBadLogicalMinimumErr,
69: kHIDBadLogicalMaximumErr,
70: kHIDInvertedLogicalRangeErr,
71: kHIDInvertedPhysicalRangeErr,
72: kHIDUnmatchedUsageRangeErr,
73: kHIDInvertedUsageRangeErr,
74: kHIDUnmatchedStringRangeErr,
75: kHIDUnmatchedDesignatorRangeErr,
76: kHIDReportSizeZeroErr,
77: kHIDReportCountZeroErr,
78: kHIDReportIDZeroErr,
79: kHIDInvalidRangePageErr,
80:
81: //
82: // HID device driver errors
83: //
84:
85: kHIDDeviceNotReady = -13910, // The device is still initializing, try again later
86: kHIDVersionIncompatibleErr,
87: };
88:
89: // types of HID reports (input, output, feature)
90: enum
91: {
92: kHIDInputReport = 1,
93: kHIDOutputReport,
94: kHIDFeatureReport,
95: kHIDUnknownReport = 255
96: };
97:
98: // flags passed to HIDOpenReportDescriptor
99: enum
100: {
101: kHIDFlag_StrictErrorChecking = 0x00000001
102: };
103:
104: typedef UInt32 HIDReportType;
105: typedef UInt32 HIDUsage;
106:
107: typedef void *HIDPreparsedDataRef;
108:
109: /*!
110: @typedef HIDUsageAndPage
111: @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.
112: @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.
113: @field usage Specifies the usage identifier within the usage page specified by usagePage of a button that is down.
114: @field usagePage Specifies the usage page identifier of a button that is down.
115: */
116: struct HIDUsageAndPage
117: {
118: HIDUsage usage;
119: HIDUsage usagePage;
120: };
121: typedef struct HIDUsageAndPage HIDUsageAndPage, *HIDUsageAndPagePtr;
122:
123: /*!
124: @typedef HIDCaps
125: @abstract The HIDCaps data structure is used by HID clients to hold the capabilities of a HID device.
126: @discussion This structure holds the parsed capabilities and data maximums returned for a device by the HIDGetCaps function.
127: @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.
128: @field usagePage Specifies the usage page identifier for this top level collection.
129: @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.
130: @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.
131: @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.
132: @field numberCollectionNodes Specifies the number of HIDCollectionNode structures that are returned for this top level collection by the HIDGetConnectionNodes function.
133: @field numberInputButtonCaps Specifies the number of input buttons.
134: @field numberInputValueCaps Specifies the number of input values.
135: @field numberOutputButtonCaps Specifies the number of output buttons.
136: @field numberOutputValueCaps Specifies the number of output values
137: @field numberFeatureButtonCaps Specifies the number of feature buttons.
138: @field numberFeatureValueCaps Specifies the number of feature values.
139: */
140: struct HIDCaps
141: {
142: HIDUsage usage;
143: HIDUsage usagePage;
144: ByteCount inputReportByteLength;
145: ByteCount outputReportByteLength;
146: ByteCount featureReportByteLength;
147: UInt32 numberCollectionNodes;
148: UInt32 numberInputButtonCaps;
149: UInt32 numberInputValueCaps;
150: UInt32 numberOutputButtonCaps;
151: UInt32 numberOutputValueCaps;
152: UInt32 numberFeatureButtonCaps;
153: UInt32 numberFeatureValueCaps;
154: };
155: typedef struct HIDCaps HIDCaps, * HIDCapsPtr;
156:
157: struct HIDCollectionNode
158: {
159: HIDUsage collectionUsage;
160: HIDUsage collectionUsagePage;
161: UInt32 parent;
162: UInt32 numberOfChildren;
163: UInt32 nextSibling;
164: UInt32 firstChild;
165: };
166: typedef struct HIDCollectionNode HIDCollectionNode, * HIDCollectionNodePtr;
167:
168: struct HIDButtonCaps
169: {
170: HIDUsage usagePage;
171: UInt32 reportID;
172: UInt32 bitField;
173: UInt32 collection;
174: HIDUsage collectionUsage;
175: HIDUsage collectionUsagePage;
176: Boolean isRange;
177: Boolean isStringRange;
178: Boolean isDesignatorRange;
179: Boolean isAbsolute;
180: SInt32 startBit; // Added esb 9-29-99
181:
182: union
183: {
184: struct
185: {
186: HIDUsage usageMin;
187: HIDUsage usageMax;
188: UInt32 stringMin;
189: UInt32 stringMax;
190: UInt32 designatorMin;
191: UInt32 designatorMax;
192: } range;
193: struct
194: {
195: HIDUsage usage;
196: HIDUsage reserved1;
197: UInt32 stringIndex;
198: UInt32 reserved2;
199: UInt32 designatorIndex;
200: UInt32 reserved3;
201: } notRange;
202: } u;
203: };
204: typedef struct HIDButtonCaps HIDButtonCaps, * HIDButtonCapsPtr;
205:
206: struct HIDValueCaps
207: {
208: HIDUsage usagePage;
209: UInt32 reportID;
210: UInt32 bitField;
211: UInt32 collection;
212: HIDUsage collectionUsage;
213: HIDUsage collectionUsagePage;
214:
215: Boolean isRange;
216: Boolean isStringRange;
217: Boolean isDesignatorRange;
218: Boolean isAbsolute;
219:
220: UInt32 startBit; // Added by esb 9-28-99
221: UInt32 bitSize;
222: UInt32 reportCount;
223:
224: SInt32 logicalMin;
225: SInt32 logicalMax;
226: SInt32 physicalMin;
227: SInt32 physicalMax;
228:
229: union
230: {
231: struct
232: {
233: HIDUsage usageMin;
234: HIDUsage usageMax;
235: UInt32 stringMin;
236: UInt32 stringMax;
237: UInt32 designatorMin;
238: UInt32 designatorMax;
239: } range;
240: struct
241: {
242: HIDUsage usage;
243: HIDUsage reserved1;
244: UInt32 stringIndex;
245: UInt32 reserved2;
246: UInt32 designatorIndex;
247: UInt32 reserved3;
248: } notRange;
249: } u;
250: };
251: typedef struct HIDValueCaps HIDValueCaps, * HIDValueCapsPtr;
252:
253: /*!
254: @function HIDOpenReportDescriptor
255: @abstract The HIDOpenReportDescriptor function allocates the memory the parser needs to handle the given report descriptor, and then parses the report descriptor.
256: @discussion When the parsed information is no longer needed, clients should call the HIDCloseReportDescriptor function.
257: @param hidReportDescriptor Contains a pointer to the actual HID report descriptor from the USB device's firmware
258: @param descriptorLength The length of the HID report descriptor
259: @param preparsedDataRef Preparsed data reference to be used for subsequent function calls
260: @param flags Flags for this runction are kHIDFlag_StrictErrorChecking = 0x00000001
261: @result OSStatus Returns an error code if an error was encountered or noErr on success.
262: */
263:
264: extern
265: OSStatus
266: HIDOpenReportDescriptor (void * hidReportDescriptor,
267: ByteCount descriptorLength,
268: HIDPreparsedDataRef * preparsedDataRef,
269: UInt32 flags);
270:
271: /*!
272: @function HIDCloseReportDescriptor
273: @abstract Disposes of the memory the parser allocated for the HIDOpenReportDescriptor function.
274: @param hidReportDescriptor Contains a pointer to the actual HID report descriptor from the USB device's firmware
275: @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.
276: @result OSStatus Returns an error code if an error was encountered or noErr on success.
277: */
278:
279: extern
280: OSStatus
281: HIDCloseReportDescriptor (HIDPreparsedDataRef preparsedDataRef);
282:
283: /*!
284: @function HIDGetButtonCaps
285: @abstract Returns the button capabilities structures for a HID device based on the given preparsed data.
286: @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
287: @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
288: @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.
289: @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
290: @result OSStatus Returns an error code if an error was encountered or noErr on success.
291: */
292:
293: extern
294: OSStatus
295: HIDGetButtonCaps (HIDReportType reportType,
296: HIDButtonCapsPtr buttonCaps,
297: UInt32 * buttonCapsSize,
298: HIDPreparsedDataRef preparsedDataRef);
299:
300: /*!
301: @function HIDGetCaps
302: @abstract Returns the capabilities of a HID device based on the given preparsed data.
303: @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
304: @param capabilities Points to a caller allocated buffer, that upon return contains the parsed capability information for this HID device.
305: @result OSStatus Returns an error code if an error was encountered or noErr on success.
306: */
307:
308: extern
309: OSStatus
310: HIDGetCaps (HIDPreparsedDataRef preparsedDataRef,
311: HIDCapsPtr capabilities);
312:
313: /*!
314: @function HIDGetCollectionNodes
315: @abstract Returns an array of HIDCollectionNode structures that describe the relationships and layout of the link collections within this top level collection.
316: @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.
317: @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.
318: @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.
319: @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
320: @result OSStatus Returns an error code if an error was encountered or noErr on success.
321: */
322:
323: extern
324: OSStatus
325: HIDGetCollectionNodes (HIDCollectionNodePtr collectionNodes,
326: UInt32 * collectionNodesSize,
327: HIDPreparsedDataRef preparsedDataRef);
328:
329: /*!
330: @function HIDGetScaledUsageValue
331: @abstract The HIDGetScaledUsageValue function returns the capabilities for all buttons for a given top level collection.
332: @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.
333: @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.
334: @param usagePage Specifies the usage page of the value to be retrieved.
335: @param collection Optionally specifies the link collection identifier of the value to be retrieved.
336: @param usage Specifies the usage of the scaled value to be retrieved.
337: @param usageValue Points to a variable, that on return from this routine holds the scaled value retrieved from the device report.
338: @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
339: @param report Points to the caller-allocated buffer that contains the device report data
340: @param reportLength Specifies the length, in bytes, of the report data provided at report
341: @result OSStatus Returns an error code if an error was encountered or noErr on success.
342: */
343:
344: extern
345: OSStatus
346: HIDGetScaledUsageValue (HIDReportType reportType,
347: HIDUsage usagePage,
348: UInt32 collection,
349: HIDUsage usage,
350: SInt32 * usageValue,
351: HIDPreparsedDataRef preparsedDataRef,
352: void * report,
353: ByteCount reportLength);
354:
355: /*!
356: @function HIDGetSpecificButtonCaps
357: @abstract Retrieves the capabilities for all buttons in a specific type of report that meet the search criteria.
358: @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.
359: @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.
360: @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.
361: @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.
362: @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.
363: @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.
364: @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.
365: @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
366: @result OSStatus Returns an error code if an error was encountered or noErr on success.
367: */
368:
369: extern
370: OSStatus
371: HIDGetSpecificButtonCaps (HIDReportType reportType,
372: HIDUsage usagePage,
373: UInt32 collection,
374: HIDUsage usage,
375: HIDButtonCapsPtr buttonCaps,
376: UInt32 * buttonCapsSize,
377: HIDPreparsedDataRef preparsedDataRef);
378:
379: /*!
380: @function HIDGetSpecificValueCaps
381: @abstract Retrieves the capabilities for all values in a specific type of report that meet the search criteria.
382: @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.
383: @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.
384: @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.
385: @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.
386: @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.
387: @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.
388: @param valueCapsLength 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.
389: @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
390: @result OSStatus Returns an error code if an error was encountered or noErr on success.
391: */
392:
393: extern
394: OSStatus
395: HIDGetSpecificValueCaps (HIDReportType reportType,
396: HIDUsage usagePage,
397: UInt32 collection,
398: HIDUsage usage,
399: HIDValueCapsPtr valueCaps,
400: UInt32 * valueCapsSize,
401: HIDPreparsedDataRef preparsedDataRef);
402:
403: /*!
404: @function HIDGetButtonsOnPage
405: @abstract Retrieves the button stat information for buttons on a specified usage page.
406: @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.
407: @param usagePage Specifies the usage page of the buttons for which to retrieve the current state.
408: @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.
409: @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.
410: @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.
411: @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
412: @param report Points to the caller-allocated buffer that contains the device report data
413: @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter
414: @result OSStatus Returns an error code if an error was encountered or noErr on success.
415: */
416:
417: extern
418: OSStatus
419: HIDGetButtonsOnPage (HIDReportType reportType,
420: HIDUsage usagePage,
421: UInt32 collection,
422: HIDUsage * usageList,
423: UInt32 * usageListSize,
424: HIDPreparsedDataRef preparsedDataRef,
425: void * report,
426: ByteCount reportLength);
427:
428: /*!
429: @function HIDGetButtons
430: @abstract The HIDGetButtons function takes a report from a HID device and gets the current state of the buttons in that report.
431: @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
432: @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.
433: @param usageList On return, points to a caller-allocated buffer that contains the usages of all the buttons that are pressed.
434: @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.
435: @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
436: @param report Points to the caller-allocated buffer that contains the device report data.
437: @param reportLength Specifies the length, in bytes, of the report data provided in the report parameter.
438: @result OSStatus Returns an error code if an error was encountered or noErr on success.
439: */
440:
441: extern
442: OSStatus
443: HIDGetButtons (HIDReportType reportType,
444: UInt32 collection,
445: HIDUsageAndPagePtr usageList,
446: UInt32 * usageListSize,
447: HIDPreparsedDataRef preparsedDataRef,
448: void * report,
449: ByteCount reportLength);
450:
451: /*!
452: @function HIDGetUsageValue
453: @abstract The HIDGetUsageValue function returns a value from a device data report given a selected search criteria.
454: @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.
455: @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.
456: @param usagePage Specifies the usage page of the value to retrieve.
457: @param collection Optionally specifies the link collection identifier of the value to be retrieved.
458: @param usage Specifies the usage of the value to be retrieved.
459: @param usageValue Points to a variable, that on return from this routine holds the value retrieved from the device report.
460: @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
461: @param report Points to the caller-allocated buffer that contains the device report data.
462: @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter.
463: @result OSStatus Returns an error code if an error was encountered or noErr on success.
464: */
465:
466: extern
467: OSStatus
468: HIDGetUsageValue (HIDReportType reportType,
469: HIDUsage usagePage,
470: UInt32 collection,
471: HIDUsage usage,
472: SInt32 * usageValue,
473: HIDPreparsedDataRef preparsedDataRef,
474: void * report,
475: ByteCount reportLength);
476:
477: /*!
478: @function HIDGetUsageValueArray
479: @abstract The HIDGetUsageValueArray function returns a value from a device data report given a selected search criteria.
480: @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.
481: @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.
482: @param usagePage Specifies the usage page of the data to be retrieved.
483: @param collection Optionally specifies the link collection identifier of the data to be retrieved.
484: @param usage Specifies the usage identifier of the value to be retrieved.
485: @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.
486: @param usageValueBufferSize Specifies the size, in bytes, of the buffer in the usageValueBuffer parameter.
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 size, in bytes, of the report data provided in report.
490: @result OSStatus Returns an error code if an error was encountered or noErr on success.
491: */
492:
493: extern
494: OSStatus
495: HIDGetUsageValueArray (HIDReportType reportType,
496: HIDUsage usagePage,
497: UInt32 collection,
498: HIDUsage usage,
499: Byte * usageValueBuffer,
500: ByteCount usageValueBufferSize,
501: HIDPreparsedDataRef preparsedDataRef,
502: void * report,
503: ByteCount reportLength);
504:
505: /*!
506: @function HIDGetValueCaps
507: @abstract The HIDGetValueCaps function retrieves the capabilities for all values for a specified top level collection.
508: @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.
509: @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.
510: @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.
511: @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.
512: @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
513: @result OSStatus Returns an error code if an error was encountered or noErr on success.
514: */
515:
516: extern
517: OSStatus
518: HIDGetValueCaps (HIDReportType reportType,
519: HIDValueCapsPtr valueCaps,
520: UInt32 * valueCapsSize,
521: HIDPreparsedDataRef preparsedDataRef);
522:
523: /*!
524: @function HIDMaxUsageListLength
525: @abstract The HIDMaxUsageListLength function returns the maximum number of buttons that can be returned from a given report type for the top level collection.
526: @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.
527: @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.
528: @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
529: @result OSStatus Returns an error code if an error was encountered or noErr on success.
530: */
531:
532: extern
533: UInt32
534: HIDMaxUsageListLength (HIDReportType reportType,
535: HIDUsage usagePage,
536: HIDPreparsedDataRef preparsedDataRef);
537:
538: /*!
539: @function HIDSetScaledUsageValue
540: @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.
541: @discussion The HIDSetScaledUsageValue function automatically handles the setting of the signed bit in the data to be sent to the device.
542: @param reportType Specifies the type of report. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
543: @param usagePage Specifies the usage page identifier of the value to be set in the report.
544: @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.
545: @param usage Specifies the usage identifier of the value to be set in the report.
546: @param usageValue Specifies the physical, or scaled, value to be set in the value for the given report.
547: @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
548: @param report Points to the caller-allocated buffer that contains the device report data.
549: @param Specifies the length, in bytes of the report data specified in the report parameter.
550: @result OSStatus Returns an error code if an error was encountered or noErr on success.
551: */
552:
553: extern
554: OSStatus
555: HIDSetScaledUsageValue (HIDReportType reportType,
556: HIDUsage usagePage,
557: UInt32 collection,
558: HIDUsage usage,
559: SInt32 usageValue,
560: HIDPreparsedDataRef preparsedDataRef,
561: void * report,
562: ByteCount reportLength);
563:
564: /*!
565: @function HIDSetButtons
566: @abstract The HIDSetButtons function takes a report from a HID device and returns the current state of the buttons in that report.
567: @param reportType Specifies the type of repor. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
568: @param usagePage Specifies the usage page identifier of the value to be set in the report.
569: @param collection Optionally specifies the link collection identifier to distinguish between buttons. If this parameter is zero, it is ignored.
570: @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.
571: @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.
572: @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
573: @param report Points to the caller-allocated buffer that contains the device report data.
574: @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter.
575: @result OSStatus Returns an error code if an error was encountered or noErr on success.
576: */
577:
578: extern
579: OSStatus
580: HIDSetButtons (HIDReportType reportType,
581: HIDUsage usagePage,
582: UInt32 collection,
583: HIDUsage * usageList,
584: UInt32 * usageListSize,
585: HIDPreparsedDataRef preparsedDataRef,
586: void * report,
587: ByteCount reportLength);
588:
589: /*!
590: @function HIDSetUsageValue
591: @abstract The HIDSetUsageValue function sets a value in a give report.
592: @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.
593: @param reportType Specifies the type of report. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
594: @param usagePage Specifies the usage page identifier of the value to be set in the report.
595: @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.
596: @param usage Specifies the usage identifier of the value to be set in the report.
597: @param usageValue Specifies the data that is to be set in the value for the given report.
598: @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
599: @param report Points to the caller-allocated buffer that contains the device report data.
600: @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter.
601: @result OSStatus Returns an error code if an error was encountered or noErr on success.
602: */
603:
604: extern
605: OSStatus
606: HIDSetUsageValue (HIDReportType reportType,
607: HIDUsage usagePage,
608: UInt32 collection,
609: HIDUsage usage,
610: SInt32 usageValue,
611: HIDPreparsedDataRef preparsedDataRef,
612: void * report,
613: ByteCount reportLength);
614:
615: /*!
616: @function HIDSetUsageValueArray
617: @abstract The HIDSetUsageValueArray function sets an array of values in a given report.
618: @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.
619: @param reportType Specifies the type of report. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
620: @param usagePage Specifies the usage page identifier of the value to be set in the report.
621: @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.
622: @param usage Specifies the usage identifier of the value to be set in the report.
623: @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.
624: @param usageValueBufferLength Specifies the size, in bytes, of the buffer in the usageValueBuffer parameter.
625: @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
626: @param report Points to the caller-allocated buffer that contains the device report data.
627: @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter.
628: @result OSStatus Returns an error code if an error was encountered or noErr on success.
629: */
630:
631: extern
632: OSStatus
633: HIDSetUsageValueArray (HIDReportType reportType,
634: HIDUsage usagePage,
635: UInt32 collection,
636: HIDUsage usage,
637: Byte * usageValueBuffer,
638: ByteCount usageValueBufferLength,
639: HIDPreparsedDataRef preparsedDataRef,
640: void * report,
641: ByteCount reportLength);
642:
643: /*!
644: @function HIDUsageListDifference
645: @abstract The HIDUsageListDifference function compares and provides the differences between two lists of buttons.
646: @param previousUsageList Points to the older button list to be used for comparison.
647: @param currentUsageList Points to the newer button list to be used for comparison.
648: @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.
649: @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.
650: @param usageListsLength Specifies the length, in array elements, of the buffers provided in the currentUsageList and previousUssageList parameters.
651: @result OSStatus Returns an error code if an error was encountered or noErr on success.
652: */
653:
654: extern
655: OSStatus
656: HIDUsageListDifference (HIDUsage * previousUsageList,
657: HIDUsage * currentUsageList,
658: HIDUsage * breakUsageList,
659: HIDUsage * makeUsageList,
660: UInt32 usageListsSize);
661:
662: /*!
663: @function HIDSetButton
664: @abstract The HIDSetButton function takes a report from a HID device and sets the current state of the specified button in that report.
665: @param reportType Specifies the type of report. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport.
666: @param usagePage Specifies the usage page identifier of the value to be set in the report.
667: @param collection Optionally specifies the link collection identifier to distinguish between buttons. If this parameter is zero, it is ignored.
668: @param usage Points to a caller-allocated buffer that contains the button data to be set in the report in the report parameter.
669: @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function
670: @param report Points to the caller-allocated buffer that contains the device report data.
671: @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter.
672: @result OSStatus Returns an error code if an error was encountered or noErr on success.
673: */
674:
675: extern
676: OSStatus
677: HIDSetButton (HIDReportType reportType,
678: HIDUsage usagePage,
679: UInt32 collection,
680: HIDUsage usage,
681: HIDPreparsedDataRef preparsedDataRef,
682: void * report,
683: ByteCount reportLength);
684:
685:
686: #ifdef __cplusplus
687: }
688: #endif
689:
690:
691: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.