|
|
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: MouseModule.c ! 27: ! 28: Contains: HID Module for USB Mouse ! 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: USB on Mac ! 41: ! 42: Writers: ! 43: ! 44: (bwm) Bruce Merritt ! 45: (BT) Barry Twycross ! 46: (DF) David Ferguson ! 47: (CJK) Craig Keithley ! 48: ! 49: Change History (most recent first): ! 50: ! 51: <USB53> 10/28/98 CJK [2282187] changed to use interface number from the interface ! 52: descriptor supplied by the composite driver. See the keyboard ! 53: driver (there's a similar change in there as well). ! 54: <USB52> 10/21/98 DF Change LMGetMBState to it's new name LMGetMouseButtonState, now ! 55: we can include LowMem.h instead of LowMemPriv.h ! 56: <USB51> 10/21/98 bwm [2229080] NewWorld: whenever a mouse driver fails in an ! 57: interrupt pipe read, force the mouse button up to prevent a ! 58: possible hung system: we do this in case someone was holding the ! 59: mouse button down while the mouse was unplugged, leaving MacOS ! 60: is a somewhat constipated state. ! 61: <USB50> 8/25/98 BT Isoc name changes ! 62: <USB49> 6/22/98 CJK move cursordevice setup to InterfaceEntry, which is guarenteed ! 63: to be at task time ! 64: <USB48> 6/22/98 CJK rename FindNextEndpointDescriptor to ! 65: FindNextEndpointDescriptorImmediate ! 66: <USB47> 6/18/98 CJK update to use new style of error handling implemented in ! 67: keyboard module. ! 68: <USB46> 6/16/98 CJK change FindHIDInterfaceByProtocol to FindHIDInterfaceByNumber ! 69: <USB45> 6/15/98 CJK change transaction depth error messages so that they output the ! 70: refcon (current state machine stage) ! 71: <USB44> 6/11/98 CJK Remove driverentry routine (not needed or used). ! 72: <USB43> 6/8/98 CJK eliminate PBVERSION1 define ! 73: <USB42> 6/5/98 CJK remove ExpertStatus; too many clutter up expert log ! 74: <USB41> 5/26/98 DF Look for the incorrect vendorID (0x1452), when checking for ! 75: version 0.04 Rudi ! 76: <USB40> 5/26/98 CJK add prototype for InitParamBlock ! 77: <USB39> 5/22/98 CJK add check for the 0.04 version of the Rudi mouse. Do a SetIdle ! 78: of 50ms if found. ! 79: <USB38> 5/20/98 BT Set version 1 PB compatability ! 80: <USB37> 5/20/98 CJK change driver name from USBMouseModule to USBHIDMouseModule ! 81: <USB36> 5/15/98 CJK Things seem to have stabilized; no longer need to try various ! 82: different int read report sizes until we find the one that ! 83: works. Just use the maxpacketsize value. ! 84: <USB35> 5/13/98 CJK move DPI setting to interface entry code ! 85: <USB34> 5/11/98 CJK setidle to 0 ! 86: <USB33> 5/4/98 CJK implement adaptive reqCount. This way, when a mouse gives back ! 87: an OverRun error, the mouse driver automatically increases the ! 88: reqCount value (never exceeding the maxPacketSize). ! 89: <USB32> 5/4/98 CJK recover from repeated stalls when doing a setidle. added detect ! 90: for MS mouse, at which we ask for a 4 byte report (rather than a ! 91: 3 byte report) ! 92: <USB31> 4/29/98 CJK add break where needed ! 93: <USB30> 4/26/98 CJK Add back in SetIdle. This seems to solve the stall problem and ! 94: double click problem. ! 95: <USB29> 4/26/98 CJK change so that pipe stall clear is only called if happens as a ! 96: result of a read or open pipe. Also cleaned up transaction ! 97: depth error messages so that the user can tell if the problem ! 98: occurred in the completion or initiation routines. ! 99: <USB28> 4/24/98 CJK add call to clear pipestall by reference ! 100: <USB27> 4/24/98 CJK add call to turn on demo mode for shim-less environments. ! 101: <USB26> 4/23/98 CJK add status message to show who's driver this is... ! 102: <USB25> 4/23/98 CJK Reworked mouse module dramatically. It now 1) gets the full ! 103: configuration and looks for the mouse HID interface, 2) uses ! 104: this mouse HID interface to find the interrupt endpoint, 3) uses ! 105: the interrupt endpoint descriptor to open the the interrupt ! 106: pipe. Of note is that all the stuff to support the non-spec'd ! 107: mice has been removed. It will be added back in, either in a ! 108: different mouse module, or within this mouse module, as further ! 109: testing demands. ! 110: <USB24> 4/14/98 CJK Change to use driverservices strcpy ! 111: <USB23> 4/9/98 CJK change driver services to be a externally supplied header file ! 112: (using < & >) rather than quotes. ! 113: <USB22> 4/9/98 DF Massaged to work with MasterInterfaces ! 114: <21> 4/8/98 CJK correct mouse status & fatal error messages (should read ! 115: "mouse", not Mouse) ! 116: <20> 4/8/98 CJK add initialization of saved interrupt routine ptr. ! 117: <19> 3/31/98 CJK change error messages ! 118: <18> 3/26/98 CJK fix delay callback depth problem. Clean up USBExpertFatal ! 119: messages. ! 120: <17> 3/25/98 CJK Add support for interrupt transactions ! 121: <16> 3/17/98 CJK Replace "};" with just "}". Add parens to pragma unused ! 122: variables. ! 123: <15> 3/5/98 CJK I feel like a darn ping pong ball, changing the X-Delta & ! 124: Y-Delta checks back and forth. But now that the mouse 'skip' ! 125: problem has been resolved, let's see if I can't make both the ! 126: BTC PS/2 mouse AND the Logitech mouse work properly. See Radar ! 127: 2216777. ! 128: <14> 3/3/98 CJK change poll rate to 20ms ! 129: <13> 3/2/98 CJK change back to check for non-zero ! 130: <12> 3/2/98 CJK Add include of USBHIDModules.h. Remove include of HIDEmulation.h ! 131: <11> 2/19/98 CJK change polling rate back to 10ms. ! 132: <10> 2/19/98 CJK change back to notifying the MacOS when the deltas change from ! 133: report to report, not just when they're non-zero. ! 134: <9> 2/18/98 CJK Implement Ferg's suggestion that we notify the HID Emulation ! 135: routine if the X & Y deltas are non-zero. ! 136: <8> 2/17/98 CJK remove "" from expert fatal error calls. ! 137: <7> 2/11/98 CJK Change debugstr to expertfatal calls ! 138: <6> 2/11/98 CJK remove unneeded states ! 139: <5> 2/10/98 CJK change hid byte count from 8 to 3. No need to look at all eight ! 140: bytes as mouse reports only consist of 3 bytes. ! 141: <4> 2/10/98 CJK Remove keyboard related code ! 142: <3> 2/9/98 CJK change first state to setprotocol (when entering driver via ! 143: InterfaceEntry ! 144: <2> 2/9/98 CJK Add InterfaceEntry function ! 145: <1> 2/9/98 CJK First time check in. Cloned from CompoundDriver. ! 146: */ ! 147: ! 148: //#include <Types.h> ! 149: //#include <Devices.h> ! 150: //#include <processes.h> ! 151: #include "../driverservices.h" ! 152: #include "../USB.h" ! 153: //#include <LowMem.h> ! 154: ! 155: #include "MouseModule.h" ! 156: ! 157: usbMousePBStruct myMousePB; ! 158: static void InitParamBlock(USBDeviceRef theDeviceRef, USBPB * paramblock) ! 159: { ! 160: paramblock->usbReference = theDeviceRef; ! 161: paramblock->pbVersion = kUSBCurrentPBVersion; ! 162: paramblock->usb.cntl.WIndex = 0; ! 163: paramblock->usbBuffer = nil; ! 164: paramblock->usbStatus = noErr; ! 165: paramblock->usbReqCount = 0; ! 166: paramblock->usb.cntl.WValue = 0; ! 167: paramblock->usbFlags = 0; ! 168: } ! 169: ! 170: ! 171: static Boolean immediateError(OSStatus err) ! 172: { ! 173: return((err != kUSBPending) && (err != noErr) ); ! 174: } ! 175: ! 176: void MouseModuleInitiateTransaction(USBPB *pb) ! 177: { ! 178: register usbMousePBStruct *pMousePB; ! 179: OSStatus myErr; ! 180: ! 181: pMousePB = (usbMousePBStruct *)(pb); ! 182: pMousePB->transDepth++; ! 183: if (pMousePB->transDepth < 0) ! 184: { ! 185: USBExpertFatalError(pMousePB->deviceRef, kUSBInternalErr, "USBHIDMouseModule: transDepth < 0 (initiation)", pMousePB->pb.usbRefcon ); ! 186: } ! 187: ! 188: if (pMousePB->transDepth > 1) ! 189: { ! 190: USBExpertFatalError(pMousePB->deviceRef, kUSBInternalErr, "USBHIDMouseModule: transDepth > 1 (initiation)", pMousePB->pb.usbRefcon ); ! 191: } ! 192: ! 193: switch(pMousePB->pb.usbRefcon & ~kRetryTransaction) ! 194: { ! 195: case kGetFullConfiguration: ! 196: InitParamBlock(pMousePB->deviceRef, &pMousePB->pb); ! 197: ! 198: pMousePB->pb.usbRefcon |= kCompletionPending; ! 199: pMousePB->pb.usbCompletion = (USBCompletion)TransactionCompletionProc; ! 200: myErr = USBGetFullConfigurationDescriptor(pb); ! 201: if(immediateError(myErr)) ! 202: { ! 203: USBExpertFatalError(pMousePB->pb.usbReference, kUSBInternalErr, "USBHIDMouseModule: kGetFullConfiguration (ImmediateError)", myErr); ! 204: } ! 205: break; ! 206: ! 207: case kFindInterfaceAndSetProtocol: ! 208: myErr = FindHIDInterfaceByNumber(pMousePB->pFullConfigDescriptor, pMousePB->interfaceDescriptor.interfaceNumber, &pMousePB->pInterfaceDescriptor ); // find the HID interface ! 209: if ((pMousePB->pInterfaceDescriptor == NULL) || (myErr != noErr)) ! 210: { ! 211: USBExpertFatalError(pMousePB->deviceRef, kUSBInternalErr, "USBHIDMouseModule: Interface not found", myErr); ! 212: pMousePB->pb.usbRefcon = kReturnFromDriver; ! 213: } ! 214: ! 215: InitParamBlock(pMousePB->deviceRef, &pMousePB->pb); ! 216: ! 217: pMousePB->pb.usb.cntl.BMRequestType = USBMakeBMRequestType(kUSBOut, kUSBClass, kUSBInterface); ! 218: pMousePB->pb.usb.cntl.BRequest = kHIDRqSetProtocol; ! 219: pMousePB->pb.usb.cntl.WValue = kHIDBootProtocolValue; ! 220: pMousePB->pb.usb.cntl.WIndex = pMousePB->interfaceDescriptor.interfaceNumber; ! 221: pMousePB->pb.usbCompletion = (USBCompletion)TransactionCompletionProc; ! 222: ! 223: pMousePB->pb.usbRefcon |= kCompletionPending; ! 224: myErr = USBDeviceRequest(&pMousePB->pb); ! 225: if (immediateError(myErr)) ! 226: { ! 227: USBExpertFatalError(pMousePB->deviceRef, kUSBInternalErr, "USBHIDMouseModule: kSetProtocol (ImmediateError)", myErr); ! 228: } ! 229: break; ! 230: ! 231: case kSetIdleRequest: ! 232: InitParamBlock(pMousePB->deviceRef, &pMousePB->pb); ! 233: ! 234: pMousePB->pb.usb.cntl.BMRequestType = USBMakeBMRequestType(kUSBOut, kUSBClass, kUSBInterface); ! 235: ! 236: pMousePB->pb.usb.cntl.BRequest = kHIDRqSetIdle; ! 237: if ((myMousePB.deviceDescriptor.vendor == USB_CONSTANT16(0x1452)) && ! 238: (myMousePB.deviceDescriptor.product == USB_CONSTANT16(0x0301)) && ! 239: (pMousePB->deviceDescriptor.devRel == USB_CONSTANT16(0x0004))) ! 240: { ! 241: pMousePB->pb.usb.cntl.WValue = ((50/4)<<8); // force a read completion if idle for more than 50ms ! 242: } ! 243: else ! 244: { ! 245: pMousePB->pb.usb.cntl.WValue = 0; // Turn off SetIdle time (set it to 0ms) ! 246: } ! 247: pMousePB->pb.usb.cntl.WIndex = pMousePB->interfaceDescriptor.interfaceNumber; ! 248: pMousePB->pb.usbCompletion = (USBCompletion)TransactionCompletionProc; ! 249: ! 250: pMousePB->pb.usbRefcon |= kCompletionPending; ! 251: ! 252: myErr = USBDeviceRequest(&pMousePB->pb); ! 253: if(immediateError(myErr)) ! 254: { ! 255: USBExpertFatalError(pMousePB->deviceRef, kUSBInternalErr, "USBHIDMouseModule: kSetIdleRequest - immediate error", myErr); ! 256: } ! 257: break; ! 258: ! 259: case kFindAndOpenInterruptPipe: ! 260: pMousePB->pb.usbClassType = kUSBInterrupt; ! 261: pMousePB->pb.usbOther = 0; ! 262: pMousePB->pb.usb.cntl.BMRequestType = USBMakeBMRequestType(kUSBIn, kUSBClass, kUSBInterface); ! 263: pMousePB->pb.usbFlags = kUSBIn; ! 264: pMousePB->pb.usbBuffer = pMousePB->pInterfaceDescriptor; ! 265: pMousePB->pb.usbReqCount = (UInt8*)pMousePB->pInterfaceDescriptor - (UInt8*)pMousePB->pFullConfigDescriptor; ! 266: myErr = USBFindNextEndpointDescriptorImmediate( &pMousePB->pb ); ! 267: if((immediateError(myErr)) || (pMousePB->pb.usbBuffer == nil)) ! 268: { ! 269: USBExpertFatalError(pMousePB->deviceRef, kUSBInternalErr, "USBHIDMouseModule: Endpoint not found", myErr); ! 270: pMousePB->pb.usbRefcon = kReturnFromDriver; ! 271: } ! 272: else ! 273: { ! 274: pMousePB->pEndpointDescriptor = (USBEndPointDescriptorPtr) pMousePB->pb.usbBuffer; ! 275: ! 276: InitParamBlock(pMousePB->deviceRef, &pMousePB->pb); ! 277: ! 278: pMousePB->pb.usbFlags = kUSBIn; ! 279: pMousePB->pb.usb.cntl.WValue = USBToHostWord(pMousePB->pEndpointDescriptor->maxPacketSize); ! 280: pMousePB->pb.usbClassType = kUSBInterrupt; ! 281: pMousePB->pb.usbOther = (pMousePB->pEndpointDescriptor->endpointAddress & 0x0f); ! 282: pMousePB->pb.usbRefcon |= kCompletionPending; ! 283: pMousePB->pb.usbCompletion = (USBCompletion)TransactionCompletionProc; ! 284: ! 285: myErr = USBOpenPipe( &pMousePB->pb ); ! 286: if(immediateError(myErr)) ! 287: { ! 288: USBExpertFatalError(pMousePB->deviceRef, kUSBInternalErr, "USBHIDMouseModule: USBOpenPipe Failed (ImmediateError)", myErr); ! 289: } ! 290: } ! 291: break; ! 292: ! 293: case kReadInterruptPipe: ! 294: InitParamBlock(pMousePB->pipeRef, &pMousePB->pb); ! 295: ! 296: pMousePB->pb.usbBuffer = (Ptr)pMousePB->hidReport; ! 297: pMousePB->pb.usbReqCount = USBToHostWord(pMousePB->pEndpointDescriptor->maxPacketSize); ! 298: pMousePB->pb.usb.cntl.WIndex = pMousePB->interfaceDescriptor.interfaceNumber; ! 299: pMousePB->pb.usbCompletion = (USBCompletion)TransactionCompletionProc; ! 300: ! 301: pMousePB->pb.usbRefcon |= kCompletionPending; ! 302: ! 303: myErr = USBIntRead(&pMousePB->pb); ! 304: if(immediateError(myErr)) ! 305: { ! 306: USBExpertFatalError(pMousePB->deviceRef, kUSBInternalErr, "USBHIDMouseModule: Read Interrupt Pipe (ImmediateError)", myErr); ! 307: } ! 308: break; ! 309: ! 310: default: ! 311: USBExpertFatalError(pMousePB->deviceRef, kUSBInternalErr, "USBHIDMouseModule: Transaction initiated with bad refcon value", pMousePB->pb.usbRefcon); ! 312: pMousePB->pb.usbRefcon = kUndefined + kReturnFromDriver; ! 313: break; ! 314: } ! 315: ! 316: // At this point the control is returned to the system. If a USB transaction ! 317: // has been initiated, then it will call the Complete procs ! 318: // (below) to handle the results of the transaction. ! 319: } ! 320: ! 321: ! 322: void TransactionCompletionProc(USBPB *pb) ! 323: { ! 324: register usbMousePBStruct *pMousePB; ! 325: unsigned char * errstring; ! 326: USBPipeState pipeState; ! 327: kprintf("TransactionCompletionProc is called for Mouse read\n"); ! 328: pMousePB = (usbMousePBStruct *)(pb); ! 329: pMousePB->transDepth--; ! 330: if (pMousePB->transDepth < 0) ! 331: { ! 332: USBExpertFatalError(pMousePB->deviceRef, kUSBInternalErr, "USBHIDMouseModule: transDepth < 0 (completion)", pMousePB->pb.usbRefcon ); ! 333: } ! 334: ! 335: if (pMousePB->transDepth > 1) ! 336: { ! 337: USBExpertFatalError(pMousePB->deviceRef, kUSBInternalErr, "USBHIDMouseModule: transDepth > 1 (completion)", pMousePB->pb.usbRefcon ); ! 338: } ! 339: ! 340: if(pMousePB->pb.usbStatus != noErr) // was there an error? ! 341: { ! 342: switch(pMousePB->pb.usbRefcon & 0x0fff) // yes, so show where the error occurred ! 343: { ! 344: case kGetFullConfiguration: errstring = "USBHIDMouseModule: Error during GetFullConfiguration"; break; ! 345: case kFindInterfaceAndSetProtocol: errstring = "USBHIDMouseModule: Error during FindInterfaceAndSetProtocol"; break; ! 346: case kSetIdleRequest: errstring = "USBHIDMouseModule: Error during kSetIdleRequest"; break; ! 347: case kFindAndOpenInterruptPipe: errstring = "USBHIDMouseModule: Error during FindAndOpenInterruptPipe"; break; ! 348: case kReadInterruptPipe: ! 349: { ! 350: errstring = "USBHIDMouseModule: Error during ReadInterruptPipe"; ! 351: //naga LMSetMouseButtonState(0x80); // release any possibly held-down mouse button ! 352: break; ! 353: } ! 354: default: errstring = "USBHIDMouseModule: Error occurred, but state is unknown"; break; ! 355: }; ! 356: USBExpertFatalError(pMousePB->deviceRef, pMousePB->pb.usbStatus, errstring, (pMousePB->pb.usbRefcon & 0x0fff)); ! 357: ! 358: pMousePB->pb.usbRefcon &= ~(kCompletionPending + kReturnFromDriver); // set up to retry the transaction ! 359: pMousePB->pb.usbRefcon |= kRetryTransaction; ! 360: pMousePB->retryCount--; ! 361: ! 362: if ((pMousePB->retryCount == 1) && ((pMousePB->pb.usbRefcon&pMousePB->pb.usbRefcon & 0x0fff) == kSetIdleRequest)) ! 363: { ! 364: USBExpertStatus(pMousePB->deviceRef, "USBHIDMouseModule: Device doesn't accept SetIdle", pMousePB->deviceRef); ! 365: pMousePB->pb.usbRefcon = kFindAndOpenInterruptPipe; ! 366: pMousePB->pb.usbStatus = noErr; ! 367: } ! 368: else ! 369: { ! 370: if ((!pMousePB->retryCount) || (pMousePB->pb.usbStatus == kUSBAbortedError)) // have we exhausted the retries? ! 371: { // or received an abort? ! 372: USBExpertStatus(pMousePB->deviceRef, "USBHIDMouseModule: Pipe abort or unable to recover from error", pMousePB->deviceRef); ! 373: pMousePB->pb.usbRefcon = kReturnFromDriver; // if so, just exit. ! 374: } ! 375: else // if it didn't abort and there's retries left, then... ! 376: { ! 377: if (pMousePB->pipeRef) // check if the pipe is open. ! 378: { ! 379: USBGetPipeStatusByReference(pMousePB->pipeRef, &pipeState); // yes, so what it's state? ! 380: if (pipeState != kUSBActive) // if it's not active, try to clear it. It might be stalled... ! 381: { ! 382: USBExpertStatus(pMousePB->deviceRef, "USBHIDMouseModule: Pipe is open and stalled, clearing stall...", pMousePB->deviceRef); ! 383: USBClearPipeStallByReference(pMousePB->pipeRef); ! 384: } ! 385: } ! 386: } ! 387: } ! 388: } ! 389: else ! 390: { ! 391: ! 392: ! 393: kprintf("."); ! 394: //Adam added this 11/30 ! 395: ! 396: pMousePB->pb.usbRefcon &= ~kRetryTransaction; ! 397: pMousePB->retryCount = kMouseRetryCount; ! 398: } ! 399: ! 400: if (pMousePB->pb.usbRefcon & kCompletionPending) ! 401: { ! 402: pMousePB->pb.usbRefcon &= ~(kCompletionPending + kReturnFromDriver); ! 403: switch(pMousePB->pb.usbRefcon) ! 404: { ! 405: case kGetFullConfiguration: ! 406: pMousePB->pFullConfigDescriptor = pMousePB->pb.usbBuffer; ! 407: if (pMousePB->pFullConfigDescriptor == nil) ! 408: { ! 409: USBExpertFatalError(pMousePB->pb.usbReference, kUSBInternalErr, "USBHIDMouseModule: USBGetFullConfiguration - pointer is nil", pMousePB->pb.usbRefcon); ! 410: pMousePB->pb.usbRefcon = kReturnFromDriver; ! 411: } ! 412: else ! 413: { ! 414: pMousePB->pb.usbRefcon = kFindInterfaceAndSetProtocol; ! 415: } ! 416: break; ! 417: ! 418: case kFindInterfaceAndSetProtocol: ! 419: pMousePB->pb.usbRefcon = kSetIdleRequest; ! 420: break; ! 421: ! 422: case kSetIdleRequest: ! 423: pMousePB->pb.usbRefcon = kFindAndOpenInterruptPipe; ! 424: break; ! 425: ! 426: case kFindAndOpenInterruptPipe: ! 427: pMousePB->pipeRef = pMousePB->pb.usbReference; ! 428: pMousePB->pb.usbRefcon = kReadInterruptPipe; ! 429: break; ! 430: ! 431: case kReadInterruptPipe: ! 432: NotifyRegisteredHIDUser(pMousePB->hidDeviceType, pMousePB->hidReport); ! 433: pMousePB->pb.usbRefcon = kReadInterruptPipe; ! 434: break; ! 435: ! 436: } ! 437: } ! 438: if (!(pMousePB->pb.usbRefcon & kReturnFromDriver)) ! 439: MouseModuleInitiateTransaction(pb); ! 440: } ! 441: ! 442: ! 443: void InterfaceEntry(UInt32 interfacenum, USBInterfaceDescriptorPtr pInterfaceDescriptor, USBDeviceDescriptorPtr pDeviceDescriptor, USBDeviceRef device) ! 444: { ! 445: #pragma unused (interfacenum) ! 446: ! 447: static Boolean beenThereDoneThat = false; ! 448: ! 449: if(beenThereDoneThat) ! 450: { ! 451: USBExpertFatalError(device, kUSBInternalErr, "USBHIDMouseModule is not reentrant", 0); ! 452: return; ! 453: } ! 454: //Hot Plug n Play ! 455: //naga beenThereDoneThat = true; ! 456: ! 457: // DebugStr("In Mouse Interface Entry routine"); ! 458: kprintf("In Mouse Interface Entry routine"); ! 459: ! 460: myMousePB.deviceDescriptor = *pDeviceDescriptor; ! 461: myMousePB.interfaceDescriptor = *pInterfaceDescriptor; ! 462: myMousePB.transDepth = 0; ! 463: myMousePB.retryCount = kMouseRetryCount; ! 464: ! 465: myMousePB.pSHIMInterruptRoutine = nil; ! 466: myMousePB.pSavedInterruptRoutine = nil; ! 467: ! 468: myMousePB.deviceRef = device; ! 469: myMousePB.interfaceRef = nil; ! 470: myMousePB.pipeRef = nil; ! 471: ! 472: InitParamBlock(device, &myMousePB.pb); ! 473: ! 474: myMousePB.pb.usbReference = device; ! 475: myMousePB.pb.pbLength = sizeof(usbMousePBStruct); ! 476: myMousePB.pb.usbRefcon = kGetFullConfiguration; ! 477: ! 478: if ((myMousePB.deviceDescriptor.vendor == USB_CONSTANT16(0x046e)) && ! 479: (myMousePB.deviceDescriptor.product == USB_CONSTANT16(0x6782))) ! 480: { ! 481: myMousePB.unitsPerInch = (Fixed)(100<<16); ! 482: } ! 483: else ! 484: { ! 485: myMousePB.unitsPerInch = (Fixed)(400<<16); ! 486: } ! 487: ! 488: myMousePB.pCursorDeviceInfo = 0; ! 489: USBHIDControlDevice(kHIDEnableDemoMode,0); ! 490: ! 491: MouseModuleInitiateTransaction(&myMousePB.pb); ! 492: } ! 493: ! 494: ! 495: /* naga */ ! 496: OSErr CursorDeviceNewDevice(CursorDevicePtr * ourDevice) ! 497: { ! 498: // TWOWORDINLINE(0x700C, 0xAADB); ! 499: return 0; ! 500: } ! 501: ! 502: OSErr CursorDeviceDisposeDevice(CursorDevicePtr ourDevice) ! 503: { ! 504: // TWOWORDINLINE(0x700D, 0xAADB); ! 505: return 0; ! 506: } ! 507: OSErr CursorDeviceMove(CursorDevicePtr ourDevice, long deltaX, long deltaY) ! 508: { ! 509: //TWOWORDINLINE(0x7000, 0xAADB); ! 510: return 0; ! 511: } ! 512: OSErr CursorDeviceMoveTo(CursorDevicePtr ourDevice, long absX, long absY) ! 513: { ! 514: //TWOWORDINLINE(0x7001, 0xAADB); ! 515: return 0; ! 516: } ! 517: OSErr CursorDeviceFlush (CursorDevicePtr ourDevice) ! 518: { ! 519: //TWOWORDINLINE(0x7002, 0xAADB); ! 520: return 0; ! 521: } ! 522: ! 523: OSErr CursorDeviceButtons(CursorDevicePtr ourDevice, short buttons) ! 524: { ! 525: //TWOWORDINLINE(0x7003, 0xAADB); ! 526: return 0; ! 527: } ! 528: OSErr CursorDeviceButtonDown(CursorDevicePtr ourDevice) ! 529: { ! 530: return 0; ! 531: } ! 532: OSErr CursorDeviceButtonUp(CursorDevicePtr ourDevice) ! 533: { ! 534: //TWOWORDINLINE(0x7005, 0xAADB); ! 535: return 0; ! 536: } ! 537: ! 538: OSErr CursorDeviceButtonOp(CursorDevicePtr ourDevice, short buttonNumber, ButtonOpcode opcode, long data) ! 539: { ! 540: //TWOWORDINLINE(0x7006, 0xAADB); ! 541: return 0; ! 542: } ! 543: ! 544: OSErr CursorDeviceSetButtons(CursorDevicePtr ourDevice, short numberOfButtons) ! 545: { ! 546: //TWOWORDINLINE(0x7007, 0xAADB); ! 547: return 0; ! 548: } ! 549: ! 550: OSErr CursorDeviceSetAcceleration(CursorDevicePtr ourDevice,Fixed acceleration) ! 551: { ! 552: //TWOWORDINLINE(0x7008, 0xAADB); ! 553: return 0; ! 554: } ! 555: ! 556: OSErr CursorDeviceDoubleTime(CursorDevicePtr ourDevice, long durationTicks) ! 557: { ! 558: //TWOWORDINLINE(0x7009, 0xAADB); ! 559: return 0; ! 560: } ! 561: ! 562: OSErr CursorDeviceUnitsPerInch(CursorDevicePtr ourDevice, Fixed resolution) ! 563: { ! 564: // TWOWORDINLINE(0x700A, 0xAADB); ! 565: return 0; ! 566: } ! 567: ! 568: OSErr CursorDeviceNextDevice(CursorDevicePtr * ourDevice) ! 569: { ! 570: //TWOWORDINLINE(0x700B, 0xAADB); ! 571: return 0; ! 572: } ! 573:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.