src/haptic/SDL_haptic.c
branchgsoc2008_force_feedback
changeset 2484 666472fd4cb0
parent 2483 9d52368ebcf5
child 2485 67978eea6d10
--- a/src/haptic/SDL_haptic.c	Tue Jul 01 14:09:53 2008 +0000
+++ b/src/haptic/SDL_haptic.c	Tue Jul 01 14:21:09 2008 +0000
@@ -334,6 +334,11 @@
       return -1;
    }
 
+   if ((haptic->supported & SDL_HAPTIC_GAIN) == 0) {
+      SDL_SetError("Haptic device does not support setting gain.");
+      return -1;
+   }
+
    if ((gain < 0) || (gain > 100)) {
       SDL_SetError("Haptic gain must be between 0 and 100.");
       return -1;
@@ -346,4 +351,31 @@
    return 0;
 }
 
+/*
+ * Makes the device autocenter, 0 disables.
+ */
+int
+SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter )
+{
+   if (!ValidHaptic(&haptic)) {
+      return -1;
+   }
 
+   if ((haptic->supported & SDL_HAPTIC_AUTOCENTER) == 0) {
+      SDL_SetError("Haptic device does not support setting autocenter.");
+      return -1;
+   }
+
+   if ((autocenter < 0) || (autocenter > 100)) {
+      SDL_SetError("Haptic autocenter must be between 0 and 100.");
+      return -1;
+   }                                           
+
+   if (SDL_SYS_HapticSetAutocenter(haptic,autocenter) < 0) {
+      return -1;
+   }
+
+   return 0;
+}
+
+