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: HIDProcessGlobalItem.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
44 Change History (most recent first):
46 <USB2> 10/18/99 DF Lets try not reporting an error with zero report count
47 <USB1> 3/5/99 BWS first checked in
53 *------------------------------------------------------------------------------
55 * HIDProcessGlobalItem - Process a GlobalItem
58 * ptDescriptor - The Descriptor Structure
59 * ptPreparsedData - The PreParsedData Structure
61 * ptDescriptor - The Descriptor Structure
62 * ptPreparsedData - The PreParsedData Structure
64 * kHIDSuccess - Success
65 * kHIDNullPointerErr - Argument, Pointer was Null
67 *------------------------------------------------------------------------------
69 OSStatus
HIDProcessGlobalItem(HIDReportDescriptor
*ptDescriptor
, HIDPreparsedDataPtr ptPreparsedData
)
71 HIDReportSizes
*ptReport
;
72 HIDGlobalItems
*ptGlobals
;
76 * Disallow NULL Pointers
78 if ((ptDescriptor
== NULL
) || (ptPreparsedData
== NULL
))
79 return kHIDNullPointerErr
;
83 ptItem
= &ptDescriptor
->item
;
84 ptGlobals
= &ptDescriptor
->globals
;
90 case kHIDTagUsagePage
:
91 if (ptItem
->unsignedValue
== 0)
92 return kHIDUsagePageZeroErr
;
93 ptGlobals
->usagePage
= ptItem
->unsignedValue
;
98 case kHIDTagLogicalMinimum
:
99 ptGlobals
->logicalMinimum
= ptItem
->signedValue
;
104 case kHIDTagLogicalMaximum
:
105 ptGlobals
->logicalMaximum
= ptItem
->signedValue
;
110 case kHIDTagPhysicalMinimum
:
111 ptGlobals
->physicalMinimum
= ptItem
->signedValue
;
116 case kHIDTagPhysicalMaximum
:
117 ptGlobals
->physicalMaximum
= ptItem
->signedValue
;
122 case kHIDTagUnitExponent
:
123 ptGlobals
->unitExponent
= ptItem
->signedValue
;
129 ptGlobals
->units
= ptItem
->unsignedValue
;
132 * Report Size in Bits
134 case kHIDTagReportSize
:
135 ptGlobals
->reportSize
= ptItem
->unsignedValue
;
136 if (ptGlobals
->reportSize
== 0)
137 return kHIDReportSizeZeroErr
;
142 case kHIDTagReportID
:
143 if (ptItem
->unsignedValue
== 0)
144 return kHIDReportIDZeroErr
;
146 * Look for the Report ID in the table
149 while ((reportIndex
< ptPreparsedData
->reportCount
)
150 && (ptPreparsedData
->reports
[reportIndex
].reportID
!= ptItem
->unsignedValue
))
153 * Initialize the entry if it's new and there's room for it
154 * Start with 8 bits for the Report ID
156 if (reportIndex
== ptPreparsedData
->reportCount
)
158 ptReport
= &ptPreparsedData
->reports
[ptPreparsedData
->reportCount
++];
159 ptReport
->reportID
= ptItem
->unsignedValue
;
160 ptReport
->inputBitCount
= 8;
161 ptReport
->outputBitCount
= 8;
162 ptReport
->featureBitCount
= 8;
165 * Remember which report is being processed
167 ptGlobals
->reportID
= ptItem
->unsignedValue
;
168 ptGlobals
->reportIndex
= reportIndex
;
173 case kHIDTagReportCount
:
175 // some device actually have a report count of zero specified. we must allow it!
176 if (ptItem
->unsignedValue
== 0)
177 return kHIDReportCountZeroErr
;
179 ptGlobals
->reportCount
= ptItem
->unsignedValue
;
185 ptDescriptor
->globalsStack
[ptDescriptor
->globalsNesting
++] = ptDescriptor
->globals
;
191 ptDescriptor
->globals
= ptDescriptor
->globalsStack
[--ptDescriptor
->globalsNesting
];