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
More comments.
Some code clean up.
  • Loading branch information
bobbens committed Aug 12, 2008
1 parent 02ea14d commit 0a3513d
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/haptic/linux/SDL_syshaptic.c
Expand Up @@ -30,32 +30,28 @@
#include "../../joystick/linux/SDL_sysjoystick_c.h" /* For joystick hwdata */

#include <unistd.h> /* close */
#include <linux/input.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/limits.h>
#include <linux/input.h> /* Force feedback linux stuff. */
#include <fcntl.h> /* O_RDWR */
#include <limits.h> /* INT_MAX */
#include <string.h>
#include <errno.h>
#include <math.h>
#include <errno.h> /* errno, strerror */
#include <math.h> /* atan2 */

/* Just in case. */
#ifndef M_PI
# define M_PI 3.14159265358979323846
#endif


#define MAX_HAPTICS 32
#define MAX_HAPTICS 32 /* It's doubtful someone has more then 32 evdev */


/*
* List of available haptic devices.
*/
static struct
{
char *fname;
SDL_Haptic *haptic;
char *fname; /* Dev path name (like /dev/input/event1) */
SDL_Haptic *haptic; /* Assosciated haptic. */
} SDL_hapticlist[MAX_HAPTICS];


Expand All @@ -64,7 +60,7 @@ static struct
*/
struct haptic_hwdata
{
int fd;
int fd; /* File descriptor of the device. */
char *fname; /* Points to the name in SDL_hapticlist. */
};

Expand Down Expand Up @@ -348,6 +344,7 @@ SDL_SYS_HapticMouse(void)
return -1;
}

/* Is it a mouse? */
if (EV_IsMouse(fd)) {
close(fd);
return i;
Expand Down Expand Up @@ -469,6 +466,10 @@ SDL_SYS_ToButton( Uint16 button )

ff_button = 0;

/*
* Not sure what the proper syntax is because this actually isn't implemented
* in the current kernel from what I've seen (2.6.26).
*/
if (button != 0) {
ff_button = BTN_GAMEPAD + button - 1;
}
Expand Down Expand Up @@ -648,6 +649,10 @@ SDL_SYS_ToFFEffect( struct ff_effect * dest, SDL_HapticEffect * src )
dest->u.condition[1].deadband = CLAMP(condition->deadband[1]);
dest->u.condition[1].center = condition->center[1];

/*
* There is no envelope in the linux force feedback api for conditions.
*/

break;

case SDL_HAPTIC_RAMP:
Expand Down

0 comments on commit 0a3513d

Please sign in to comment.