From e96845c438cc030b34dc232411f2847cd3da6f54 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 29 Jul 2002 22:26:43 +0000 Subject: [PATCH] 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/joystick/darwin/SDL_sysjoystick.c b/src/joystick/darwin/SDL_sysjoystick.c index c74f12822..5ce67b0b1 100644 --- a/src/joystick/darwin/SDL_sysjoystick.c +++ b/src/joystick/darwin/SDL_sysjoystick.c @@ -609,11 +609,17 @@ int SDL_SYS_JoystickInit(void) /*/ 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 */