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: HIDIsButtonOrValue.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.
48 <USB2> 3/5/99 BWS [2311366] HIDIsButton should screen out constants (at least
49 until other functions, like HIDGetButtons, are fixed to be able
50 to properly skip constants)
51 <USB1> 3/5/99 BWS first checked in
57 *-----------------------------------------------------------------------------
59 * HIDIsButton - Is the data button(s)?
62 * ptReportItem - Input/Output/Feature
67 *-----------------------------------------------------------------------------
69 Boolean
HIDIsButton(HIDReportItem
*ptReportItem
, HIDPreparsedDataRef preparsedDataRef
)
71 HIDPreparsedDataPtr ptPreparsedData
= (HIDPreparsedDataPtr
) preparsedDataRef
;
74 * Disallow Null Pointers
76 if (ptReportItem
==NULL
)
79 * Remove items that are constant and have no usage
81 if ((ptReportItem
->dataModes
& kHIDDataConstantBit
) == kHIDDataConstant
)
83 // if has no usages, then bit filler
84 if (ptReportItem
->usageItemCount
== 0)
87 // also check to see if there is a usage, but it is zero
89 // if the first usage item is range, then check that one
90 // (we will not worry about report items with multiple zero usages,
91 // as I dont think that is a case that makes sense)
92 if (ptReportItem
->firstUsageItem
< ptPreparsedData
->usageItemCount
)
94 HIDP_UsageItem
* ptUsageItem
= &ptPreparsedData
->usageItems
[ptReportItem
->firstUsageItem
];
96 // if it is a range usage, with both zero usages
97 if ((ptUsageItem
->isRange
&& ptUsageItem
->usageMinimum
== 0 && ptUsageItem
->usageMaximum
== 0) &&
98 // or not a range, and zero usage
99 (!ptUsageItem
->isRange
&& ptUsageItem
->usage
== 0))
100 // then this is bit filler
106 * Arrays and 1-bit Variables
108 return (((ptReportItem
->dataModes
& kHIDDataArrayBit
) == kHIDDataArray
)
109 || (ptReportItem
->globals
.reportSize
== 1));
113 *-----------------------------------------------------------------------------
115 * HIDIsVariable - Is the data variable(s)?
118 * ptReportItem - Input/Output/Feature
123 *-----------------------------------------------------------------------------
125 Boolean
HIDIsVariable(HIDReportItem
*ptReportItem
, HIDPreparsedDataRef preparsedDataRef
)
127 HIDPreparsedDataPtr ptPreparsedData
= (HIDPreparsedDataPtr
) preparsedDataRef
;
130 * Disallow Null Pointers
132 if (ptReportItem
==NULL
)
136 * Remove items that are constant and have no usage
138 if ((ptReportItem
->dataModes
& kHIDDataConstantBit
) == kHIDDataConstant
)
140 // if has no usages, then bit filler
141 if (ptReportItem
->usageItemCount
== 0)
144 // also check to see if there is a usage, but it is zero
146 // if the first usage item is range, then check that one
147 // (we will not worry about report items with multiple zero usages,
148 // as I dont think that is a case that makes sense)
149 if (ptReportItem
->firstUsageItem
< ptPreparsedData
->usageItemCount
)
151 HIDP_UsageItem
* ptUsageItem
= &ptPreparsedData
->usageItems
[ptReportItem
->firstUsageItem
];
153 // if it is a range usage, with both zero usages
154 if ((ptUsageItem
->isRange
&& ptUsageItem
->usageMinimum
== 0 && ptUsageItem
->usageMaximum
== 0) &&
155 // or not a range, and zero usage
156 (!ptUsageItem
->isRange
&& ptUsageItem
->usage
== 0))
157 // then this is bit filler
163 * Multi-bit Variables
165 return (((ptReportItem
->dataModes
& kHIDDataArrayBit
) != kHIDDataArray
)
166 && (ptReportItem
->globals
.reportSize
!= 1));