src/haptic/SDL_haptic.c
branchgsoc2008_force_feedback
changeset 2484 666472fd4cb0
parent 2483 9d52368ebcf5
child 2485 67978eea6d10
     1.1 --- a/src/haptic/SDL_haptic.c	Tue Jul 01 14:09:53 2008 +0000
     1.2 +++ b/src/haptic/SDL_haptic.c	Tue Jul 01 14:21:09 2008 +0000
     1.3 @@ -334,6 +334,11 @@
     1.4        return -1;
     1.5     }
     1.6  
     1.7 +   if ((haptic->supported & SDL_HAPTIC_GAIN) == 0) {
     1.8 +      SDL_SetError("Haptic device does not support setting gain.");
     1.9 +      return -1;
    1.10 +   }
    1.11 +
    1.12     if ((gain < 0) || (gain > 100)) {
    1.13        SDL_SetError("Haptic gain must be between 0 and 100.");
    1.14        return -1;
    1.15 @@ -346,4 +351,31 @@
    1.16     return 0;
    1.17  }
    1.18  
    1.19 +/*
    1.20 + * Makes the device autocenter, 0 disables.
    1.21 + */
    1.22 +int
    1.23 +SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter )
    1.24 +{
    1.25 +   if (!ValidHaptic(&haptic)) {
    1.26 +      return -1;
    1.27 +   }
    1.28  
    1.29 +   if ((haptic->supported & SDL_HAPTIC_AUTOCENTER) == 0) {
    1.30 +      SDL_SetError("Haptic device does not support setting autocenter.");
    1.31 +      return -1;
    1.32 +   }
    1.33 +
    1.34 +   if ((autocenter < 0) || (autocenter > 100)) {
    1.35 +      SDL_SetError("Haptic autocenter must be between 0 and 100.");
    1.36 +      return -1;
    1.37 +   }                                           
    1.38 +
    1.39 +   if (SDL_SYS_HapticSetAutocenter(haptic,autocenter) < 0) {
    1.40 +      return -1;
    1.41 +   }
    1.42 +
    1.43 +   return 0;
    1.44 +}
    1.45 +
    1.46 +