|
|
1.1 root 1: /*
2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7: * Reserved. This file contains Original Code and/or Modifications of
8: * Original Code as defined in and that are subject to the Apple Public
9: * Source License Version 1.1 (the "License"). You may not use this file
10: * except in compliance with the License. Please obtain a copy of the
11: * License at http://www.apple.com/publicsource and read it before using
12: * this file.
13: *
14: * The Original Code and all software distributed under the License are
15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19: * License for the specific language governing rights and limitations
20: * under the License.
21: *
22: * @APPLE_LICENSE_HEADER_END@
23: */
24:
25: /*
26: File: ConfigParse.c
27:
28: Contains: xxx put contents here xxx
29:
30: Version: xxx put version here xxx
31:
32: Copyright: � 1998 by Apple Computer, Inc., all rights reserved.
33:
34: File Ownership:
35:
36: DRI: Craig Keithley
37:
38: Other Contact: xxx put other contact here xxx
39:
40: Technology: xxx put technology here xxx
41:
42: Writers:
43:
44: (BG) Bill Galcher
45: (CJK) Craig Keithley
46:
47: Change History (most recent first):
48:
49: <USB10> 6/29/98 CJK change total length so that it's properly byte swapped
50: <USB9> 6/16/98 CJK change FindHIDInterfaceByProtocol to FindHIDInterfaceByNumber
51: <USB8> 5/19/98 BG Fix some casting problems.
52: <USB7> 4/26/98 CJK add a routine to search for a HID/Keyboard interface
53: <USB6> 4/9/98 CJK replace include of USBHIDModules.h with include of USB.h
54: <5> 3/17/98 CJK change }; to just }. MetroWerks has a problem with }; ;-)
55: <4> 3/9/98 CJK Fix RADAR #2216609 (Duplicate sets of enums)
56: <3> 3/2/98 CJK remove inlcude of KBDHIDEmulation.h
57: <2> 2/27/98 CJK change add include of USBHIDModules.h
58: <1> 2/10/98 CJK Cloned from Mouse HID Module (modified for keyboards)
59: */
60:
61: //#include <Types.h>
62: //#include <Devices.h>
63: //#include <processes.h>
64: #include "../driverservices.h"
65: #include "../USB.h"
66:
67:
68: #include "KeyboardModule.h"
69:
70: OSErr kbd_FindHIDInterfaceByNumber(LogicalAddress pConfigDesc, UInt32 ReqInterface, USBInterfaceDescriptorPtr * hInterfaceDesc)
71: {
72: UInt32 totalLength;
73: void * pEndOfDescriptors;
74: USBInterfaceDescriptorPtr pMyIntDesc;
75: USBDescriptorHeaderPtr pCurrentDesc;
76: unsigned long anAddress, anOffset;
77:
78: totalLength = USBToHostWord(((USBConfigurationDescriptorPtr)pConfigDesc)->totalLength);
79: pEndOfDescriptors = (Ptr)pConfigDesc + totalLength; // get the total length and add it to the start of the config space
80: pCurrentDesc = (USBDescriptorHeaderPtr)pConfigDesc; // point the currentdesc to the start of the config space
81:
82: while (pCurrentDesc < pEndOfDescriptors) // as long as we haven't exhausted all the descriptors
83: {
84: if (pCurrentDesc->descriptorType == kUSBInterfaceDesc) // look at the current descriptor
85: {
86: pMyIntDesc = (USBInterfaceDescriptorPtr)pCurrentDesc; // if it's an interface descriptor
87: if ((pMyIntDesc->interfaceClass == kUSBHIDInterfaceClass) &&
88: (pMyIntDesc->interfaceNumber == ReqInterface)) // and if it's the interface we want...
89: {
90: *hInterfaceDesc = pMyIntDesc; // if it is, then return with hInterfaceDesc set to the
91: return noErr; // current descriptor pointer
92: }
93: }
94: // (Ptr)pCurrentDesc += pCurrentDesc->length; // Nope, that either wasn't an interface descriptor
95: anAddress = (unsigned long) pCurrentDesc; // Nope, that either wasn't an interface descriptor
96: anOffset = (unsigned long) pCurrentDesc->length;
97: anAddress += anOffset;
98: pCurrentDesc = (USBDescriptorHeaderPtr) anAddress;
99: if (pCurrentDesc->length == 0)
100: break;
101: } // or it was, but not the droid we're looking for.
102: *hInterfaceDesc = NULL;
103: return kUSBInternalErr;
104: }
105:
106:
107:
108:
109:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.