Fixed bug 3446 - The haptic API does not allow to select the direction axes Mathieu Laurendeau Consider a device supporting effects on multiple axes. There's currently no way to play effects against a single-axis direction. A device supporting effects against X and Y may not allow to play effects with a two-axis direction coordinate, even if one of the coordinates is null. My current (ugly) work around for this is to add a direction type SDL_HAPTIC_X_FORCE to play effects against a X-axis only direction (patch attached). This issue impacted two GIMX users using the following wheels: - Leo Bodnar SimSteering force feedback wheel - Accuforce direct drive wheel Playing constant/spring/damper effects against a X-axis direction worked well for the first wheel, but not for the second one. A better strategy seems to play the effects against the first axis reported by the DirectInput enumeration. This strategy also works with Logitech wheels (at least the DFGT). It's been more than a year that I have the latest patch (playing effects against the first axis only) in the GIMX software. It's being used by thousands of people, mostly for adapting their FFB wheel to the PS4. I had no report that proves this strategy to be wrong.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
diff --git a/include/SDL_haptic.h b/include/SDL_haptic.h
index aa6f47f..b43f6fb 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 ecbd2bd..55d28b8 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 cccc74f..ea7526a 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) {