diff -uNrp rev1/include/SDL_haptic.h rev2/include/SDL_haptic.h --- rev1/include/SDL_haptic.h 2014-08-23 20:24:23.217689665 +0200 +++ rev2/include/SDL_haptic.h 2014-08-23 21:45:09.573875988 +0200 @@ -553,7 +553,7 @@ typedef struct SDL_HapticPeriodic /* Periodic */ Uint16 period; /**< Period of the wave. */ - Sint16 magnitude; /**< Peak value. */ + Sint16 magnitude; /**< Peak value; if negative, equivalent to 180 degrees extra phase shift. */ Sint16 offset; /**< Mean value of the wave. */ Uint16 phase; /**< Horizontal shift given by hundredth of a degree. */ diff -uNrp rev1/src/haptic/darwin/SDL_syshaptic.c rev2/src/haptic/darwin/SDL_syshaptic.c --- rev1/src/haptic/darwin/SDL_syshaptic.c 2014-08-17 00:20:14.000000000 +0200 +++ rev2/src/haptic/darwin/SDL_syshaptic.c 2014-08-23 21:01:52.426068731 +0200 @@ -23,6 +23,7 @@ #ifdef SDL_HAPTIC_IOKIT #include "SDL_assert.h" +#include "SDL_stdinc.h" #include "SDL_haptic.h" #include "../SDL_syshaptic.h" #include "SDL_joystick.h" @@ -872,9 +873,10 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, SDL_memset(periodic, 0, sizeof(FFPERIODIC)); /* Specifics */ - periodic->dwMagnitude = CONVERT(hap_periodic->magnitude); + periodic->dwMagnitude = CONVERT(SDL_abs(hap_periodic->magnitude)); periodic->lOffset = CONVERT(hap_periodic->offset); - periodic->dwPhase = hap_periodic->phase; + periodic->dwPhase = + (hap_periodic->phase + (hap_periodic->magnitude < 0 ? 18000 : 0)) % 36000; periodic->dwPeriod = hap_periodic->period * 1000; dest->cbTypeSpecificParams = sizeof(FFPERIODIC); dest->lpvTypeSpecificParams = periodic; diff -uNrp rev1/src/haptic/windows/SDL_dinputhaptic.c rev2/src/haptic/windows/SDL_dinputhaptic.c --- rev1/src/haptic/windows/SDL_dinputhaptic.c 2014-08-17 00:20:14.000000000 +0200 +++ rev2/src/haptic/windows/SDL_dinputhaptic.c 2014-08-23 21:01:46.792030148 +0200 @@ -21,6 +21,7 @@ #include "../../SDL_internal.h" #include "SDL_error.h" +#include "SDL_stdinc.h" #include "SDL_haptic.h" #include "SDL_timer.h" #include "SDL_windowshaptic_c.h" @@ -714,9 +715,10 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, SDL_memset(periodic, 0, sizeof(DIPERIODIC)); /* Specifics */ - periodic->dwMagnitude = CONVERT(hap_periodic->magnitude); + periodic->dwMagnitude = CONVERT(SDL_abs(hap_periodic->magnitude)); periodic->lOffset = CONVERT(hap_periodic->offset); - periodic->dwPhase = hap_periodic->phase; + periodic->dwPhase = + (hap_periodic->phase + (hap_periodic->magnitude < 0 ? 18000 : 0)) % 36000; periodic->dwPeriod = hap_periodic->period * 1000; dest->cbTypeSpecificParams = sizeof(DIPERIODIC); dest->lpvTypeSpecificParams = periodic; diff -uNrp rev1/test/testhaptic.c rev2/test/testhaptic.c --- rev1/test/testhaptic.c 2014-08-17 00:20:14.000000000 +0200 +++ rev2/test/testhaptic.c 2014-08-23 22:33:59.242997030 +0200 @@ -122,7 +122,8 @@ main(int argc, char **argv) SDL_Log(" effect %d: Sine Wave\n", nefx); efx[nefx].type = SDL_HAPTIC_SINE; efx[nefx].periodic.period = 1000; - efx[nefx].periodic.magnitude = 0x4000; + efx[nefx].periodic.magnitude = -0x2000; /* Negative magnitude and ... */ + efx[nefx].periodic.phase = 18000; /* ... 180 degrees phase shift => cancel eachother */ efx[nefx].periodic.length = 5000; efx[nefx].periodic.attack_length = 1000; efx[nefx].periodic.fade_length = 1000;