Annotation of XNU/iokit/Families/IOHIDSystem/IOHIDDescriptorParser/HIDParseDescriptor.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             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.
        !            11:  * 
        !            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
        !            18:  * under the License.
        !            19:  * 
        !            20:  * @APPLE_LICENSE_HEADER_END@
        !            21:  */
        !            22: /*
        !            23:        File:           HIDParseDescriptor.c
        !            24: 
        !            25:        Contains:       xxx put contents here xxx
        !            26: 
        !            27:        Version:        xxx put version here xxx
        !            28: 
        !            29:        Copyright:      � 1999 by Apple Computer, Inc., all rights reserved.
        !            30: 
        !            31:        File Ownership:
        !            32: 
        !            33:                DRI:                            xxx put dri here xxx
        !            34: 
        !            35:                Other Contact:          xxx put other contact here xxx
        !            36: 
        !            37:                Technology:                     xxx put technology here xxx
        !            38: 
        !            39:        Writers:
        !            40: 
        !            41:                (BWS)   Brent Schorsch
        !            42: 
        !            43:        Change History (most recent first):
        !            44: 
        !            45:          <USB1>          3/5/99        BWS             first checked in
        !            46: */
        !            47: 
        !            48: #include "HIDLib.h"
        !            49: 
        !            50: //#include <stdio.h>
        !            51: /*
        !            52:  *------------------------------------------------------------------------------
        !            53:  *
        !            54:  * HIDParseDescriptor - Fill in the PreparsedData structures
        !            55:  *
        !            56:  *      Input:
        !            57:  *                       ptDescriptor                  - Descriptor Pointer Structure
        !            58:  *                       ptPreparsedData               - The PreParsedData Structure
        !            59:  *      Output:
        !            60:  *                       ptPreparsedData               - The PreParsedData Structure
        !            61:  *      Returns:
        !            62:  *                       kHIDSuccess              - Success
        !            63:  *                       kHIDNullPointerErr      - Argument, Pointer was Null
        !            64:  *
        !            65:  *     NOTE: HIDCountDescriptorItems MUST have been called to set up the
        !            66:  *               array pointers in the HIDPreparsedData structure!
        !            67:  *
        !            68:  *------------------------------------------------------------------------------
        !            69: */
        !            70: OSStatus HIDParseDescriptor(HIDReportDescriptor *ptDescriptor, HIDPreparsedDataPtr ptPreparsedData)
        !            71: {
        !            72:        OSStatus iStatus;
        !            73:        HIDItem *ptItem;
        !            74:        HIDCollection *ptCollection;
        !            75:        HIDReportSizes *ptReport;
        !            76: /*
        !            77:  *     Disallow NULL Pointers
        !            78: */
        !            79:        if ((ptDescriptor == NULL) || (ptPreparsedData == NULL))
        !            80:                return kHIDNullPointerErr;
        !            81: /*
        !            82:  *     Initialize Counters
        !            83: */
        !            84:        ptPreparsedData->collectionCount = 1;
        !            85:        ptPreparsedData->reportItemCount = 0;
        !            86:        ptPreparsedData->reportCount = 1;
        !            87:        ptPreparsedData->usageItemCount = 0;
        !            88:        ptPreparsedData->stringItemCount = 0;
        !            89:        ptPreparsedData->desigItemCount = 0;
        !            90: /*
        !            91:  *     Initialize the Descriptor Data
        !            92: */
        !            93:        ptDescriptor->index = 0;
        !            94:        ptDescriptor->collectionNesting = 0;
        !            95:        ptDescriptor->globalsNesting = 0;
        !            96:        ptDescriptor->firstUsageItem = 0;
        !            97:        ptDescriptor->firstStringItem = 0;
        !            98:        ptDescriptor->firstDesigItem = 0;
        !            99:        ptDescriptor->parent = 0;
        !           100:        ptDescriptor->sibling = 0;
        !           101:        ptDescriptor->globals.usagePage = 0;
        !           102:        ptDescriptor->globals.logicalMinimum = 0;
        !           103:        ptDescriptor->globals.logicalMaximum = 0;
        !           104:        ptDescriptor->globals.physicalMinimum = 0;
        !           105:        ptDescriptor->globals.physicalMaximum = 0;
        !           106:        ptDescriptor->globals.unitExponent = 0;
        !           107:        ptDescriptor->globals.units = 0;
        !           108:        ptDescriptor->globals.reportSize = 0;
        !           109:        ptDescriptor->globals.reportID = 0;
        !           110:        ptDescriptor->globals.reportCount = 0;
        !           111:        ptDescriptor->globals.reportIndex = 0;
        !           112:        ptDescriptor->haveUsageMin = false;
        !           113:        ptDescriptor->haveUsageMax = false;
        !           114:        ptDescriptor->haveStringMin = false;
        !           115:        ptDescriptor->haveStringMax = false;
        !           116:        ptDescriptor->haveDesigMin = false;
        !           117:        ptDescriptor->haveDesigMax = false;
        !           118:        ptItem = &ptDescriptor->item;
        !           119: /*
        !           120:  *     Initialize the virtual collection
        !           121: */
        !           122:        ptCollection = ptPreparsedData->collections;
        !           123:        ptCollection->data = 0;
        !           124:        ptCollection->usagePage = 0;
        !           125:        ptCollection->firstUsageItem = 0;
        !           126:        ptCollection->usageItemCount = 0;
        !           127:        ptCollection->firstReportItem = 0;
        !           128:        ptCollection->reportItemCount = 0;
        !           129:        ptCollection->parent = 0;
        !           130:        ptCollection->children = 0;
        !           131:        ptCollection->firstChild = 0;
        !           132:        ptCollection->nextSibling = 0;
        !           133: /*
        !           134:  *     Initialize the default report
        !           135: */
        !           136:        ptReport = ptPreparsedData->reports;
        !           137:        ptReport->reportID = 0;
        !           138:        ptReport->inputBitCount = 0;
        !           139:        ptReport->outputBitCount = 0;
        !           140:        ptReport->featureBitCount = 0;
        !           141: 
        !           142: /*
        !           143:  *     Parse the Descriptor
        !           144: */
        !           145:        while ((iStatus = HIDNextItem(ptDescriptor)) == kHIDSuccess)
        !           146:        {
        !           147:                switch (ptItem->itemType)
        !           148:                {
        !           149:                        case kHIDTypeMain:
        !           150:                                iStatus = HIDProcessMainItem(ptDescriptor,ptPreparsedData);
        !           151:                                break;
        !           152:                        case kHIDTypeGlobal:
        !           153:                                iStatus = HIDProcessGlobalItem(ptDescriptor,ptPreparsedData);
        !           154:                                break;
        !           155:                        case kHIDTypeLocal:
        !           156:                                iStatus = HIDProcessLocalItem(ptDescriptor,ptPreparsedData);
        !           157:                                break;
        !           158:                }
        !           159:                if (iStatus != kHIDSuccess)
        !           160:                        return iStatus;
        !           161:        }
        !           162:        if (iStatus == kHIDEndOfDescriptorErr)
        !           163:                iStatus = kHIDSuccess;
        !           164: /*
        !           165:  *     Update the virtual collection
        !           166: */
        !           167:        ptCollection = ptPreparsedData->collections;
        !           168:        ptCollection->reportItemCount = ptPreparsedData->reportItemCount;
        !           169: /*
        !           170:  *     Mark the PreparsedData initialized
        !           171: */
        !           172:        return iStatus;
        !           173: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.