ADC Home > Reference Library > Technical Q&As > Legacy Documents > Hardware & Drivers >
Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.
Current information on this Reference Library topic can be found here:
|
Q: Under MacOS USB 1.4.x, the Apple USB Mouse and Keyboard drivers work better with MacsBug. How can I implement similar functionality in my vendor-specific Mouse and Keyboard driver? A: MacOS USB 1.4.x implements modifications within the USB Services Library so that when MacsBug is active, the USB Interrupt Service Routine (ISR) limits the processing of data to those devices whose drivers support MacsBug. In prior versions of MacOS USB, the USB ISR continued to process incoming data requests, such that all USB devices would still function within the MacsBug context. To support MacsBug, the following conditions must be true:
The To support MacsBug, the USB ISR must be aware that
MacsBug has been entered. This is handled by the Setting the
|
// initialize the parameter block InitParamBlock(pKeyboardPB->pipeRef, &pKeyboardPB->pb); // specify where the response buffer pKeyboardPB->pb.usbBuffer = (Ptr)response; // 8 bytes of data requested for a keyboard read pKeyboardPB->pb.usbReqCount = 0x08; // set the interfaceNumber of the keyboard pKeyboardPB->pb.usb.cntl.WIndex = interfaceNumber; // set the completion proc pKeyboardPB->pb.usbCompletion = (USBCompletion)KeyboardCompletionProc; // user sets the usbRefcon field which remains unchanged // across the call pKeyboardPB->pb.usbRefcon |= kCompletionPending; // Get USB Version to see if we support the // debug aware flag ( version > 1.4 ) if ( pKeyboardPB->usbVersion >= kUSBVersion14 ) { pKeyboardPB->pb.usbFlags |= kUSBDebugAwareFlag; } // post the USBIntRead call myErr = USBIntRead(&pKeyboardPB->pb); |
When the mouse or keyboard device is attached, the
ADBShim
is notified and it searches for an exported
TheHIDModuleDispatchTable
symbol
associated with the device driver. If the symbol is found,
then the USBHIDInstallInterruptProcPtr
field is checked to make sure that it is not nil. The
ADBShim
passes the driver its ISR to be used to process all
incoming data. If there is no TheHIDModuleDispatchTable
or if the USBHIDInstallInterruptProcPtr
is nil, the ADBShim
does not support the device. An example
of implementing the TheHIDModuleDispatchTable
,
is demonstrated in the Keyboard and Mouse module driver
samples which are part of the MacOS
USB DDK 1.4.1.
A vendor specific keyboard or mouse driver may implement
support for the kUSBDebugAwareFlag
bit, but not export the TheHIDModuleDispatchTable
,
and still work with MacsBug. For this to happen, a keyboard
that is supported by the ADBShim
must be attached. For this
reason, developers find that their keyboards and mice that
are supported by vendor-specific drivers work within
MacsBug with an Apple USB keyboard attached, but not without
it.
A vendor-specific keyboard or mouse driver can implement
support for the TheHIDModuleDispatchTable
as well as the USBHIDInstallInterruptProcPtr
and still selectively support additional functionality which
their product provides. When processing each event,
determine which events should be passed to the ADBShim
. If
the event is to be handled by your own code, be aware that
the driver may be operating within the MacsBug context.
Consider using a Deferred
Task to execute your code, in this case.
|