From ef8c3d89ce341d260f5942b63f2dfbb846319bf6 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 29 Nov 2014 11:48:43 -0800 Subject: [PATCH] Fixed bug 2766 - Haptic coding bugs and fixes for Linux FF: periodic.phase handled as time instead of angle; + direction clarification Elias Vanderstuyft It's not obvious from the general "haptic direction" description what the SDL direction actually means in terms of force magnitude sign, currently its meaning is only reflected by the example. --- include/SDL_haptic.h | 3 +++ src/haptic/linux/SDL_syshaptic.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/include/SDL_haptic.h b/include/SDL_haptic.h index 569c635edd072..eb87d6862aacc 100644 --- a/include/SDL_haptic.h +++ b/include/SDL_haptic.h @@ -347,6 +347,9 @@ typedef struct _SDL_Haptic SDL_Haptic; /** * \brief Structure that represents a haptic direction. * + * This is the direction where the force comes from, + * instead of the direction in which the force is exerted. + * * Directions can be specified by: * - ::SDL_HAPTIC_POLAR : Specified by polar coordinates. * - ::SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates. diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index 459d0ab245244..f75f7b81b0ad2 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -669,6 +669,8 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src) 90 deg -> 0x4000 (left) 180 deg -> 0x8000 (up) 270 deg -> 0xC000 (right) + The force pulls into the direction specified by Linux directions, + i.e. the opposite convention of SDL directions. */ tmp = ((src->dir[0] % 36000) * 0x8000) / 18000; /* convert to range [0,0xFFFF] */ *dest = (Uint16) tmp;