Improvement for bug 3446 - The haptic API does not allow to select the direction axes
authorSam Lantinga <slouken@libsdl.org>
Mon, 04 May 2020 13:17:43 -0700
changeset 13789a359f4f93439
parent 13788 56eb55f090f3
child 13790 fdabcc76aaaf
Improvement for bug 3446 - The haptic API does not allow to select the direction axes

meyraud705

I see how the documentation is confusing. I think that the choice of the axis is an implementation detail. The documentation should state the goal of this value, so I propose this wording:

"Use this value to play an effect on the steering wheel axis. This provides
better compatibility across platforms and devices as SDL will guess the
correct axis."

Value could even be renamed 'SDL_HAPTIC_STEERING_AXIS'.

For Linux, sending an effect on the X axis with a Logitech wheel works. Others brands don't have driver for Linux as far as I know.
include/SDL_haptic.h
src/haptic/darwin/SDL_syshaptic.c
src/haptic/linux/SDL_syshaptic.c
src/haptic/windows/SDL_dinputhaptic.c
     1.1 --- a/include/SDL_haptic.h	Mon May 04 10:16:10 2020 -0700
     1.2 +++ b/include/SDL_haptic.h	Mon May 04 13:17:43 2020 -0700
     1.3 @@ -337,21 +337,12 @@
     1.4  #define SDL_HAPTIC_SPHERICAL  2
     1.5  
     1.6  /**
     1.7 - *  \brief Uses first axis only.
     1.8 - *  For some device with only one axis (steering wheel,...),
     1.9 - *  SDL_HAPTIC_CARTESIAN does not work. SDL_HAPTIC_FIRST_AXIS can be used in 
    1.10 - *  this case.
    1.11 - *  Using SDL_HAPTIC_FIRST_AXIS is equivalent to :
    1.12 - *  \code
    1.13 - *  SDL_HapticDirection direction;
    1.14 - *  direction.type = SDL_HAPTIC_CARTESIAN;
    1.15 - *  direction.dir[0] = 1;
    1.16 - *  direction.dir[1] = 0;
    1.17 - *  direction.dir[2] = 0;
    1.18 - *  \endcode
    1.19 + *  \brief Use this value to play an effect on the steering wheel axis. This 
    1.20 + *  provides better compatibility across platforms and devices as SDL will guess 
    1.21 + *  the correct axis.
    1.22   *  \sa SDL_HapticDirection
    1.23   */
    1.24 -#define SDL_HAPTIC_FIRST_AXIS 3
    1.25 +#define SDL_HAPTIC_STEERING_AXIS 3
    1.26  
    1.27  /* @} *//* Direction encodings */
    1.28  
    1.29 @@ -461,7 +452,7 @@
    1.30   *  \sa SDL_HAPTIC_POLAR
    1.31   *  \sa SDL_HAPTIC_CARTESIAN
    1.32   *  \sa SDL_HAPTIC_SPHERICAL
    1.33 - *  \sa SDL_HAPTIC_FIRST_AXIS
    1.34 + *  \sa SDL_HAPTIC_STEERING_AXIS
    1.35   *  \sa SDL_HapticEffect
    1.36   *  \sa SDL_HapticNumAxes
    1.37   */
     2.1 --- a/src/haptic/darwin/SDL_syshaptic.c	Mon May 04 10:16:10 2020 -0700
     2.2 +++ b/src/haptic/darwin/SDL_syshaptic.c	Mon May 04 13:17:43 2020 -0700
     2.3 @@ -765,7 +765,7 @@
     2.4              rglDir[2] = dir->dir[2];
     2.5          }
     2.6          return 0;
     2.7 -    case SDL_HAPTIC_FIRST_AXIS:
     2.8 +    case SDL_HAPTIC_STEERING_AXIS:
     2.9          effect->dwFlags |= FFEFF_CARTESIAN;
    2.10          rglDir[0] = 0;
    2.11          return 0;
    2.12 @@ -817,7 +817,7 @@
    2.13      envelope->dwSize = sizeof(FFENVELOPE);      /* Always should be this. */
    2.14  
    2.15      /* Axes. */
    2.16 -    if (src->constant.direction.type == SDL_HAPTIC_FIRST_AXIS) {
    2.17 +    if (src->constant.direction.type == SDL_HAPTIC_STEERING_AXIS) {
    2.18          dest->cAxes = 1;
    2.19      } else {
    2.20          dest->cAxes = haptic->naxes;
     3.1 --- a/src/haptic/linux/SDL_syshaptic.c	Mon May 04 10:16:10 2020 -0700
     3.2 +++ b/src/haptic/linux/SDL_syshaptic.c	Mon May 04 13:17:43 2020 -0700
     3.3 @@ -718,7 +718,7 @@
     3.4              *dest = (Uint16) tmp;
     3.5          }
     3.6          break;
     3.7 -    case SDL_HAPTIC_FIRST_AXIS:
     3.8 +    case SDL_HAPTIC_STEERING_AXIS:
     3.9          *dest = 0x4000;
    3.10          break;
    3.11      default:
     4.1 --- a/src/haptic/windows/SDL_dinputhaptic.c	Mon May 04 10:16:10 2020 -0700
     4.2 +++ b/src/haptic/windows/SDL_dinputhaptic.c	Mon May 04 13:17:43 2020 -0700
     4.3 @@ -589,7 +589,7 @@
     4.4          if (naxes > 2)
     4.5              rglDir[2] = dir->dir[2];
     4.6          return 0;
     4.7 -    case SDL_HAPTIC_FIRST_AXIS:
     4.8 +    case SDL_HAPTIC_STEERING_AXIS:
     4.9          effect->dwFlags |= DIEFF_CARTESIAN;
    4.10          rglDir[0] = 0;
    4.11          return 0;
    4.12 @@ -641,7 +641,7 @@
    4.13      envelope->dwSize = sizeof(DIENVELOPE);      /* Always should be this. */
    4.14  
    4.15      /* Axes. */
    4.16 -    if (src->constant.direction.type == SDL_HAPTIC_FIRST_AXIS) {
    4.17 +    if (src->constant.direction.type == SDL_HAPTIC_STEERING_AXIS) {
    4.18          dest->cAxes = 1;
    4.19      } else {
    4.20          dest->cAxes = haptic->naxes;