home *** CD-ROM | disk | FTP | other *** search
- /*
- File: KeyboardModuleHeader.c
-
- Contains: Keyboard 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 "KeyboardModule.h"
- #include "KeyboardModuleVersion.h"
-
- static OSStatus KeyboardModuleInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
- static OSStatus KeyboardModuleFinalize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc);
- static OSStatus KeyboardInterfaceInitialize (UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device);
-
- extern usbKeyboardPBStruct myKeyboardPB;
-
- //------------------------------------------------------
- //
- // 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
- kUSBKeyboardInterfaceProtocol, // 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
- kUSBKeyboardInterfaceProtocol, // Interface Protocol
-
-
- // Driver Info
- "\pUSBHIDKeyboardModule", // Driver name for Name Registry
- kUSBHIDInterfaceClass, // Device Class (from USBDeviceDefines.h)
- kUSBBootInterfaceSubClass, // Device Subclass
- kKBDHexMajorVers,
- kKBDHexMinorVers,
- kKBDCurrentRelease,
- kKBDReleaseStage, // version of driver
-
- // Driver Loading Info
- kUSBProtocolMustMatch // Flags
- };
-
- USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
- {
- kClassDriverPluginVersion, // Version of this structure
- 0, // Hardware Validation Procedure
- KeyboardModuleInitialize, // Initialization Procedure
- KeyboardInterfaceInitialize, // Interface Initialization Procedure
- KeyboardModuleFinalize, // Finalization Procedure
- 0, // Driver Notification Procedure
- };
-
-
-
- // Initialization function
- // Called upon load by Expert
- static OSStatus KeyboardModuleInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable)
- {
- #pragma unused (busPowerAvailable)
- #pragma unused (pDesc)
- USBExpertStatus(device, "\pUSBHIDKeyboardModule: Entered via KeyboardModuleInitialize", device);
- return (OSStatus)noErr;
- }
-
- // Interface Initialization Initialization function
- // Called upon load by Expert
- static OSStatus KeyboardInterfaceInitialize (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 KeyboardModuleFinalize(USBDeviceRef theDeviceRef, USBDeviceDescriptorPtr pDesc)
- {
- #pragma unused (pDesc)
-
- OSStatus myErr;
-
- USBExpertStatus(theDeviceRef, "\pUSBHIDKeyboardModule: Finalize", theDeviceRef);
- if (myKeyboardPB.pFullConfigDescriptor != nil)
- {
- if (myKeyboardPB.pipeRef)
- {
- USBExpertStatus(theDeviceRef, "\pUSBHIDKeyboardModule: Aborting interrupt pipe", theDeviceRef);
- USBAbortPipeByReference(myKeyboardPB.pipeRef);
- }
-
- myKeyboardPB.pb.usbReference = theDeviceRef;
- myKeyboardPB.pb.pbVersion = kUSBCurrentPBVersion;
- myKeyboardPB.pb.usbFlags = 0;
- myKeyboardPB.pb.usbRefcon = 0;
- myKeyboardPB.pb.usbBuffer = myKeyboardPB.pFullConfigDescriptor;
- myKeyboardPB.pb.usbCompletion = (USBCompletion)-1;
-
- myErr = USBDeallocMem(&myKeyboardPB.pb);
- };
- return (OSStatus)noErr;
- }
-
-