home *** CD-ROM | disk | FTP | other *** search
- /*
- File: MouseModuleHeader.c
-
- Contains: Mouse Module Header file
-
- Version: xxx put version here xxx
-
- Copyright: © 1997-1998 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #include <Types.h>
- #include <Devices.h>
- #include <DriverServices.h>
- #include <USB.h>
-
-
- #include "MouseModule.h"
- #include "MouseModuleVersion.h"
-
- static OSStatus MouseModuleInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
- static OSStatus MouseModuleFinalize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc);
- static OSStatus MouseInterfaceInitialize (UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device);
-
- extern usbMousePBStruct myMousePB;
-
- //------------------------------------------------------
- //
- // This is the driver description structure that the expert looks for first.
- // If it's here, the information within is used to match the driver
- // to the device whose descriptor was passed to the expert.
- // Information in this block is also used by the expert when an
- // entry is created in the Name Registry.
- //
- //------------------------------------------------------
- USBDriverDescription TheUSBDriverDescription =
- {
- // Signature info
- kTheUSBDriverDescriptionSignature,
- kInitialUSBDriverDescriptor,
-
- // Device Info
- 0, // vendor = not device specific
- 0, // product = not device specific
- 0, // version of product = not device specific
- kUSBMouseInterfaceProtocol, // protocol = not device specific
-
- // Interface Info (* I don't think this would always be required...*)
- 0, // Configuration Value
- 0, // Interface Number
- kUSBHIDInterfaceClass, // Interface Class
- kUSBBootInterfaceSubClass, // Interface SubClass
- kUSBMouseInterfaceProtocol, // Interface Protocol
-
-
- // Driver Info
- "\pUSBHIDMouseModule", // Driver name for Name Registry
- kUSBHIDInterfaceClass, // Device Class (from USBDeviceDefines.h)
- kUSBBootInterfaceSubClass, // Device Subclass
- kMouseHexMajorVers,
- kMouseHexMinorVers,
- kMouseCurrentRelease,
- kMouseReleaseStage, // version of driver
-
- // Driver Loading Info
- kUSBProtocolMustMatch // Flags (currently undefined)
- };
-
- USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
- {
- kClassDriverPluginVersion, // Version of this structure
- 0, // Hardware Validation Procedure
- MouseModuleInitialize, // Initialization Procedure
- MouseInterfaceInitialize, // Interface Initialization Procedure
- MouseModuleFinalize, // Finalization Procedure
- 0, // Driver Notification Procedure
- };
-
-
- // Initialization function
- // Called upon load by Expert
- static OSStatus MouseModuleInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable)
- {
- #pragma unused (busPowerAvailable)
- #pragma unused (pDesc)
- USBExpertStatus(device, "\pUSBHIDMouseModule: Entered via KeyboardModuleInitialize", device);
- return (OSStatus)noErr;
- }
-
- // Interface Initialization Initialization function
- // Called upon load by Expert
- static OSStatus MouseInterfaceInitialize (UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device)
- {
- InterfaceEntry(interfacenum, pInterface, pDesc, device);
- return (OSStatus)noErr;
- }
-
-
-
- // Termination function
- // Called by Expert when driver is being shut down
- static OSStatus MouseModuleFinalize(USBDeviceRef theDeviceRef, USBDeviceDescriptorPtr pDesc)
- {
- #pragma unused (pDesc)
- OSStatus myErr;
- //USBHIDData theMouseData;
-
- USBExpertStatus(theDeviceRef, "\pUSBHIDMouseModule: Finalize", theDeviceRef);
-
- /*
- if (myMousePB.pSHIMInterruptRoutine)
- {
- USBExpertStatus(theDeviceRef, "\pUSBHIDMouseModule: Release mouse buttons", theDeviceRef);
- theMouseData.mouse.buttons = 0;
- theMouseData.mouse.XDelta = 1;
- theMouseData.mouse.YDelta = 1;
- (*myMousePB.pSHIMInterruptRoutine)(myMousePB.interruptRefcon, (void *)&theMouseData);
- }
- */
-
- if (myMousePB.pCursorDeviceInfo != 0)
- {
- USBExpertStatus(theDeviceRef, "\pUSBHIDMouseModule: Remove CDM device", theDeviceRef);
- CursorDeviceDisposeDevice(myMousePB.pCursorDeviceInfo);
- myMousePB.pCursorDeviceInfo = 0;
- }
-
- if (myMousePB.pFullConfigDescriptor != nil)
- {
- if (myMousePB.pipeRef)
- {
- USBExpertStatus(theDeviceRef, "\pUSBHIDMouseModule: Aborting interrupt pipe", theDeviceRef);
- USBAbortPipeByReference(myMousePB.pipeRef);
- }
- myMousePB.pb.usbReference = theDeviceRef;
- myMousePB.pb.pbVersion = kUSBCurrentPBVersion;
- myMousePB.pb.usbFlags = 0;
- myMousePB.pb.usbRefcon = 0;
- myMousePB.pb.usbBuffer = myMousePB.pFullConfigDescriptor;
- myMousePB.pb.usbCompletion = (USBCompletion)-1;
-
- myErr = USBDeallocMem(&myMousePB.pb);
- }
-
- return (OSStatus)noErr;
- }
-
-