diff src/haptic/darwin/SDL_syshaptic.c @ 2533:0c8cea99c4b8 gsoc2008_force_feedback

Added SDL_HAPTIC_RAMP support for darwin.
author Edgar Simo <bobbens@gmail.com>
date Fri, 18 Jul 2008 19:21:36 +0000
parents 688cad3f6090
children e597de8dccd5
line wrap: on
line diff
--- 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;