Added SDL_HAPTIC_RAMP support for darwin. gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Fri, 18 Jul 2008 19:21:36 +0000
branchgsoc2008_force_feedback
changeset 2533 0c8cea99c4b8
parent 2532 688cad3f6090
child 2534 e597de8dccd5
Added SDL_HAPTIC_RAMP support for darwin.
src/haptic/darwin/SDL_syshaptic.c
--- a/src/haptic/darwin/SDL_syshaptic.c	Fri Jul 18 19:16:03 2008 +0000
+++ b/src/haptic/darwin/SDL_syshaptic.c	Fri Jul 18 19:21:36 2008 +0000
@@ -570,6 +570,32 @@
 
       case SDL_HAPTIC_RAMP:
          hap_ramp = &src->ramp;
+         ramp = SDL_malloc(sizeof(FFRAMPFORCE));
+         if (ramp == NULL) {
+            SDL_OutOfMemory();
+            return -1;
+         }
+
+         /* Specifics */
+         ramp->lMagnitude = CONVERT(hap_ramp->start);
+         ramp->lEnd = CONVERT(hap_ramp->end);
+
+         /* Generics */
+         dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */
+         dest->dwTriggerButton = FFJOFS_BUTTON(hap_ramp->button);
+         dest->dwTriggerRepeatInterval = hap_ramp->interval;
+         dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */
+
+         /* Direction. */
+         if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) {
+            return -1;
+         }
+
+         /* Envelope */
+         envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level);
+         envelope->dwAttackTime = hap_ramp->attack_length * 1000;
+         envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level);
+         envelope->dwFadeTime = hap_ramp->fade_length * 1000;
 
          break;