diff src/haptic/darwin/SDL_syshaptic.c @ 2550:b5b8a7f4a965 gsoc2008_force_feedback

Reset device and enable actuators when initializing.
author Edgar Simo <bobbens@gmail.com>
date Wed, 30 Jul 2008 10:28:37 +0000
parents 3cfe0ae232c0
children ee048e7bc909
line wrap: on
line diff
--- a/src/haptic/darwin/SDL_syshaptic.c	Mon Jul 28 10:26:21 2008 +0000
+++ b/src/haptic/darwin/SDL_syshaptic.c	Wed Jul 30 10:28:37 2008 +0000
@@ -364,12 +364,30 @@
    }
 
    /* Get supported features. */
-   haptic->supported = GetSupportedFeatures(haptic->hwdata->device,
-                                            &haptic->neffects, &haptic->nplaying,
-                                            &haptic->naxes);
+   haptic->supported = GetSupportedFeatures( haptic->hwdata->device,
+                                             &haptic->neffects, &haptic->nplaying,
+                                             &haptic->naxes );
    if (haptic->supported == 0) { /* Error since device supports nothing. */
       goto open_err;
    }
+
+
+   /* Reset and then enable actuators. */
+   ret = FFDeviceSendForceFeedbackCommand( haptic->hwdata->device,
+                                           FFSFFC_RESET );
+   if (ret != FF_OK) {
+      SDL_SetError("Haptic: Unable to reset device: %s.", FFStrError(ret));
+      goto open_err;
+   }
+   ret = FFDeviceSendForceFeedbackCommand( haptic->hwdata->device,
+                                           FFSFFC_SETACTUATORSON  );
+   if (ret != FF_OK) {
+      SDL_SetError("Haptic: Unable to enable actuators: %s.", FFStrError(ret));
+      goto open_err;
+   }
+
+
+   /* Allocate effects memory. */
    haptic->effects = (struct haptic_effect *)
          SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
    if (haptic->effects == NULL) {