2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 File: HIDProcessCollection.c
25 Contains: xxx put contents here xxx
27 Version: xxx put version here xxx
29 Copyright: © 1999 by Apple Computer, Inc., all rights reserved.
33 DRI: xxx put dri here xxx
35 Other Contact: xxx put other contact here xxx
37 Technology: xxx put technology here xxx
43 Change History (most recent first):
45 <USB1> 3/5/99 BWS first checked in
51 *------------------------------------------------------------------------------
53 * HIDProcessCollection - Process a Collection MainItem
56 * ptDescriptor - The Descriptor Structure
57 * ptPreparsedData - The PreParsedData Structure
59 * ptDescriptor - The Descriptor Structure
60 * ptPreparsedData - The PreParsedData Structure
62 * kHIDSuccess - Success
63 * kHIDNullPointerErr - Argument, Pointer was Null
65 *------------------------------------------------------------------------------
67 OSStatus
HIDProcessCollection(HIDReportDescriptor
*ptDescriptor
, HIDPreparsedDataPtr ptPreparsedData
)
69 HIDCollection
*collections
;
70 HIDCollection
*ptCollection
;
74 * Disallow NULL Pointers
76 if ((ptDescriptor
== NULL
) || (ptPreparsedData
== NULL
))
77 return kHIDNullPointerErr
;
79 * Initialize the new Collection Structure
81 iCollection
= ptPreparsedData
->collectionCount
++;
82 collections
= ptPreparsedData
->collections
;
83 ptCollection
= &collections
[iCollection
];
84 ptCollection
->data
= ptDescriptor
->item
.unsignedValue
;
85 ptCollection
->firstUsageItem
= ptDescriptor
->firstUsageItem
;
86 ptCollection
->usageItemCount
= ptPreparsedData
->usageItemCount
- ptDescriptor
->firstUsageItem
;
87 ptDescriptor
->firstUsageItem
= ptPreparsedData
->usageItemCount
;
88 ptCollection
->children
= 0;
89 ptCollection
->nextSibling
= ptDescriptor
->sibling
;
90 ptDescriptor
->sibling
= 0;
91 ptCollection
->firstChild
= 0;
92 ptCollection
->usagePage
= ptDescriptor
->globals
.usagePage
;
93 ptCollection
->firstReportItem
= ptPreparsedData
->reportItemCount
;
95 * Set up the relationship with the parent Collection
97 parent
= ptDescriptor
->parent
;
98 ptCollection
->parent
= parent
;
99 collections
[parent
].firstChild
= iCollection
;
100 collections
[parent
].children
++;
101 ptDescriptor
->parent
= iCollection
;
103 * Save the parent Collection Information on the stack
105 ptDescriptor
->collectionStack
[ptDescriptor
->collectionNesting
++] = parent
;
110 *------------------------------------------------------------------------------
112 * HIDProcessEndCollection - Process an EndCollection MainItem
115 * ptDescriptor - The Descriptor Structure
116 * ptPreparsedData - The PreParsedData Structure
118 * ptPreparsedData - The PreParsedData Structure
120 * kHIDSuccess - Success
121 * kHIDNullPointerErr - Argument, Pointer was Null
123 *------------------------------------------------------------------------------
125 OSStatus
HIDProcessEndCollection(HIDReportDescriptor
*ptDescriptor
, HIDPreparsedDataPtr ptPreparsedData
)
127 HIDCollection
*ptCollection
;
130 * Remember the number of ReportItem MainItems in this Collection
132 ptCollection
= &ptPreparsedData
->collections
[ptDescriptor
->parent
];
133 ptCollection
->reportItemCount
= ptPreparsedData
->reportItemCount
- ptCollection
->firstReportItem
;
135 * Restore the parent Collection Data
137 iCollection
= ptDescriptor
->collectionStack
[--ptDescriptor
->collectionNesting
];
138 ptDescriptor
->sibling
= ptDescriptor
->parent
;
139 ptDescriptor
->parent
= iCollection
;