Fixed bug 2766 - Haptic coding bugs and fixes for Linux FF: periodic.phase handled as time instead of angle; + direction clarification
authorSam Lantinga <slouken@libsdl.org>
Sat, 29 Nov 2014 11:48:43 -0800
changeset 924935a4fab04296
parent 9248 dabd5df43970
child 9250 50fb32b7f2bd
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
src/haptic/linux/SDL_syshaptic.c
     1.1 --- a/include/SDL_haptic.h	Sat Nov 29 11:18:49 2014 -0800
     1.2 +++ b/include/SDL_haptic.h	Sat Nov 29 11:48:43 2014 -0800
     1.3 @@ -347,6 +347,9 @@
     1.4  /**
     1.5   *  \brief Structure that represents a haptic direction.
     1.6   *
     1.7 + *  This is the direction where the force comes from,
     1.8 + *  instead of the direction in which the force is exerted.
     1.9 + *
    1.10   *  Directions can be specified by:
    1.11   *   - ::SDL_HAPTIC_POLAR : Specified by polar coordinates.
    1.12   *   - ::SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates.
     2.1 --- a/src/haptic/linux/SDL_syshaptic.c	Sat Nov 29 11:18:49 2014 -0800
     2.2 +++ b/src/haptic/linux/SDL_syshaptic.c	Sat Nov 29 11:48:43 2014 -0800
     2.3 @@ -669,6 +669,8 @@
     2.4                          90 deg -> 0x4000 (left)
     2.5                          180 deg -> 0x8000 (up)
     2.6                          270 deg -> 0xC000 (right)
     2.7 +                   The force pulls into the direction specified by Linux directions,
     2.8 +                   i.e. the opposite convention of SDL directions.
     2.9                      */
    2.10          tmp = ((src->dir[0] % 36000) * 0x8000) / 18000; /* convert to range [0,0xFFFF] */
    2.11          *dest = (Uint16) tmp;