|
|
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: /* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved. ! 26: * ! 27: * PCPointer.m - Generic PCPointer device class. ! 28: * ! 29: * ! 30: * HISTORY ! 31: * 01-Dec-92 Joe Pasqua at NeXT ! 32: * Created. ! 33: */ ! 34: ! 35: // TO DO: ! 36: // ! 37: // Notes: ! 38: // * To find things that need to be fixed, search for FIX, to find questions ! 39: // to be resolved, search for ASK, to find stuff that still needs to be ! 40: // done, search for TO DO. ! 41: // ! 42: ! 43: #define MACH_USER_API 1 ! 44: #undef KERNEL_PRIVATE ! 45: ! 46: #import <objc/Object.h> ! 47: #import <driverkit/driverServer.h> ! 48: #import <driverkit/generalFuncs.h> ! 49: #import <bsd/dev/ppc/PCPointer.h> ! 50: #import <bsd/dev/ppc/PCPointerDefs.h> ! 51: ! 52: static id activePointerDevice; ! 53: ! 54: @implementation PCPointer ! 55: ! 56: - (int)getResolution ! 57: { ! 58: // Subclasses must implement this method for proper operation ! 59: return 50; // This is a standard sort of value. ! 60: } ! 61: ! 62: - (BOOL)setEventTarget:eventTarget ! 63: { ! 64: if ( [eventTarget conformsTo:@protocol(ADBPointerTarget)] ) ! 65: { ! 66: target = eventTarget; ! 67: return TRUE; ! 68: } ! 69: else ! 70: { ! 71: IOLog( "PCPointer setEventTarget: new target [%s] does not " ! 72: "implement PCPointerTarget protocol.\n", ! 73: object_getClassName(eventTarget) ); ! 74: return FALSE; ! 75: } ! 76: } ! 77: ! 78: PCPatoi(char *p) ! 79: { ! 80: int n = 0; ! 81: int f = 0; ! 82: ! 83: for(;;p++) { ! 84: switch(*p) { ! 85: case ' ': ! 86: case '\t': ! 87: continue; ! 88: case '-': ! 89: f++; ! 90: case '+': ! 91: p++; ! 92: } ! 93: break; ! 94: } ! 95: while(*p >= '0' && *p <= '9') ! 96: n = n*10 + *p++ - '0'; ! 97: return(f? -n: n); ! 98: } ! 99: ! 100: - (BOOL)mouseInit:deviceDescription ! 101: { ! 102: return NO; ! 103: } ! 104: ! 105: + (id) activePointerDevice ! 106: { ! 107: return activePointerDevice; ! 108: } ! 109: ! 110: + (BOOL)probe:deviceDescription ! 111: { ! 112: PCPointer *inst; ! 113: char nameBuf[20]; ! 114: static IOObjectNumber nextUnit; // Initial value is 0 ! 115: ! 116: inst = [[self alloc] initFromDeviceDescription:deviceDescription]; ! 117: inst->target = nil; // No one is the target of mouse events yet ! 118: ! 119: // Initialize the specific rodent in question. ! 120: if ([inst mouseInit:deviceDescription] == NO) { ! 121: IOLog("PCPointer probe: mouseInit failure\n"); ! 122: [inst free]; ! 123: return NO; ! 124: } ! 125: else { ! 126: sprintf(nameBuf, "PPCPointer%d", nextUnit); ! 127: [inst setUnit:nextUnit++]; ! 128: [inst setName:nameBuf]; ! 129: // [self setDeviceKind:"SpecificType"]; was done by the subclass ! 130: [inst registerDevice]; ! 131: activePointerDevice = inst; ! 132: } ! 133: ! 134: return YES; ! 135: } ! 136: @end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.