From b482ac39f00967e00fe2f55162918962bfa5ea8a Mon Sep 17 00:00:00 2001 From: Edgar Simo Date: Wed, 9 Jul 2008 18:29:11 +0000 Subject: [PATCH] Fixed bugs in documentation. Improved code correctness a bit. --- include/SDL_haptic.h | 10 +++++----- src/haptic/linux/SDL_syshaptic.c | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/SDL_haptic.h b/include/SDL_haptic.h index d68e1ae0c..4c2745f05 100644 --- a/include/SDL_haptic.h +++ b/include/SDL_haptic.h @@ -306,16 +306,16 @@ typedef struct _SDL_Haptic SDL_Haptic; * If type is SDL_HAPTIC_POLAR, direction is encoded by hundredths of a * degree starting north and turning clockwise. The cardinal directions would be: * - North: 0 (0 degrees) - * - West: 9000 (90 degrees) + * - East: 9000 (90 degrees) * - South: 18000 (180 degrees) - * - East: 27000 (270 degrees) + * - West: 27000 (270 degrees) * * If type is SDL_HAPTIC_CARTESIAN, direction is encoded by position. * The cardinal directions would be: * - North: 0,-1 - * - West: -1, 0 + * - East: -1, 0 * - South: 0, 1 - * - East: 1, 0 + * - West: 1, 0 * * * Example: @@ -323,7 +323,7 @@ typedef struct _SDL_Haptic SDL_Haptic; * SDL_HapticDirection direction; * * direction.type = SDL_HAPTIC_POLAR; // We'll be using polar direction encoding. - * direction.dir = 180000; // Force comes from the south meaning the user will + * direction.dir = 18000; // Force comes from the south meaning the user will * // have to pull the stick to counteract. * \endcode * diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index b6428ece4..50c3e45e2 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -72,7 +72,7 @@ struct haptic_hwdata */ struct haptic_hweffect { - struct ff_effect effect; + struct ff_effect effect; /* The linux kernel effect structure. */ }; @@ -343,20 +343,19 @@ static Uint16 SDL_SYS_ToDirection( SDL_HapticDirection * dir ) { Uint32 tmp; - float f; + float f; /* Ideally we'd use fixed point math instead of floats... */ switch (dir->type) { case SDL_HAPTIC_POLAR: /* Linux directions are inverted. */ tmp = (((18000 + dir->dir[0]) % 36000) * 0xFFFF) / 36000; return (Uint16) tmp; - break; case SDL_HAPTIC_CARTESIAN: + /* We must invert "x" and "y" to go clockwise. */ f = atan2(dir->dir[0], dir->dir[1]); tmp = (int)(f*18000./M_PI) % 36000; tmp = (tmp * 0xFFFF) / 36000; return (Uint16) tmp; - break; default: return -1;