|
|
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: MouseModuleHeader.c
27:
28: Contains: Mouse Module Header file
29:
30: Version: xxx put version here xxx
31:
32: Copyright: � 1997-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: (TC) Tom Clark
45: (CJK) Craig Keithley
46:
47: Change History (most recent first):
48:
49: <USB15> 6/23/98 CJK comment out the 'theMouseData' variable; it's not used (yet).
50: <USB14> 6/22/98 CJK make certain that the cursor device is disposed in the finalize
51: routine
52: <USB13> 6/18/98 CJK add pipe abort to finalize routine
53: <USB12> 6/11/98 CJK change display of status to display of interfaceRef (in finalize
54: routine)
55: <USB11> 6/11/98 CJK remove call to driverentry in MouseModuleInitialize. Add some
56: USBExpertStatus messages to the initialize and finalize
57: routines.
58: <USB10> 6/8/98 CJK add dealloc of full configuration to finalize routine
59: <USB9> 5/20/98 CJK change driver name from USBMouseModule to USBHIDMouseModule
60: <USB8> 4/27/98 TC Implement a USBDriverLoadingOption to enforce protocol matching.
61: <USB7> 4/9/98 CJK remove include of USBClassDrivers.h, USBHIDModules.h, and
62: USBDeviceDefines.h
63: <6> 3/17/98 CJK Add parens around pragma unused variables.
64: <5> 3/5/98 CJK use version defines from MouseModuleVersion.h
65: <4> 3/2/98 CJK Add include of USBHIDModules.h. Remove include of HIDEmulation.h
66: <3> 2/9/98 CJK remove deallocate of full configuration memory (the full
67: configuration data is not needed for HID devices)
68: <2> 2/9/98 CJK Add interface initialization routine.
69: <1> 2/9/97 CJK First time checkin
70: */
71:
72: //#include <Types.h>
73: //#include <Devices.h>
74: #include "../driverservices.h"
75: #include "../USB.h"
76:
77:
78: #include "MouseModule.h"
79: #include "MouseModuleVersion.h"
80:
81: static OSStatus MouseModuleInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
82: static OSStatus MouseModuleFinalize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc);
83: static OSStatus MouseInterfaceInitialize (UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device);
84:
85: extern usbMousePBStruct myMousePB;
86:
87: //------------------------------------------------------
88: //
89: // This is the driver description structure that the expert looks for first.
90: // If it's here, the information within is used to match the driver
91: // to the device whose descriptor was passed to the expert.
92: // Information in this block is also used by the expert when an
93: // entry is created in the Name Registry.
94: //
95: //------------------------------------------------------
96: /* naga define in kbd
97: USBDriverDescription TheUSBDriverDescription =
98: {
99: // Signature info
100: kTheUSBDriverDescriptionSignature,
101: kInitialUSBDriverDescriptor,
102:
103: // Device Info
104: 0, // vendor = not device specific
105: 0, // product = not device specific
106: 0, // version of product = not device specific
107: kUSBMouseInterfaceProtocol, // protocol = not device specific
108:
109: // Interface Info (* I don't think this would always be required...*)
110: 0, // Configuration Value
111: 0, // Interface Number
112: kUSBHIDInterfaceClass, // Interface Class
113: kUSBBootInterfaceSubClass, // Interface SubClass
114: kUSBMouseInterfaceProtocol, // Interface Protocol
115:
116:
117: // Driver Info
118: "USBHIDMouseModule", // Driver name for Name Registry
119: kUSBHIDInterfaceClass, // Device Class (from USBDeviceDefines.h)
120: kUSBBootInterfaceSubClass, // Device Subclass
121: kMouseHexMajorVers,
122: kMouseHexMinorVers,
123: kMouseCurrentRelease,
124: kMouseReleaseStage, // version of driver
125:
126: // Driver Loading Info
127: kUSBProtocolMustMatch // Flags (currently undefined)
128: };
129: */
130: /* naga defined in CompositeDriverDescription.c
131: USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
132: {
133: kClassDriverPluginVersion, // Version of this structure
134: 0, // Hardware Validation Procedure
135: MouseModuleInitialize, // Initialization Procedure
136: MouseInterfaceInitialize, // Interface Initialization Procedure
137: MouseModuleFinalize, // Finalization Procedure
138: 0, // Driver Notification Procedure
139: };
140:
141: */
142: // Initialization function
143: // Called upon load by Expert
144: static OSStatus MouseModuleInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable)
145: {
146: #pragma unused (busPowerAvailable)
147: #pragma unused (pDesc)
148: USBExpertStatus(device, "USBHIDMouseModule: Entered via KeyboardModuleInitialize", device);
149: return (OSStatus)noErr;
150: }
151:
152: // Interface Initialization Initialization function
153: // Called upon load by Expert
154: static OSStatus MouseInterfaceInitialize (UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device)
155: {
156: InterfaceEntry(interfacenum, pInterface, pDesc, device);
157: return (OSStatus)noErr;
158: }
159:
160:
161:
162: // Termination function
163: // Called by Expert when driver is being shut down
164: static OSStatus MouseModuleFinalize(USBDeviceRef theDeviceRef, USBDeviceDescriptorPtr pDesc)
165: {
166: #pragma unused (pDesc)
167: OSStatus myErr;
168: //USBHIDData theMouseData;
169:
170: USBExpertStatus(theDeviceRef, "USBHIDMouseModule: Finalize", theDeviceRef);
171:
172: /*
173: if (myMousePB.pSHIMInterruptRoutine)
174: {
175: USBExpertStatus(theDeviceRef, "USBHIDMouseModule: Release mouse buttons", theDeviceRef);
176: theMouseData.mouse.buttons = 0;
177: theMouseData.mouse.XDelta = 1;
178: theMouseData.mouse.YDelta = 1;
179: (*myMousePB.pSHIMInterruptRoutine)(myMousePB.interruptRefcon, (void *)&theMouseData);
180: }
181: */
182:
183: if (myMousePB.pCursorDeviceInfo != 0)
184: {
185: USBExpertStatus(theDeviceRef, "USBHIDMouseModule: Remove CDM device", theDeviceRef);
186: CursorDeviceDisposeDevice(myMousePB.pCursorDeviceInfo);
187: myMousePB.pCursorDeviceInfo = 0;
188: }
189:
190: if (myMousePB.pFullConfigDescriptor != nil)
191: {
192: if (myMousePB.pipeRef)
193: {
194: USBExpertStatus(theDeviceRef, "USBHIDMouseModule: Aborting interrupt pipe", theDeviceRef);
195: USBAbortPipeByReference(myMousePB.pipeRef);
196: }
197: myMousePB.pb.usbReference = theDeviceRef;
198: myMousePB.pb.pbVersion = kUSBCurrentPBVersion;
199: myMousePB.pb.usbFlags = 0;
200: myMousePB.pb.usbRefcon = 0;
201: myMousePB.pb.usbBuffer = myMousePB.pFullConfigDescriptor;
202: myMousePB.pb.usbCompletion = (USBCompletion)-1;
203:
204: myErr = USBDeallocMem(&myMousePB.pb);
205: }
206:
207: return (OSStatus)noErr;
208: }
209:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.