# HG changeset patch # User Edgar Simo # Date 1218397538 0 # Node ID 2f826c229d7729452d2ba62bd65ed58d031639b4 # Parent 57ac1594164ebe0903990b711109db5b25aa0a7a First draft of darwin haptic<->joystick stuff. diff -r 57ac1594164e -r 2f826c229d77 src/haptic/darwin/SDL_syshaptic.c --- a/src/haptic/darwin/SDL_syshaptic.c Wed Aug 06 17:14:54 2008 +0000 +++ b/src/haptic/darwin/SDL_syshaptic.c Sun Aug 10 19:45:38 2008 +0000 @@ -447,6 +447,8 @@ int SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) { + if (joystick->hwdata->ffservice != 0) + return SDL_TRUE; return SDL_FALSE; } @@ -457,6 +459,8 @@ int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) { + if (IOObjectIsEqualTo(haptic->hwdata->device, joystick->hwdata->ffservice)) + return 1; return 0; } @@ -467,7 +471,8 @@ int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) { - return -1; + return SDL_SYS_HapticOpenFromService(haptic, + joystick->hwdata->ffservice); } diff -r 57ac1594164e -r 2f826c229d77 src/joystick/darwin/SDL_sysjoystick.c --- a/src/joystick/darwin/SDL_sysjoystick.c Wed Aug 06 17:14:54 2008 +0000 +++ b/src/joystick/darwin/SDL_sysjoystick.c Sun Aug 10 19:45:38 2008 +0000 @@ -545,6 +545,12 @@ /* save next device prior to disposing of this device */ pDeviceNext = (*ppDevice)->pNext; + /* free posible io_service_t */ + if ((*ppDevice)->ffservice) { + IOObjectRelease((*ppDevice)->ffservice); + (*ppDevice)->ffservice = 0; + } + /* free element lists */ HIDDisposeElementList(&(*ppDevice)->firstAxis); HIDDisposeElementList(&(*ppDevice)->firstButton); @@ -637,8 +643,16 @@ if (!device) continue; - /* dump device object, it is no longer needed */ - result = IOObjectRelease(ioHIDDeviceObject); + /* We have to do some storage of the io_service_t for + * SDL_HapticOpenFromJoystick */ + if (FFIsForceFeedback(device) == FF_OK) { + device->ffservice = ioHIDDeviceObject; + } + else { + device->ffservice = 0; + /* dump device object, it is no longer needed */ + result = IOObjectRelease(ioHIDDeviceObject); + } /* if (KERN_SUCCESS != result) HIDReportErrorNum ("IOObjectRelease error with ioHIDDeviceObject.", result); */ diff -r 57ac1594164e -r 2f826c229d77 src/joystick/darwin/SDL_sysjoystick_c.h --- a/src/joystick/darwin/SDL_sysjoystick_c.h Wed Aug 06 17:14:54 2008 +0000 +++ b/src/joystick/darwin/SDL_sysjoystick_c.h Sun Aug 10 19:45:38 2008 +0000 @@ -60,6 +60,7 @@ struct joystick_hwdata { + io_service_t ffservice; /* Interface for force feedback, 0 = no ff */ IOHIDDeviceInterface **interface; /* interface to device, NULL = no interface */ char product[256]; /* name of product */