diff src/haptic/SDL_haptic.c @ 2484:666472fd4cb0 gsoc2008_force_feedback

HapticSetGain checks to see if device supports it. Added HapticSetAutocenter().
author Edgar Simo <bobbens@gmail.com>
date Tue, 01 Jul 2008 14:21:09 +0000
parents 9d52368ebcf5
children 67978eea6d10
line wrap: on
line diff
--- 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;
+}
+
+