# HG changeset patch # User Sam Lantinga # Date 1027981603 0 # Node ID 027ae30b867f454fa7a666ce4cf7b0cc80e4b87e # Parent 33712e5d1ec89055879a7aa8397e84e8189095eb 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. diff -r 33712e5d1ec8 -r 027ae30b867f src/joystick/darwin/SDL_sysjoystick.c --- a/src/joystick/darwin/SDL_sysjoystick.c Fri Jul 26 17:13:17 2002 +0000 +++ b/src/joystick/darwin/SDL_sysjoystick.c Mon Jul 29 22:26:43 2002 +0000 @@ -609,11 +609,17 @@ /*/ Now search I/O Registry for matching devices. */ result = IOServiceGetMatchingServices (masterPort, hidMatchDictionary, &hidObjectIterator); /* Check for errors */ - if ((kIOReturnSuccess != result) || (NULL == hidObjectIterator)) + if (kIOReturnSuccess != result) { SDL_SetError("Joystick: Couldn't create a HID object iterator."); return -1; } + if (NULL == hidObjectIterator) /* there are no joysticks */ + { + gpDeviceList = NULL; + SDL_numjoysticks = 0; + return 0; + } /* IOServiceGetMatchingServices consumes a reference to the dictionary, so we don't need to release the dictionary ref. */ /* build flat linked list of devices from device iterator */