src/haptic/linux/SDL_syshaptic.c
branchgsoc2008_force_feedback
changeset 2526 2d88b82ce781
parent 2524 1a55848ce198
child 2530 22ce87690b41
--- a/src/haptic/linux/SDL_syshaptic.c	Thu Jul 17 16:08:46 2008 +0000
+++ b/src/haptic/linux/SDL_syshaptic.c	Fri Jul 18 08:00:16 2008 +0000
@@ -493,6 +493,7 @@
 static int
 SDL_SYS_ToFFEffect( struct ff_effect * dest, SDL_HapticEffect * src )
 {
+   Uint32 tmp;
    SDL_HapticConstant *constant;
    SDL_HapticPeriodic *periodic;
    SDL_HapticCondition *condition;
@@ -563,7 +564,9 @@
          dest->u.periodic.period = CLAMP(periodic->period);
          dest->u.periodic.magnitude = periodic->magnitude;
          dest->u.periodic.offset = periodic->offset;
-         dest->u.periodic.phase = CLAMP(periodic->phase);
+         /* Phase is calculated based of offset from period and then clamped. */
+         tmp = ((periodic->phase % 36000) * dest->u.periodic.period) / 36000;
+         dest->u.periodic.phase = CLAMP(tmp);
          
          /* Envelope */
          dest->u.periodic.envelope.attack_length = CLAMP(periodic->attack_length);