From 4c22a21e06421ff943b3e4fc9cf5c477f3109b67 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 17 Mar 2020 14:18:05 -0700 Subject: [PATCH] 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 | 13 ++++++++++++- src/haptic/linux/SDL_syshaptic.c | 4 +++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/SDL_haptic.h b/include/SDL_haptic.h index b43f6fb6abac6..18c74eff6e1a7 100644 --- a/include/SDL_haptic.h +++ b/include/SDL_haptic.h @@ -338,7 +338,17 @@ typedef struct _SDL_Haptic SDL_Haptic; /** * \brief Uses first axis only. - * + * For some device with only one axis (steering wheel,...), + * SDL_HAPTIC_CARTESIAN does not work. SDL_HAPTIC_FIRST_AXIS can be used in + * this case. + * Using SDL_HAPTIC_FIRST_AXIS is equivalent to : + * \code + * SDL_HapticDirection direction; + * direction.type = SDL_HAPTIC_CARTESIAN; + * direction.dir[0] = 1; + * direction.dir[1] = 0; + * direction.dir[2] = 0; + * \endcode * \sa SDL_HapticDirection */ #define SDL_HAPTIC_FIRST_AXIS 3 @@ -451,6 +461,7 @@ typedef struct _SDL_Haptic SDL_Haptic; * \sa SDL_HAPTIC_POLAR * \sa SDL_HAPTIC_CARTESIAN * \sa SDL_HAPTIC_SPHERICAL + * \sa SDL_HAPTIC_FIRST_AXIS * \sa SDL_HapticEffect * \sa SDL_HapticNumAxes */ diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index c18b7a03aa700..b8e7f13384f37 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -718,7 +718,9 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src) *dest = (Uint16) tmp; } break; - + case SDL_HAPTIC_FIRST_AXIS: + *dest = 0x4000; + break; default: return SDL_SetError("Haptic: Unsupported direction type."); }