Fixed bugs in documentation. gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Wed, 09 Jul 2008 18:29:11 +0000
branchgsoc2008_force_feedback
changeset 2511f12ae0bae468
parent 2510 e6ad7e678fca
child 2512 ef147ee4896c
Fixed bugs in documentation.
Improved code correctness a bit.
include/SDL_haptic.h
src/haptic/linux/SDL_syshaptic.c
     1.1 --- a/include/SDL_haptic.h	Wed Jul 09 18:23:54 2008 +0000
     1.2 +++ b/include/SDL_haptic.h	Wed Jul 09 18:29:11 2008 +0000
     1.3 @@ -306,16 +306,16 @@
     1.4   * If type is SDL_HAPTIC_POLAR, direction is encoded by hundredths of a 
     1.5   *  degree starting north and turning clockwise.  The cardinal directions would be:
     1.6   *   - North: 0 (0 degrees)
     1.7 - *   - West: 9000 (90 degrees)
     1.8 + *   - East: 9000 (90 degrees)
     1.9   *   - South: 18000 (180 degrees)
    1.10 - *   - East: 27000 (270 degrees)
    1.11 + *   - West: 27000 (270 degrees)
    1.12   *
    1.13   * If type is SDL_HAPTIC_CARTESIAN, direction is encoded by position.
    1.14   *  The cardinal directions would be:
    1.15   *   - North:  0,-1
    1.16 - *   - West:  -1, 0
    1.17 + *   - East:  -1, 0
    1.18   *   - South:  0, 1
    1.19 - *   - East:   1, 0
    1.20 + *   - West:   1, 0
    1.21   *
    1.22   *
    1.23   * Example:
    1.24 @@ -323,7 +323,7 @@
    1.25   * SDL_HapticDirection direction;
    1.26   *
    1.27   * direction.type = SDL_HAPTIC_POLAR; // We'll be using polar direction encoding.
    1.28 - * direction.dir = 180000; // Force comes from the south meaning the user will
    1.29 + * direction.dir = 18000; // Force comes from the south meaning the user will
    1.30   *                         // have to pull the stick to counteract.
    1.31   * \endcode
    1.32   *
     2.1 --- a/src/haptic/linux/SDL_syshaptic.c	Wed Jul 09 18:23:54 2008 +0000
     2.2 +++ b/src/haptic/linux/SDL_syshaptic.c	Wed Jul 09 18:29:11 2008 +0000
     2.3 @@ -72,7 +72,7 @@
     2.4   */
     2.5  struct haptic_hweffect
     2.6  {
     2.7 -   struct ff_effect effect;
     2.8 +   struct ff_effect effect; /* The linux kernel effect structure. */
     2.9  };
    2.10  
    2.11  
    2.12 @@ -343,20 +343,19 @@
    2.13  SDL_SYS_ToDirection( SDL_HapticDirection * dir )
    2.14  {
    2.15     Uint32 tmp;
    2.16 -   float f;
    2.17 +   float f; /* Ideally we'd use fixed point math instead of floats... */
    2.18  
    2.19     switch (dir->type) {
    2.20        case SDL_HAPTIC_POLAR:
    2.21           /* Linux directions are inverted. */
    2.22           tmp = (((18000 + dir->dir[0]) % 36000) * 0xFFFF) / 36000;
    2.23           return (Uint16) tmp;
    2.24 -         break;
    2.25        case SDL_HAPTIC_CARTESIAN:
    2.26 +         /* We must invert "x" and "y" to go clockwise. */
    2.27           f = atan2(dir->dir[0], dir->dir[1]);
    2.28           tmp = (int)(f*18000./M_PI) % 36000;
    2.29           tmp = (tmp * 0xFFFF) / 36000;
    2.30           return (Uint16) tmp;
    2.31 -         break;
    2.32  
    2.33        default:
    2.34           return -1;