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: HIDMaxUsageListLength.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 <USB3> 11/1/99 BWS [2405720] We need a better check for 'bit padding' items,
46 rather than just is constant. We will check to make sure the
47 item is constant, and has no usage, or zero usage. This means we
48 need to pass an additional parameter to some internal functions
49 <USB2> 3/6/99 BWS Eliminate warning
50 <USB1> 3/5/99 BWS first checked in
56 *------------------------------------------------------------------------------
58 * HIDMaxUsageListLength
61 * reportType - HIDP_Input, HIDP_Output, HIDP_Feature
62 * usagePage - Page Criteria or zero
63 * ptPreparsedData - Pre-Parsed Data
65 * Returns: length of list
67 *------------------------------------------------------------------------------
70 HIDMaxUsageListLength (HIDReportType reportType
,
72 HIDPreparsedDataRef preparsedDataRef
)
74 #pragma unused(usagePage) // not used, see comment below
76 HIDPreparsedDataPtr ptPreparsedData
= (HIDPreparsedDataPtr
) preparsedDataRef
;
77 HIDReportItem
*ptReportItem
;
83 * Disallow Null Pointers
85 if (ptPreparsedData
== NULL
)
87 if (ptPreparsedData
->hidTypeIfValid
!= kHIDOSType
)
88 return kHIDInvalidPreparsedDataErr
;
90 * Go through the ReportItems
91 * Filter on ReportType
92 * Sum the button counts
94 * NOTE: A more precise value for the maximum list length
95 * may be obtained by filtering out the usages that
96 * are not on the specified usage page. Most of
97 * the time the number returned below is the same
98 * as that returned by filtering usages. It is
99 * never smaller. The tradeoff is sometimes wasting
100 * a few words of RAM in exchange for speed.
103 for (i
=0; i
<ptPreparsedData
->reportItemCount
; i
++)
105 ptReportItem
= &ptPreparsedData
->reportItems
[i
];
106 if ((ptReportItem
->reportType
== reportType
)
107 && HIDIsButton(ptReportItem
, preparsedDataRef
))
108 iButtons
+= ptReportItem
->globals
.reportCount
;