diff --git a/include/SDL_haptic.h b/include/SDL_haptic.h index aa6f47fdd..b43f6fb6a 100644 --- a/include/SDL_haptic.h +++ b/include/SDL_haptic.h @@ -336,6 +336,13 @@ typedef struct _SDL_Haptic SDL_Haptic; */ #define SDL_HAPTIC_SPHERICAL 2 +/** + * \brief Uses first axis only. + * + * \sa SDL_HapticDirection + */ +#define SDL_HAPTIC_FIRST_AXIS 3 + /* @} *//* Direction encodings */ /* @} *//* Haptic features */ diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c index ecbd2bdf1..55d28b80e 100644 --- a/src/haptic/darwin/SDL_syshaptic.c +++ b/src/haptic/darwin/SDL_syshaptic.c @@ -765,6 +765,10 @@ SDL_SYS_SetDirection(FFEFFECT * effect, SDL_HapticDirection * dir, int naxes) rglDir[2] = dir->dir[2]; } return 0; + case SDL_HAPTIC_FIRST_AXIS: + effect->dwFlags |= FFEFF_CARTESIAN; + rglDir[0] = 0; + return 0; default: return SDL_SetError("Haptic: Unknown direction type."); @@ -813,7 +817,11 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src) envelope->dwSize = sizeof(FFENVELOPE); /* Always should be this. */ /* Axes. */ - dest->cAxes = haptic->naxes; + if (src->constant.direction.type == SDL_HAPTIC_FIRST_AXIS) { + dest->cAxes = 1; + } else { + dest->cAxes = haptic->naxes; + } if (dest->cAxes > 0) { axes = SDL_malloc(sizeof(DWORD) * dest->cAxes); if (axes == NULL) { diff --git a/src/haptic/windows/SDL_dinputhaptic.c b/src/haptic/windows/SDL_dinputhaptic.c index cccc74fae..ea7526aca 100644 --- a/src/haptic/windows/SDL_dinputhaptic.c +++ b/src/haptic/windows/SDL_dinputhaptic.c @@ -589,6 +589,10 @@ SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir, int naxes) if (naxes > 2) rglDir[2] = dir->dir[2]; return 0; + case SDL_HAPTIC_FIRST_AXIS: + effect->dwFlags |= DIEFF_CARTESIAN; + rglDir[0] = 0; + return 0; default: return SDL_SetError("Haptic: Unknown direction type."); @@ -637,7 +641,11 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, envelope->dwSize = sizeof(DIENVELOPE); /* Always should be this. */ /* Axes. */ - dest->cAxes = haptic->naxes; + if (src->constant.direction.type == SDL_HAPTIC_FIRST_AXIS) { + dest->cAxes = 1; + } else { + dest->cAxes = haptic->naxes; + } if (dest->cAxes > 0) { axes = SDL_malloc(sizeof(DWORD) * dest->cAxes); if (axes == NULL) {