]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Families/IOHIDSystem/IOHIDDescriptorParser/HIDUsageListDifference.c
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: HIDUsageListDifference.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 * In - Is a usage in a UsageList?
56 * piUsageList - usage List
57 * iUsageListLength - Max entries in usage Lists
60 * Returns: true or false
62 *------------------------------------------------------------------------------
64 static Boolean
IsUsageInUsageList(HIDUsage
*piUsageList
, UInt32 iUsageListLength
, HIDUsage usage
)
67 for (i
= 0; i
< iUsageListLength
; i
++)
68 if (piUsageList
[i
] == usage
)
74 *------------------------------------------------------------------------------
76 * HIDUsageListDifference - Return adds and drops given present and past
79 * piPreviouUL - Previous usage List
80 * piCurrentUL - Current usage List
81 * piBreakUL - Break usage List
82 * piMakeUL - Make usage List
83 * iUsageListLength - Max entries in usage Lists
85 * piBreakUL - Break usage List
86 * piMakeUL - Make usage List
89 *------------------------------------------------------------------------------
91 OSStatus
HIDUsageListDifference(HIDUsage
*piPreviousUL
, HIDUsage
*piCurrentUL
, HIDUsage
*piBreakUL
, HIDUsage
*piMakeUL
, UInt32 iUsageListLength
)
97 for (i
= 0; i
< iUsageListLength
; i
++)
100 * If in Current but not Previous then it's a Make
102 usage
= piCurrentUL
[i
];
103 if ((usage
!= 0) && (!IsUsageInUsageList(piPreviousUL
,iUsageListLength
,usage
))
104 && (!IsUsageInUsageList(piMakeUL
,iMakeLength
,usage
)))
105 piMakeUL
[iMakeLength
++] = usage
;
107 * If in Previous but not Current then it's a Break
109 usage
= piPreviousUL
[i
];
110 if ((usage
!= 0) && (!IsUsageInUsageList(piCurrentUL
,iUsageListLength
,usage
))
111 && (!IsUsageInUsageList(piBreakUL
,iBreakLength
,usage
)))
112 piBreakUL
[iBreakLength
++] = usage
;
115 * Clear the rest of the usage Lists
117 while (iMakeLength
< iUsageListLength
)
118 piMakeUL
[iMakeLength
++] = 0;
119 while (iBreakLength
< iUsageListLength
)
120 piBreakUL
[iBreakLength
++] = 0;