Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Implemented SDL_HAPTIC_CARTESIAN on linux.
  • Loading branch information
bobbens committed Jul 9, 2008
1 parent f36b472 commit 8da2af6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/haptic/linux/SDL_syshaptic.c
Expand Up @@ -38,6 +38,11 @@
#include <linux/limits.h>
#include <string.h>
#include <errno.h>
#include <math.h>

#ifndef M_PI
# define M_PI 3.14159265358979323846
#endif


#define MAX_HAPTICS 32
Expand Down Expand Up @@ -338,6 +343,7 @@ static Uint16
SDL_SYS_ToDirection( SDL_HapticDirection * dir )
{
Uint32 tmp;
float f;

switch (dir->type) {
case SDL_HAPTIC_POLAR:
Expand All @@ -346,8 +352,10 @@ SDL_SYS_ToDirection( SDL_HapticDirection * dir )
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:
Expand Down

0 comments on commit 8da2af6

Please sign in to comment.