Date: Mon, 29 Jul 2002 15:07:22 +1000
authorSam Lantinga <slouken@libsdl.org>
Mon, 29 Jul 2002 22:26:43 +0000
changeset 427027ae30b867f
parent 426 33712e5d1ec8
child 428 1338c24e30cb
Date: Mon, 29 Jul 2002 15:07:22 +1000
From: screwtape@froup.com

The attached patch lets SDL_Init(SDL_INIT_JOYSTICK) succeed on Mac OS
X when there are no joysticks attached, in line with SDL's behaviour
on Linux.
src/joystick/darwin/SDL_sysjoystick.c
     1.1 --- a/src/joystick/darwin/SDL_sysjoystick.c	Fri Jul 26 17:13:17 2002 +0000
     1.2 +++ b/src/joystick/darwin/SDL_sysjoystick.c	Mon Jul 29 22:26:43 2002 +0000
     1.3 @@ -609,11 +609,17 @@
     1.4  	/*/ Now search I/O Registry for matching devices. */
     1.5  	result = IOServiceGetMatchingServices (masterPort, hidMatchDictionary, &hidObjectIterator);
     1.6  	/* Check for errors */
     1.7 -	if ((kIOReturnSuccess != result) || (NULL == hidObjectIterator))
     1.8 +	if (kIOReturnSuccess != result)
     1.9  	{
    1.10  		SDL_SetError("Joystick: Couldn't create a HID object iterator.");
    1.11  		return -1;
    1.12  	}
    1.13 +	if (NULL == hidObjectIterator) /* there are no joysticks */
    1.14 +	{
    1.15 +		gpDeviceList = NULL;
    1.16 +		SDL_numjoysticks = 0;
    1.17 +		return 0;
    1.18 +	}
    1.19  	/* IOServiceGetMatchingServices consumes a reference to the dictionary, so we don't need to release the dictionary ref. */
    1.20  
    1.21  	/* build flat linked list of devices from device iterator */