src/joystick/darwin/SDL_sysjoystick.c
branchgsoc2008_force_feedback
changeset 2637 2f826c229d77
parent 2632 9e7f58b1b255
child 2638 db93456d4b26
     1.1 --- a/src/joystick/darwin/SDL_sysjoystick.c	Wed Aug 06 17:14:54 2008 +0000
     1.2 +++ b/src/joystick/darwin/SDL_sysjoystick.c	Sun Aug 10 19:45:38 2008 +0000
     1.3 @@ -545,6 +545,12 @@
     1.4          /* save next device prior to disposing of this device */
     1.5          pDeviceNext = (*ppDevice)->pNext;
     1.6  
     1.7 +        /* free posible io_service_t */
     1.8 +        if ((*ppDevice)->ffservice) {
     1.9 +            IOObjectRelease((*ppDevice)->ffservice);
    1.10 +            (*ppDevice)->ffservice = 0;
    1.11 +        }
    1.12 +
    1.13          /* free element lists */
    1.14          HIDDisposeElementList(&(*ppDevice)->firstAxis);
    1.15          HIDDisposeElementList(&(*ppDevice)->firstButton);
    1.16 @@ -637,8 +643,16 @@
    1.17          if (!device)
    1.18              continue;
    1.19  
    1.20 -        /* dump device object, it is no longer needed */
    1.21 -        result = IOObjectRelease(ioHIDDeviceObject);
    1.22 +        /* We have to do some storage of the io_service_t for
    1.23 +         * SDL_HapticOpenFromJoystick */
    1.24 +        if (FFIsForceFeedback(device) == FF_OK) {
    1.25 +           device->ffservice = ioHIDDeviceObject;
    1.26 +        }
    1.27 +        else {
    1.28 +           device->ffservice = 0;
    1.29 +           /* dump device object, it is no longer needed */
    1.30 +           result = IOObjectRelease(ioHIDDeviceObject);
    1.31 +        }
    1.32  /*		if (KERN_SUCCESS != result)
    1.33  			HIDReportErrorNum ("IOObjectRelease error with ioHIDDeviceObject.", result);
    1.34  */