Reset device and enable actuators when initializing. gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Wed, 30 Jul 2008 10:28:37 +0000
branchgsoc2008_force_feedback
changeset 2550b5b8a7f4a965
parent 2549 491e43f427ee
child 2551 f010e1d4e431
Reset device and enable actuators when initializing.
src/haptic/darwin/SDL_syshaptic.c
     1.1 --- a/src/haptic/darwin/SDL_syshaptic.c	Mon Jul 28 10:26:21 2008 +0000
     1.2 +++ b/src/haptic/darwin/SDL_syshaptic.c	Wed Jul 30 10:28:37 2008 +0000
     1.3 @@ -364,12 +364,30 @@
     1.4     }
     1.5  
     1.6     /* Get supported features. */
     1.7 -   haptic->supported = GetSupportedFeatures(haptic->hwdata->device,
     1.8 -                                            &haptic->neffects, &haptic->nplaying,
     1.9 -                                            &haptic->naxes);
    1.10 +   haptic->supported = GetSupportedFeatures( haptic->hwdata->device,
    1.11 +                                             &haptic->neffects, &haptic->nplaying,
    1.12 +                                             &haptic->naxes );
    1.13     if (haptic->supported == 0) { /* Error since device supports nothing. */
    1.14        goto open_err;
    1.15     }
    1.16 +
    1.17 +
    1.18 +   /* Reset and then enable actuators. */
    1.19 +   ret = FFDeviceSendForceFeedbackCommand( haptic->hwdata->device,
    1.20 +                                           FFSFFC_RESET );
    1.21 +   if (ret != FF_OK) {
    1.22 +      SDL_SetError("Haptic: Unable to reset device: %s.", FFStrError(ret));
    1.23 +      goto open_err;
    1.24 +   }
    1.25 +   ret = FFDeviceSendForceFeedbackCommand( haptic->hwdata->device,
    1.26 +                                           FFSFFC_SETACTUATORSON  );
    1.27 +   if (ret != FF_OK) {
    1.28 +      SDL_SetError("Haptic: Unable to enable actuators: %s.", FFStrError(ret));
    1.29 +      goto open_err;
    1.30 +   }
    1.31 +
    1.32 +
    1.33 +   /* Allocate effects memory. */
    1.34     haptic->effects = (struct haptic_effect *)
    1.35           SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
    1.36     if (haptic->effects == NULL) {