home *** CD-ROM | disk | FTP | other *** search
- /*
- File: USBTabletModuleHeader.c
-
- Contains: USBTabletModule 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 "USBTabletModule.h"
- #include "USBTabletModuleVersion.h"
-
- extern usbTabletPBStruct myTabletPB;
-
- //------------------------------------------------------
- //
- // 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
- 0x056a, // 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
- "\pUSBHIDTabletModule", // Driver name for Name Registry
- kUSBHIDInterfaceClass, // Device Class (from USBDeviceDefines.h)
- kUSBBootInterfaceSubClass, // Device Subclass
- kTabletHexMajorVers,
- kTabletHexMinorVers,
- kTabletCurrentRelease,
- kTabletReleaseStage, // version of driver
-
- // Driver Loading Info
- kUSBProtocolMustMatch+kUSBDoNotMatchInterface+kUSBDoNotMatchGenericDevice // Flags (currently undefined)
- };
-
- USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
- {
- kClassDriverPluginVersion, // Version of this structure
- TabletDriverValidateHW, // Hardware Validation Procedure
- TabletDeviceInitialize, // Initialization Procedure
- TabletInterfaceInitialize, // Interface Initialization Procedure
- TabletDriverFinalize, // Finalization Procedure
- TabletDriverNotifyProc, // Driver Notification Procedure
- };
-
-
- // Hardware Validation
- // Called upon load by Expert
- OSStatus TabletDriverValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc)
- {
- #pragma unused (device)
- #pragma unused (desc)
-
- return (OSStatus)kUSBNoErr;
- }
-
-
- // Initialization function
- // Called upon load by Expert
- OSStatus TabletDeviceInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable)
- {
- #pragma unused (busPowerAvailable)
-
- //DebugStr("\pIn Tablet Driver");
- // until we get going, it's okay to accept a call to finalize
- DeviceInitialize(device, pDesc, busPowerAvailable);
- return (OSStatus)kUSBNoErr;
- }
-
-
- // Interface Initialization Initialization function
- // Called upon load by Expert
- OSStatus TabletInterfaceInitialize (UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device)
- {
- #pragma unused (interfacenum)
- #pragma unused (pInterface)
- #pragma unused (pDesc)
- #pragma unused (device)
-
- return (OSStatus)noErr;
- }
-
- // Termination function
- // Called by Expert when driver is being shut down
- OSStatus TabletDriverFinalize(USBDeviceRef theDeviceRef, USBDeviceDescriptorPtr pDesc)
- {
- #pragma unused (pDesc)
- OSStatus myErr;
- //USBHIDData theTabletData;
-
- USBExpertStatus(theDeviceRef, "\pUSBHIDTabletModule: Finalize", theDeviceRef);
-
- /*
- if (myTabletPB.pSHIMInterruptRoutine)
- {
- USBExpertStatus(theDeviceRef, "\pUSBHIDTabletModule: Release Tablet buttons", theDeviceRef);
- theTabletData.Tablet.buttons = 0;
- theTabletData.Tablet.XDelta = 1;
- theTabletData.Tablet.YDelta = 1;
- (*myTabletPB.pSHIMInterruptRoutine)(myTabletPB.interruptRefcon, (void *)&theTabletData);
- }
- */
-
- if (myTabletPB.pCursorDeviceInfo != 0)
- {
- USBExpertStatus(theDeviceRef, "\pUSBHIDTabletModule: Remove CDM device", theDeviceRef);
- CursorDeviceDisposeDevice(myTabletPB.pCursorDeviceInfo);
- myTabletPB.pCursorDeviceInfo = 0;
- }
-
- if (myTabletPB.pipeRef)
- {
- USBExpertStatus(theDeviceRef, "\pUSBHIDTabletModule: Aborting interrupt pipe", theDeviceRef);
- USBAbortPipeByReference(myTabletPB.pipeRef);
- }
-
- myTabletPB.pb.usbReference = theDeviceRef;
- myTabletPB.pb.pbVersion = kUSBCurrentPBVersion;
- myTabletPB.pb.usbFlags = 0;
- myTabletPB.pb.usbRefcon = 0;
- myTabletPB.pb.usbCompletion = (USBCompletion)-1;
-
- myErr = USBDeallocMem(&myTabletPB.pb);
-
- return (OSStatus)noErr;
- }
-
- OSStatus TabletDriverNotifyProc(UInt32 notification, void *pointer)
- {
- #pragma unused (pointer)
- #pragma unused (notification)
- return(kUSBNoErr);
- }
-
- void DeviceInitialize(USBDeviceRef device, USBDeviceDescriptorPtr pDeviceDescriptor, UInt32 busPowerAvailable)
- {
- #pragma unused (pDeviceDescriptor)
- static Boolean beenThereDoneThat = false;
-
- DebugStr("\pIn Tablet Driver");
- if(beenThereDoneThat)
- {
- USBExpertFatalError(device, kUSBInternalErr, "\pTablet driver is not reentrant!", 0);
- return;
- }
- beenThereDoneThat = true;
-
- InitParamBlock(device, &myTabletPB.pb);
-
- myTabletPB.deviceRef = device;
- myTabletPB.pSHIMInterruptRoutine = nil;
- myTabletPB.pSavedInterruptRoutine = nil;
-
- myTabletPB.busPowerAvailable = busPowerAvailable;
- myTabletPB.transDepth = 0;
- myTabletPB.retryCount = kTabletRetryCount;
-
- myTabletPB.deviceRef = device;
- myTabletPB.interfaceRef = nil;
- myTabletPB.pipeRef = nil;
-
- myTabletPB.pb.usbRefcon = kFindInterface;
- myTabletPB.pb.usbReference = device;
- myTabletPB.pb.pbLength = sizeof(usbTabletPBStruct);
- myTabletPB.unitsPerInch = (Fixed)(400<<16);
- myTabletPB.pCursorDeviceInfo = 0;
- API_ControlDevice(kHIDEnableDemoMode,0);
-
- InitParamBlock(device, &myTabletPB.pb);
- InitiateTransactionProc(&myTabletPB.pb);
- }
-
-