src/joystick/darwin/SDL_sysjoystick.c
changeset 1487 dc6b59e925a2
parent 1409 ebc8b5855040
child 1496 405e20dc004c
     1.1 --- a/src/joystick/darwin/SDL_sysjoystick.c	Wed Mar 08 18:30:12 2006 +0000
     1.2 +++ b/src/joystick/darwin/SDL_sysjoystick.c	Thu Mar 09 06:33:21 2006 +0000
     1.3 @@ -48,42 +48,42 @@
     1.4  
     1.5  struct recElement
     1.6  {
     1.7 -	IOHIDElementCookie cookie;				// unique value which identifies element, will NOT change
     1.8 -	long min;								// reported min value possible
     1.9 -	long max;								// reported max value possible
    1.10 -/*
    1.11 -	TODO: maybe should handle the following stuff somehow?
    1.12 +	IOHIDElementCookie cookie;				/* unique value which identifies element, will NOT change */
    1.13 +	long min;								/* reported min value possible */
    1.14 +	long max;								/* reported max value possible */
    1.15 +#if 0
    1.16 +	/* TODO: maybe should handle the following stuff somehow? */
    1.17  
    1.18 -	long scaledMin;							// reported scaled min value possible
    1.19 -	long scaledMax;							// reported scaled max value possible
    1.20 -	long size;								// size in bits of data return from element
    1.21 -	Boolean relative;						// are reports relative to last report (deltas)
    1.22 -	Boolean wrapping;						// does element wrap around (one value higher than max is min)
    1.23 -	Boolean nonLinear;						// are the values reported non-linear relative to element movement
    1.24 -	Boolean preferredState;					// does element have a preferred state (such as a button)
    1.25 -	Boolean nullState;						// does element have null state
    1.26 -*/
    1.27 +	long scaledMin;							/* reported scaled min value possible */
    1.28 +	long scaledMax;							/* reported scaled max value possible */
    1.29 +	long size;								/* size in bits of data return from element */
    1.30 +	Boolean relative;						/* are reports relative to last report (deltas) */
    1.31 +	Boolean wrapping;						/* does element wrap around (one value higher than max is min) */
    1.32 +	Boolean nonLinear;						/* are the values reported non-linear relative to element movement */
    1.33 +	Boolean preferredState;					/* does element have a preferred state (such as a button) */
    1.34 +	Boolean nullState;						/* does element have null state */
    1.35 +#endif /* 0 */
    1.36  
    1.37  	/* runtime variables used for auto-calibration */
    1.38 -	long minReport;							// min returned value
    1.39 -	long maxReport;							// max returned value
    1.40 +	long minReport;							/* min returned value */
    1.41 +	long maxReport;							/* max returned value */
    1.42  	
    1.43 -	struct recElement * pNext;				// next element in list
    1.44 +	struct recElement * pNext;				/* next element in list */
    1.45  };
    1.46  typedef struct recElement recElement;
    1.47  
    1.48  struct joystick_hwdata
    1.49  {
    1.50 -	IOHIDDeviceInterface ** interface;		// interface to device, NULL = no interface
    1.51 +	IOHIDDeviceInterface ** interface;		/* interface to device, NULL = no interface */
    1.52  
    1.53 -	char product[256];							// name of product
    1.54 -	long usage;								// usage page from IOUSBHID Parser.h which defines general usage
    1.55 -	long usagePage;							// usage within above page from IOUSBHID Parser.h which defines specific usage
    1.56 +	char product[256];							/* name of product */
    1.57 +	long usage;								/* usage page from IOUSBHID Parser.h which defines general usage */
    1.58 +	long usagePage;							/* usage within above page from IOUSBHID Parser.h which defines specific usage */
    1.59  
    1.60 -	long axes;								// number of axis (calculated, not reported by device)
    1.61 -	long buttons;							// number of buttons (calculated, not reported by device)
    1.62 -	long hats;								// number of hat switches (calculated, not reported by device)
    1.63 -	long elements;							// number of total elements (shouldbe total of above) (calculated, not reported by device)
    1.64 +	long axes;								/* number of axis (calculated, not reported by device) */
    1.65 +	long buttons;							/* number of buttons (calculated, not reported by device) */
    1.66 +	long hats;								/* number of hat switches (calculated, not reported by device) */
    1.67 +	long elements;							/* number of total elements (shouldbe total of above) (calculated, not reported by device) */
    1.68  
    1.69  	recElement* firstAxis;
    1.70  	recElement* firstButton;
    1.71 @@ -92,7 +92,7 @@
    1.72  	int removed;
    1.73  	int uncentered;
    1.74  
    1.75 -	struct joystick_hwdata* pNext;			// next device
    1.76 +	struct joystick_hwdata* pNext;			/* next device */
    1.77  };
    1.78  typedef struct joystick_hwdata recDevice;
    1.79  
    1.80 @@ -131,32 +131,17 @@
    1.81  		}
    1.82  	}
    1.83  
    1.84 -	// auto user scale
    1.85 +	/* auto user scale */
    1.86  	return hidEvent.value;
    1.87  }
    1.88  
    1.89 -/* similiar to HIDGetElementValue, but auto-calibrates the value before returning it */
    1.90 -
    1.91 -static SInt32 HIDCalibratedValue (recDevice *pDevice, recElement *pElement)
    1.92 -{
    1.93 -	float deviceScale = pElement->max - pElement->min;
    1.94 -	float readScale = pElement->maxReport - pElement->minReport;
    1.95 -	SInt32 value = HIDGetElementValue(pDevice, pElement);
    1.96 -	if (readScale == 0)
    1.97 -		return value; // no scaling at all
    1.98 -	else
    1.99 -		return ((value - pElement->minReport) * deviceScale / readScale) + pElement->min;
   1.100 -}
   1.101 -
   1.102 -/* similiar to HIDCalibratedValue but calibrates to an arbitrary scale instead of the elements default scale */
   1.103 -
   1.104  static SInt32 HIDScaledCalibratedValue (recDevice *pDevice, recElement *pElement, long min, long max)
   1.105  {
   1.106  	float deviceScale = max - min;
   1.107  	float readScale = pElement->maxReport - pElement->minReport;
   1.108  	SInt32 value = HIDGetElementValue(pDevice, pElement);
   1.109  	if (readScale == 0)
   1.110 -		return value; // no scaling at all
   1.111 +		return value; /* no scaling at all */
   1.112  	else
   1.113  		return ((value - pElement->minReport) * deviceScale / readScale) + min;
   1.114  }
   1.115 @@ -191,7 +176,7 @@
   1.116  													kIOCFPlugInInterfaceID, &ppPlugInInterface, &score);
   1.117  		if (kIOReturnSuccess == result)
   1.118  		{
   1.119 -			// Call a method of the intermediate plug-in to create the device interface
   1.120 +			/* Call a method of the intermediate plug-in to create the device interface */
   1.121  			plugInResult = (*ppPlugInInterface)->QueryInterface (ppPlugInInterface,
   1.122  								CFUUIDGetUUIDBytes (kIOHIDDeviceInterfaceID), (void *) &(pDevice->interface));
   1.123  			if (S_OK != plugInResult)
   1.124 @@ -225,15 +210,15 @@
   1.125  	
   1.126  	if ((NULL != pDevice) && (NULL != pDevice->interface))
   1.127  	{
   1.128 -		// close the interface
   1.129 +		/* close the interface */
   1.130  		result = (*(pDevice->interface))->close (pDevice->interface);
   1.131  		if (kIOReturnNotOpen == result)
   1.132  		{
   1.133 -			//  do nothing as device was not opened, thus can't be closed
   1.134 +			/* do nothing as device was not opened, thus can't be closed */
   1.135  		}
   1.136  		else if (kIOReturnSuccess != result)
   1.137  			HIDReportErrorNum ("Failed to close IOHIDDeviceInterface.", result);
   1.138 -		//release the interface
   1.139 +		/* release the interface */
   1.140  		result = (*(pDevice->interface))->Release (pDevice->interface);
   1.141  		if (kIOReturnSuccess != result)
   1.142  			HIDReportErrorNum ("Failed to release IOHIDDeviceInterface.", result);
   1.143 @@ -559,7 +544,7 @@
   1.144  	recDevice *pDeviceNext = NULL;
   1.145  	if (*ppDevice)
   1.146  	{
   1.147 -		// save next device prior to disposing of this device
   1.148 +		/* save next device prior to disposing of this device */
   1.149  		pDeviceNext = (*ppDevice)->pNext;
   1.150  		
   1.151  		/* free element lists */
   1.152 @@ -658,8 +643,9 @@
   1.153  
   1.154  		/* dump device object, it is no longer needed */
   1.155  		result = IOObjectRelease (ioHIDDeviceObject);
   1.156 -//		if (KERN_SUCCESS != result)
   1.157 -//			HIDReportErrorNum ("IOObjectRelease error with ioHIDDeviceObject.", result);
   1.158 +/*		if (KERN_SUCCESS != result)
   1.159 +			HIDReportErrorNum ("IOObjectRelease error with ioHIDDeviceObject.", result);
   1.160 +*/
   1.161  
   1.162  		/* Filter device list to non-keyboard/mouse stuff */ 
   1.163  		if ( (device->usagePage != kHIDPage_GenericDesktop) ||