More comments.
Some code clean up.
1.1 --- a/src/haptic/linux/SDL_syshaptic.c Tue Aug 12 20:46:39 2008 +0000
1.2 +++ b/src/haptic/linux/SDL_syshaptic.c Tue Aug 12 20:49:31 2008 +0000
1.3 @@ -30,23 +30,19 @@
1.4 #include "../../joystick/linux/SDL_sysjoystick_c.h" /* For joystick hwdata */
1.5
1.6 #include <unistd.h> /* close */
1.7 -#include <linux/input.h>
1.8 -#include <sys/ioctl.h>
1.9 -#include <sys/types.h>
1.10 -#include <sys/stat.h>
1.11 -#include <fcntl.h>
1.12 -#include <linux/limits.h>
1.13 +#include <linux/input.h> /* Force feedback linux stuff. */
1.14 +#include <fcntl.h> /* O_RDWR */
1.15 #include <limits.h> /* INT_MAX */
1.16 -#include <string.h>
1.17 -#include <errno.h>
1.18 -#include <math.h>
1.19 +#include <errno.h> /* errno, strerror */
1.20 +#include <math.h> /* atan2 */
1.21
1.22 +/* Just in case. */
1.23 #ifndef M_PI
1.24 # define M_PI 3.14159265358979323846
1.25 #endif
1.26
1.27
1.28 -#define MAX_HAPTICS 32
1.29 +#define MAX_HAPTICS 32 /* It's doubtful someone has more then 32 evdev */
1.30
1.31
1.32 /*
1.33 @@ -54,8 +50,8 @@
1.34 */
1.35 static struct
1.36 {
1.37 - char *fname;
1.38 - SDL_Haptic *haptic;
1.39 + char *fname; /* Dev path name (like /dev/input/event1) */
1.40 + SDL_Haptic *haptic; /* Assosciated haptic. */
1.41 } SDL_hapticlist[MAX_HAPTICS];
1.42
1.43
1.44 @@ -64,7 +60,7 @@
1.45 */
1.46 struct haptic_hwdata
1.47 {
1.48 - int fd;
1.49 + int fd; /* File descriptor of the device. */
1.50 char *fname; /* Points to the name in SDL_hapticlist. */
1.51 };
1.52
1.53 @@ -348,6 +344,7 @@
1.54 return -1;
1.55 }
1.56
1.57 + /* Is it a mouse? */
1.58 if (EV_IsMouse(fd)) {
1.59 close(fd);
1.60 return i;
1.61 @@ -469,6 +466,10 @@
1.62
1.63 ff_button = 0;
1.64
1.65 + /*
1.66 + * Not sure what the proper syntax is because this actually isn't implemented
1.67 + * in the current kernel from what I've seen (2.6.26).
1.68 + */
1.69 if (button != 0) {
1.70 ff_button = BTN_GAMEPAD + button - 1;
1.71 }
1.72 @@ -648,6 +649,10 @@
1.73 dest->u.condition[1].deadband = CLAMP(condition->deadband[1]);
1.74 dest->u.condition[1].center = condition->center[1];
1.75
1.76 + /*
1.77 + * There is no envelope in the linux force feedback api for conditions.
1.78 + */
1.79 +
1.80 break;
1.81
1.82 case SDL_HAPTIC_RAMP: