Date: Thu, 12 Sep 2002 20:35:51 -0400
authorSam Lantinga <slouken@libsdl.org>
Mon, 16 Sep 2002 06:50:26 +0000
changeset 4954503f9475cf2
parent 494 95aa4041e7f9
child 496 864a66f028d8
Date: Thu, 12 Sep 2002 20:35:51 -0400
From: Darrell Walisser
Subject: Jag joystick fix (take 2)

This patch enables all HID devices, not just joysticks. This quell
complaints about gamepads not working, though I don't have I gamepad to
verify this theory.

Before, only joysticks were recognized. Now, all HID devices except the
keyboard and mouse will be recognized.
src/joystick/darwin/SDL_sysjoystick.c
     1.1 --- a/src/joystick/darwin/SDL_sysjoystick.c	Mon Sep 16 06:26:22 2002 +0000
     1.2 +++ b/src/joystick/darwin/SDL_sysjoystick.c	Mon Sep 16 06:50:26 2002 +0000
     1.3 @@ -571,8 +571,6 @@
     1.4  	CFMutableDictionaryRef hidMatchDictionary = NULL;
     1.5  	recDevice *device, *lastDevice;
     1.6  	io_object_t ioHIDDeviceObject = NULL;
     1.7 -	UInt32 usagePage = kHIDPage_GenericDesktop;
     1.8 -	UInt32 usage = kHIDUsage_GD_Joystick; /* We probably also should check for gamepads? */
     1.9  	
    1.10  	SDL_numjoysticks = 0;
    1.11  	
    1.12 @@ -591,15 +589,20 @@
    1.13  
    1.14  	/* Set up a matching dictionary to search I/O Registry by class name for all HID class devices. */
    1.15  	hidMatchDictionary = IOServiceMatching (kIOHIDDeviceKey);
    1.16 -	if ((hidMatchDictionary != NULL) && (usagePage) && (usage))
    1.17 +	if ((hidMatchDictionary != NULL))
    1.18  	{
    1.19  		/* Add key for device type (joystick, in this case) to refine the matching dictionary. */
    1.20 +		
    1.21 +		/* NOTE: we now perform this filtering later
    1.22 +		UInt32 usagePage = kHIDPage_GenericDesktop;
    1.23 +		UInt32 usage = kHIDUsage_GD_Joystick;
    1.24  		CFNumberRef refUsage = NULL, refUsagePage = NULL;
    1.25  
    1.26  		refUsage = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &usage);
    1.27  		CFDictionarySetValue (hidMatchDictionary, CFSTR (kIOHIDPrimaryUsageKey), refUsage);
    1.28  		refUsagePage = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &usagePage);
    1.29  		CFDictionarySetValue (hidMatchDictionary, CFSTR (kIOHIDPrimaryUsagePageKey), refUsagePage);
    1.30 +		*/
    1.31  	}
    1.32  	else
    1.33  	{
    1.34 @@ -638,6 +641,18 @@
    1.35  		result = IOObjectRelease (ioHIDDeviceObject);
    1.36  //		if (KERN_SUCCESS != result)
    1.37  //			HIDReportErrorNum ("IOObjectRelease error with ioHIDDeviceObject.", result);
    1.38 +
    1.39 +		/* Filter device list to non-keyboard/mouse stuff */ 
    1.40 +		if ( device->usagePage == kHIDPage_GenericDesktop &&
    1.41 +		     (device->usage == kHIDUsage_GD_Keyboard ||
    1.42 +		      device->usage == kHIDUsage_GD_Mouse)) {
    1.43 +            
    1.44 +			/* release memory for the device */
    1.45 +			HIDDisposeDevice (&device);
    1.46 +			DisposePtr((Ptr)device);
    1.47 +			continue;
    1.48 +		}
    1.49 +		
    1.50  		/* Add device to the end of the list */
    1.51  		if (lastDevice)
    1.52  			lastDevice->pNext = device;