Fixed bug 3446 - The haptic API does not allow to select the direction axes
authorSam Lantinga <slouken@libsdl.org>
Tue, 17 Mar 2020 14:18:05 -0700
changeset 13645f7fc52b64177
parent 13644 b1ebbd8cafef
child 13646 784ce9766fb9
Fixed bug 3446 - The haptic API does not allow to select the direction axes

meyraud705

Added Linux implementation, otherwise you get "Unsupported direction type" error.
Added documentation to explain why one would use SDL_HAPTIC_FIRST_AXIS.
include/SDL_haptic.h
src/haptic/linux/SDL_syshaptic.c
     1.1 --- a/include/SDL_haptic.h	Tue Mar 17 15:47:30 2020 +0100
     1.2 +++ b/include/SDL_haptic.h	Tue Mar 17 14:18:05 2020 -0700
     1.3 @@ -338,7 +338,17 @@
     1.4  
     1.5  /**
     1.6   *  \brief Uses first axis only.
     1.7 - *
     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   *  \sa SDL_HapticDirection
    1.20   */
    1.21  #define SDL_HAPTIC_FIRST_AXIS 3
    1.22 @@ -451,6 +461,7 @@
    1.23   *  \sa SDL_HAPTIC_POLAR
    1.24   *  \sa SDL_HAPTIC_CARTESIAN
    1.25   *  \sa SDL_HAPTIC_SPHERICAL
    1.26 + *  \sa SDL_HAPTIC_FIRST_AXIS
    1.27   *  \sa SDL_HapticEffect
    1.28   *  \sa SDL_HapticNumAxes
    1.29   */
     2.1 --- a/src/haptic/linux/SDL_syshaptic.c	Tue Mar 17 15:47:30 2020 +0100
     2.2 +++ b/src/haptic/linux/SDL_syshaptic.c	Tue Mar 17 14:18:05 2020 -0700
     2.3 @@ -718,7 +718,9 @@
     2.4              *dest = (Uint16) tmp;
     2.5          }
     2.6          break;
     2.7 -
     2.8 +    case SDL_HAPTIC_FIRST_AXIS:
     2.9 +        *dest = 0x4000;
    2.10 +        break;
    2.11      default:
    2.12          return SDL_SetError("Haptic: Unsupported direction type.");
    2.13      }