# HG changeset patch # User Edgar Simo # Date 1215627834 0 # Node ID e6ad7e678fcaa43fb12adbcff30f02b0399be5ed # Parent 3b54b3a97046e9341547096868adf2dee702668c Implemented SDL_HAPTIC_CARTESIAN on linux. diff -r 3b54b3a97046 -r e6ad7e678fca src/haptic/linux/SDL_syshaptic.c --- a/src/haptic/linux/SDL_syshaptic.c Wed Jul 09 17:06:54 2008 +0000 +++ b/src/haptic/linux/SDL_syshaptic.c Wed Jul 09 18:23:54 2008 +0000 @@ -38,6 +38,11 @@ #include #include #include +#include + +#ifndef M_PI +# define M_PI 3.14159265358979323846 +#endif #define MAX_HAPTICS 32 @@ -338,6 +343,7 @@ SDL_SYS_ToDirection( SDL_HapticDirection * dir ) { Uint32 tmp; + float f; switch (dir->type) { case SDL_HAPTIC_POLAR: @@ -346,8 +352,10 @@ return (Uint16) tmp; break; case SDL_HAPTIC_CARTESIAN: - /* TODO implement cartesian for linux since it's not supported - * by driver */ + f = atan2(dir->dir[0], dir->dir[1]); + tmp = (int)(f*18000./M_PI) % 36000; + tmp = (tmp * 0xFFFF) / 36000; + return (Uint16) tmp; break; default: