From f43c0a3fd22962e0dc699cb283af5ccc31c91449 Mon Sep 17 00:00:00 2001 From: Edgar Simo Date: Wed, 30 Jul 2008 10:28:37 +0000 Subject: [PATCH] Reset device and enable actuators when initializing. --- src/haptic/darwin/SDL_syshaptic.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c index 8b139f115..c7fc556f5 100644 --- a/src/haptic/darwin/SDL_syshaptic.c +++ b/src/haptic/darwin/SDL_syshaptic.c @@ -364,12 +364,30 @@ SDL_SYS_HapticOpenFromService(SDL_Haptic * haptic, io_service_t service) } /* 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) {